Changeset 5fa248011061e1436ae212075879aeed6634c0d9

Show
Ignore:
Timestamp:
06/17/07 17:23:21 (1 year ago)
Author:
Christopher Jung <bktheg@web.de>
git-committer:
Christopher Jung <bktheg@web.de> 1182093801 +0200
git-parent:

[3a4d21b128e99eca998913a19f89740275988fd2]

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

Erster Teil des Modul 'Schiff' auf die neue Schiffsklasse umgestellt

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/net/driftingsouls/ds2/server/framework/db/HibernateFacade.java

    r3924571 r5fa2480  
    2525import net.driftingsouls.ds2.server.framework.xml.XMLUtils; 
    2626 
     27import org.hibernate.Hibernate; 
    2728import org.hibernate.Session; 
    2829import org.hibernate.SessionFactory; 
    2930import org.hibernate.cfg.AnnotationConfiguration; 
     31import org.hibernate.dialect.function.StandardSQLFunction; 
    3032import org.hibernate.stat.Statistics; 
    3133import org.w3c.dom.Document; 
     
    4648                conf = new AnnotationConfiguration(); 
    4749                conf.configure(new File(Configuration.getSetting("configdir")+"hibernate.xml")); 
     50                conf.addSqlFunction("pow", new StandardSQLFunction("pow", Hibernate.DOUBLE)); 
     51                conf.addSqlFunction("floor", new StandardSQLFunction("floor", Hibernate.LONG)); 
    4852                 
    4953                try { 
  • src/net/driftingsouls/ds2/server/modules/DeutAllController.java

    r283e6c7 r5fa2480  
    8585                        if( (lastcoords == null) || !lastcoords.sameSector(0, Location.fromResult(ship), 0) ) { 
    8686                                t.set_var(      "ship.newcoords",               1, 
    87                                                         "ship.location",                Ships.getLocationText(ship, false), 
     87                                                        "ship.location",                Ships.getLocationText(Location.fromResult(ship), false), 
    8888                                                        "ship.newcoords.break", lastcoords != null ); 
    8989 
  • src/net/driftingsouls/ds2/server/modules/SchiffController.java

    r23d6d8b r5fa2480  
    2323import java.util.ArrayList; 
    2424import java.util.HashMap; 
     25import java.util.Iterator; 
    2526import java.util.LinkedHashMap; 
    2627import java.util.List; 
     
    2829 
    2930import net.driftingsouls.ds2.server.ContextCommon; 
    30 import net.driftingsouls.ds2.server.Location; 
    3131import net.driftingsouls.ds2.server.Offizier; 
    3232import net.driftingsouls.ds2.server.cargo.Cargo; 
     
    5555import net.driftingsouls.ds2.server.ships.Ship; 
    5656import net.driftingsouls.ds2.server.ships.ShipClasses; 
     57import net.driftingsouls.ds2.server.ships.ShipFleet; 
    5758import net.driftingsouls.ds2.server.ships.ShipTypeData; 
    5859import net.driftingsouls.ds2.server.ships.ShipTypes; 
     
    7071 */ 
    7172public class SchiffController extends DSGenerator implements Loggable { 
    72         private SQLResultRow ship = null; 
     73        private Ship ship = null; 
    7374        private ShipTypeData shiptype = null; 
    7475        private Offizier offizier = null; 
     
    122123                User user = (User)getUser(); 
    123124                TemplateEngine t = getTemplateEngine(); 
    124                 Database db = getDatabase(); 
     125                org.hibernate.Session db = getDB(); 
    125126                 
    126127                t.set_var( "user.tooltips", user.getUserValue("TBLORDER/schiff/tooltips") ); 
     
    128129                int shipid = getInteger("ship"); 
    129130                 
    130                 ship = db.first("SELECT * FROM ships WHERE id>0 AND owner='",user.getID(),"' AND id=",shipid); 
    131                 if( ship.isEmpty() ) { 
     131                ship = (Ship)db.get(Ship.class, shipid); 
     132                if( (ship == null) || (ship.getId() < 0) || (ship.getOwner() != user) ) { 
    132133                        addError("Das angegebene Schiff existiert nicht", Common.buildUrl(getContext(),"default", "module", "schiffe") ); 
    133134                        return false; 
    134135                } 
    135136 
    136                 if( ship.getInt("battle") > 0 ) { 
    137                         addError("Das Schiff ist in einen Kampf verwickelt (hier klicken um zu diesem zu gelangen)!", Common.buildUrl(getContext(), "default", "module", "angriff", "battle", ship.getInt("battle"), "ship", shipid) ); 
     137                if( ship.getBattle() > 0 ) { 
     138                        addError("Das Schiff ist in einen Kampf verwickelt (hier klicken um zu diesem zu gelangen)!", Common.buildUrl(getContext(), "default", "module", "angriff", "battle", ship.getBattle(), "ship", shipid) ); 
    138139                        return false; 
    139140                } 
    140141 
    141142 
    142                 shiptype = Ship.getShipType(ship); 
    143  
    144                 offizier = Offizier.getOffizierByDest('s', ship.getInt("id")); 
    145                  
    146                 if( !action.equals("communicate") && !action.equals("onmove") && !action.equals("onenter") && !ship.getString("lock").equals("") ) { 
     143                shiptype = ship.getTypeData(); 
     144 
     145                offizier = Offizier.getOffizierByDest('s', ship.getId()); 
     146                 
     147                if( !action.equals("communicate") && !action.equals("onmove") && !action.equals("onenter") && (ship.getLock() != null) && !ship.getLock().equals("") ) { 
    147148                        ScriptParser scriptparser = getContext().get(ContextCommon.class).getScriptParser( ScriptParser.NameSpace.QUEST ); 
    148149                        scriptparser.setShip(ship); 
     
    151152                        } 
    152153                         
    153                         Quests.executeLock(scriptparser, ship.getString("lock"), user); 
     154                        Quests.executeLock(scriptparser, ship.getLock(), user); 
    154155                } 
    155156                 
     
    205206                 
    206207                if( (alarm >= 0) && (alarm <= 1) ) {  
    207                         db.update("UPDATE ships SET alarm=",alarm," WHERE id>0 AND id=",ship.getInt("id")); 
     208                        db.update("UPDATE ships SET alarm=",alarm," WHERE id>0 AND id=",ship.getId()); 
    208209                         
    209210                        getTemplateEngine().set_var("ship.message", "Alarmstufe erfolgreich ge&auml;ndert<br />"); 
    210211                } 
    211212                 
    212                 Ships.recalculateShipStatus(ship.getInt("id")); 
     213                Ships.recalculateShipStatus(ship.getId()); 
    213214                 
    214215                redirect(); 
     
    222223         */ 
    223224        public void consignAction() { 
    224                 Database db = getDatabase(); 
     225                org.hibernate.Session db = getDB(); 
    225226                TemplateEngine t = getTemplateEngine(); 
    226227                User user = (User)getUser(); 
     
    229230                int newownerID = getInteger("newowner"); 
    230231                 
    231                 User newowner = (User)getDB().get(User.class, newownerID); 
     232                User newowner = (User)db.get(User.class, newownerID); 
    232233                 
    233234                parameterNumber("conf"); 
     
    235236                 
    236237                if( conf == 0 ) { 
    237                         String text = "<span style=\"color:white\">Wollen sie das Schiff "+Common._plaintitle(ship.getString("name"))+" ("+ship.getInt("id")+") wirklich an "+newowner.getProfileLink()+" &uuml;bergeben?</span><br />"; 
    238                         text += "<a class=\"ok\" href=\""+Common.buildUrl(getContext(), "consign", "ship", ship.getInt("id"), "conf" , 1, "newowner" , newowner.getID())+"\">&Uuml;bergeben</a></span><br />"; 
     238                        String text = "<span style=\"color:white\">Wollen sie das Schiff "+Common._plaintitle(ship.getName())+" ("+ship.getId()+") wirklich an "+newowner.getProfileLink()+" &uuml;bergeben?</span><br />"; 
     239                        text += "<a class=\"ok\" href=\""+Common.buildUrl(getContext(), "consign", "ship", ship.getId(), "conf" , 1, "newowner" , newowner.getID())+"\">&Uuml;bergeben</a></span><br />"; 
    239240                        t.set_var( "ship.message", text ); 
    240241                         
     
    243244                } 
    244245                 
    245                 int fleet = ship.getInt("fleet"); 
    246                  
    247                 boolean result = Ships.consign(user, ship, newowner, false ); 
     246                ShipFleet fleet = ship.getFleet(); 
     247                 
     248                boolean result = ship.consign(newowner, false); 
    248249                         
    249250                if( result ) { 
     
    253254                } 
    254255                else { 
    255                         String msg = "Ich habe dir die "+ship.getString("name")+" ("+ship.getInt("id")+"), ein Schiff der "+shiptype.getNickname()+"-Klasse, &uuml;bergeben\nSie steht bei "+ship.getInt("system")+":"+ship.getInt("x")+"/"+ship.getInt("y"); 
     256                        String msg = "Ich habe dir die "+ship.getName()+" ("+ship.getId()+"), ein Schiff der "+shiptype.getNickname()+"-Klasse, &uuml;bergeben\nSie steht bei "+ship.getSystem()+":"+ship.getX()+"/"+ship.getY(); 
    256257                        PM.send(getContext(), user.getID(), newowner.getID(), "Schiff &uuml;bergeben", msg); 
    257258                 
     
    259260                        t.set_var("ship.message", (!consMessage.equals("") ? consMessage+"<br />" : "")+"<span style=\"color:green\">Das Schiff wurde erfolgreich an "+newowner.getProfileLink()+" &uuml;bergeben</span><br />"); 
    260261                         
    261                         if( fleet != 0 ) { 
    262                                 int fleetcount = db.first("SELECT count(*) count FROM ships WHERE id>0 AND fleet="+fleet).getInt("count"); 
     262                        if( fleet != null ) { 
     263                                int fleetcount = (Integer)db.createQuery("select count(*) from Ship where id>0 and fleet=?") 
     264                                        .setEntity(0, fleet) 
     265                                        .iterate().next(); 
    263266                         
    264267                                if( fleetcount < 3 ) { 
    265                                         db.update("UPDATE ships SET fleet=null WHERE id>0 AND fleet="+fleet); 
    266                                         db.update("DELETE FROM ship_fleets WHERE id>0 AND id="+fleet); 
     268                                        db.createQuery("update Ship set fleet=null where id>0 and fleet=?") 
     269                                                .setEntity(0, fleet) 
     270                                                .executeUpdate(); 
     271                                         
     272                                        db.delete(fleet); 
    267273                                } 
    268274                        }        
     
    279285                TemplateEngine t = getTemplateEngine(); 
    280286 
    281                 if( !ship.getString("lock").equals("") ) { 
     287                if( (ship.getLock() != null) && (ship.getLock().length() > 0) ) { 
    282288                        t.set_var("ship.message", "<span style=\"color:red\">Dieses Schiff kann sich nicht selbstzerst&ouml;ren, da es in ein Quest eingebunden ist</span><br />"); 
    283289                        redirect(); 
     
    289295         
    290296                if( conf == 0 ) { 
    291                         String text = "<span style=\"color:white\">Wollen sie Selbstzerst&ouml;rung des Schiffes "+Common._plaintitle(ship.getString("name"))+" ("+ship.getInt("id")+") wirklich ausf&uuml;hren?</span><br />\n"; 
    292                         text += "<a class=\"error\" href=\""+Common.buildUrl(getContext(), "destroy", "ship", ship.getInt("id"), "conf", 1)+"\">Selbstzerst&ouml;rung</a></span><br />"; 
     297                        String text = "<span style=\"color:white\">Wollen sie Selbstzerst&ouml;rung des Schiffes "+Common._plaintitle(ship.getName())+" ("+ship.getId()+") wirklich ausf&uuml;hren?</span><br />\n"; 
     298                        text += "<a class=\"error\" href=\""+Common.buildUrl(getContext(), "destroy", "ship", ship.getId(), "conf", 1)+"\">Selbstzerst&ouml;rung</a></span><br />"; 
    293299                        t.set_var("ship.message", text); 
    294300                         
     
    297303                } 
    298304         
    299                 Ships.destroy( ship.getInt("id") ); 
     305                Ships.destroy( ship.getId() ); 
    300306 
    301307                t.set_var("ship.message", "<span style=\"color:white\">Das Schiff hat sich selbstzerst&ouml;rt</span><br />"); 
     
    311317                TemplateEngine t = getTemplateEngine(); 
    312318                 
    313                 if( (shiptype.getCost() == 0) || (ship.getInt("engine") == 0) ) { 
     319                if( (shiptype.getCost() == 0) || (ship.getEngine() == 0) ) { 
    314320                        redirect(); 
    315321                        return; 
     
    320326                 
    321327                if( node != 0 ) { 
    322                         Ships.jump(ship.getInt("id"), node, false); 
     328                        Ships.jump(ship.getId(), node, false); 
    323329                        t.set_var("ship.message", Ships.MESSAGE.getMessage()); 
    324330                } 
     
    335341                TemplateEngine t = getTemplateEngine(); 
    336342                 
    337                 if( (shiptype.getCost() == 0) || (ship.getInt("engine") == 0) ) { 
     343                if( (shiptype.getCost() == 0) || (ship.getEngine() == 0) ) { 
    338344                        redirect(); 
    339345                        return; 
     
    344350                 
    345351                if( knode != 0 ) { 
    346                         Ships.jump(ship.getInt("id"), knode, true); 
     352                        Ships.jump(ship.getId(), knode, true); 
    347353                        t.set_var("ship.message", Ships.MESSAGE.getMessage()); 
    348354                } 
     
    357363         */ 
    358364        public void renameAction() { 
    359                 Database db = getDatabase(); 
    360365                TemplateEngine t = getTemplateEngine(); 
    361366                 
     
    363368                String newname = getString("newname"); 
    364369                 
    365                 db.prepare("UPDATE ships SET name= ? WHERE id= ?").update(newname, ship.getInt("id")); 
     370                ship.setName(newname); 
    366371                t.set_var("ship.message", "Name zu "+Common._plaintitle(newname)+" ge&auml;ndert<br />"); 
    367                 ship.put("name", newname); 
    368372         
    369373                redirect(); 
     
    421425                int[] shiplist = Common.explodeToInt("|",shipIdList); 
    422426                 
    423                 Ships.dock(Ships.DockMode.LAND, user.getID(), ship.getInt("id"), shiplist); 
     427                Ships.dock(Ships.DockMode.LAND, user.getID(), ship.getId(), shiplist); 
    424428                t.set_var("ship.message", Ships.MESSAGE.getMessage()); 
    425429 
     
    446450                int[] shiplist = Common.explodeToInt("|",shipIdList); 
    447451                 
    448                 Ships.dock(Ships.DockMode.START, user.getID(), ship.getInt("id"), shiplist); 
     452                Ships.dock(Ships.DockMode.START, user.getID(), ship.getId(), shiplist); 
    449453                t.set_var("ship.message", Ships.MESSAGE.getMessage()); 
    450454 
     
    487491                } 
    488492                 
    489                 Ships.dock(Ships.DockMode.DOCK, user.getID(), ship.getInt("id"), shiplist); 
     493                Ships.dock(Ships.DockMode.DOCK, user.getID(), ship.getId(), shiplist); 
    490494                t.set_var("ship.message", Ships.MESSAGE.getMessage()); 
    491495 
     
    512516                int[] shiplist = Common.explodeToInt("|",shipIdList); 
    513517                 
    514                 Ships.dock(Ships.DockMode.UNDOCK, user.getID(), ship.getInt("id"), shiplist); 
     518                Ships.dock(Ships.DockMode.UNDOCK, user.getID(), ship.getId(), shiplist); 
    515519                t.set_var("ship.message", Ships.MESSAGE.getMessage()); 
    516520 
     
    524528         */ 
    525529        public void joinAction() { 
    526                 Database db = getDatabase(); 
     530                org.hibernate.Session db = getDB(); 
    527531                TemplateEngine t = getTemplateEngine(); 
    528532                User user = (User)getUser(); 
     
    531535                int join = getInteger("join"); 
    532536                 
    533                 SQLResultRow fleetship = db.first("SELECT name,x,y,system,owner,fleet,`lock` FROM ships WHERE id>0 AND id=",join); 
     537                Ship fleetship = (Ship)db.get(Ship.class, join); 
     538                if( (fleetship == null) || (fleetship.getId() < 0) ) { 
     539                        redirect(); 
     540                        return; 
     541                } 
    534542 
    535543                // Austreten 
    536                 if( (join == 0) && ship.getString("lock").equals("") ) { 
    537                         Ships.removeFromFleet(ship); 
    538                         ship.put("fleet", 0); 
     544                if( (join == 0) && (ship.getLock() == null) && (ship.getLock().length() == 0) ) { 
     545                        ship.removeFromFleet(); 
    539546                         
    540547                        t.set_var("ship.message", "<span style=\"color:green\">"+Ships.MESSAGE.getMessage()+"</span><br />"); 
     
    545552                // Beitreten 
    546553                else { 
    547                         SQLResultRow fleet = db.first("SELECT id,name FROM ship_fleets WHERE id='",fleetship.getInt("fleet"),"'"); 
    548                  
    549                         if( !fleetship.getString("lock").equals("") || !ship.getString("lock").equals("") ) { 
     554                        ShipFleet fleet = fleetship.getFleet(); 
     555                         
     556                        if( fleet == null ) { 
     557                                t.set_var("ship.message", "<span style=\"color:red\">Sie m&uuml;ssen erst eine Flotte erstellen</span><br />"); 
     558                                redirect(); 
     559                                return; 
     560                        } 
     561                 
     562                        if( ((fleetship.getLock() != null) && (fleetship.getLock().length() > 0)) || ((ship.getLock() != null) && (ship.getLock().length() > 0)) ) { 
    550563                                t.set_var("ship.message", "<span style=\"color:red\">Sie k&oumlnnen der Flotte nicht beitreten, solange entweder das Schiff oder die Flotte in ein Quest eingebunden ist</span><br />"); 
    551564                                redirect(); 
     
    554567                        } 
    555568                         
    556                         if( !Location.fromResult(ship).sameSector(0, Location.fromResult(fleetship), 0) || ( fleetship.getInt("owner") != user.getID() ) || (fleet.getInt("id") != fleetship.getInt("fleet")) ) { 
    557                                 t.set_var("ship.message", "<span style=\"color:red\">Beitritt zur Flotte &quot;"+Common._plaintitle(fleet.getString("name"))+"&quot; nicht m&ouml;glich</span><br />"); 
     569                        if( !ship.getLocation().sameSector(0, fleetship.getLocation(), 0) || ( fleetship.getOwner() != user ) ) { 
     570                                t.set_var("ship.message", "<span style=\"color:red\">Beitritt zur Flotte &quot;"+Common._plaintitle(fleet.getName())+"&quot; nicht m&ouml;glich</span><br />"); 
    558571                        } 
    559572                        else { 
    560                                 if( fleetship.getInt("fleet") == 0 ) { 
    561                                         t.set_var("ship.message", "<span style=\"color:red\">Sie m&uuml;ssen erst eine Flotte erstellen</span><br />"); 
    562                                         redirect(); 
    563                                         return; 
    564                                 } 
    565                          
    566                                 db.update("UPDATE ships SET fleet=",fleetship.getInt("fleet")," WHERE id>0 AND id=",ship.getInt("id")); 
    567                                 t.set_var("ship.message", "<span style=\"color:green\">Flotte &quot;"+Common._plaintitle(fleet.getString("name"))+"&quot; beigetreten</span><br />"); 
     573                                ship.setFleet(fleet); 
     574                                t.set_var("ship.message", "<span style=\"color:green\">Flotte &quot;"+Common._plaintitle(fleet.getName())+"&quot; beigetreten</span><br />"); 
    568575                        } 
    569576                } 
     
    578585         */ 
    579586        public void shupAction() { 
    580                 Database db = getDatabase(); 
    581587                TemplateEngine t = getTemplateEngine(); 
    582588                 
     
    589595                } 
    590596 
    591                 if( shup > (shiptype.getShields() - ship.getInt("shields"))/shieldfactor ) { 
    592                         shup = (shiptype.getShields() - ship.getInt("shields"))/shieldfactor; 
    593                 } 
    594                 if( shup > ship.getInt("e") ) { 
    595                         shup = ship.getInt("e"); 
     597                if( shup > (shiptype.getShields() - ship.getShields())/shieldfactor ) { 
     598                        shup = (shiptype.getShields() - ship.getShields())/shieldfactor; 
     599                } 
     600                if( shup > ship.getEnergy() ) { 
     601                        shup = ship.getEnergy(); 
    596602                } 
    597603 
    598604                t.set_var("ship.message", "Schilde +"+(shup*shieldfactor)+"<br />"); 
    599605                 
    600                 int oldshields = ship.getInt("shields"); 
    601                 ship.put("shields", ship.getInt("shields") + shup*shieldfactor); 
    602                 if( ship.getInt("shields") > shiptype.getShields() ) { 
    603                         ship.put("shields", shiptype.getShields()); 
    604                 } 
    605          
    606                 int olde = ship.getInt("e"); 
    607                 ship.put("e", ship.getInt("e") - shup); 
    608  
    609                 db.update("UPDATE ships SET e=",ship.getInt("e"),",shields=",ship.getInt("shields")," WHERE id=",ship.getInt("id")," AND e='",olde,"' AND shields='",oldshields,"'"); 
    610          
    611                 Ships.recalculateShipStatus(ship.getInt("id")); 
     606                ship.setShields(ship.getShields() + shup*shieldfactor); 
     607                if( ship.getShields() > shiptype.getShields() ) { 
     608                        ship.setShields(shiptype.getShields()); 
     609                } 
     610         
     611                ship.setEnergy(ship.getEnergy() - shup); 
     612 
     613                Ships.recalculateShipStatus(ship.getId()); 
    612614         
    613615                redirect(); 
     
    637639                        } 
    638640         
    639                         db.prepare("UPDATE ships SET script= ? ",resetsql," WHERE id>0 AND id= ? ").update(script, ship.getInt("id")); 
     641                        db.prepare("UPDATE ships SET script= ? ",resetsql," WHERE id>0 AND id= ? ").update(script, ship.getId()); 
    640642                } 
    641643                else { 
    642                         db.update("UPDATE ships SET script=NULL,scriptexedata=NULL WHERE id>0 AND id='",ship.getInt("id"),"'");                
     644                        db.update("UPDATE ships SET script=NULL,scriptexedata=NULL WHERE id>0 AND id='",ship.getId(),"'");             
    643645                } 
    644646                 
     
    655657         */ 
    656658        public void communicateAction() { 
    657                 Database db = getDatabase(); 
     659                org.hibernate.Session db = getDB(); 
    658660                TemplateEngine t = getTemplateEngine(); 
    659661                User user = (User)getUser(); 
     
    662664                int communicate = getInteger("communicate"); 
    663665                 
    664                 String[] lock = StringUtils.split(ship.getString("lock"), ':'); 
    665  
    666                 if( (lock.length > 2) && !lock[2].equals(Quests.EVENT_ONCOMMUNICATE) ) { 
     666                String[] lock = StringUtils.split(ship.getLock(), ':'); 
     667 
     668                if( (lock == null) || ((lock.length > 2) && !lock[2].equals(Quests.EVENT_ONCOMMUNICATE)) ) { 
    667669                        redirect(); 
    668670                         
     
    690692                } 
    691693         
    692                 SQLResultRow targetship = db.first("SELECT x,y,system,oncommunicate FROM ships WHERE id>0 AND id='",communicate,"'"); 
    693                 if( !Location.fromResult(targetship).sameSector(0, Location.fromResult(ship), 0) ) { 
     694                Ship targetship = (Ship)db.get(Ship.class, communicate); 
     695                if( (targetship.getId() < 0) || !targetship.getLocation().sameSector(0, ship.getLocation(), 0) ) { 
    694696                        t.set_var("ship.message", "<span style=\"color:red\">Sie k&ouml;nnen nur mit Schiffen im selben Sektor kommunizieren</span><br />"); 
    695697                        redirect(); 
    696698                        return; 
    697699                } 
    698                 Quests.executeEvent( scriptparser, targetship.getString("oncommunicate"), user.getID(), execparameter ); 
     700                Quests.executeEvent( scriptparser, targetship.getOnCommunicate(), user.getID(), execparameter ); 
    699701                 
    700702                redirect(); 
     
    710712                User user = (User)getUser(); 
    711713                 
    712                 String[] lock = StringUtils.split(ship.getString("lock"), ':'); 
    713                  
    714                 if( (lock.length > 2) && !lock[2].equals(Quests.EVENT_ONMOVE) ) { 
     714                String[] lock = StringUtils.split(ship.getLock(), ':'); 
     715                 
     716                if( (lock == null) || ((lock.length > 2) && !lock[2].equals(Quests.EVENT_ONMOVE)) ) { 
    715717                        redirect(); 
    716718                         
     
    736738                } 
    737739         
    738                 if( ship.getString("onmove").equals("") ) { 
     740                if( (ship.getOnMove() == null) || ship.getOnMove().equals("") ) { 
    739741                        t.set_var("ship.message", "<span style=\"color:red\">Das angegebene Schiff verf&uuml;gt nicht &uuml;ber dieses Ereigniss</span><br />"); 
    740742                        redirect(); 
     
    742744                } 
    743745 
    744                 Quests.executeEvent( scriptparser, ship.getString("onmove"), user.getID(), execparameter ); 
     746                Quests.executeEvent( scriptparser, ship.getOnMove(), user.getID(), execparameter ); 
    745747         
    746748                redirect(); 
     
    753755         */ 
    754756        public void onenterAction() { 
    755                 Database db = getDatabase(); 
    756757                TemplateEngine t = getTemplateEngine(); 
    757758                User user = (User)getUser(); 
    758759                 
    759                 String[] lock = StringUtils.split(ship.getString("lock"), ':'); 
    760                  
    761                 if( (lock.length > 2) && !lock[2].equals(Quests.EVENT_ONENTER) ) { 
     760                String[] lock = StringUtils.split(ship.getLock(), ':'); 
     761                 
     762                if( (lock == null) || ((lock.length > 2) && !lock[2].equals(Quests.EVENT_ONENTER)) ) { 
    762763                        redirect(); 
    763764                         
     
    784785         
    785786                if( !usescript.equals("-1") ) { 
     787                        Database database = getDatabase(); 
     788                         
    786789                        parameterString("execparameter"); 
    787790                        String execparameter = getString( "execparameter" ); 
     
    792795                        Quests.currentEventURL.set("&action=onenter"); 
    793796                         
    794                         SQLQuery runningdata = db.query("SELECT id,execdata FROM quests_running WHERE id='",rquestid,"'"); 
     797                        SQLQuery runningdata = database.query("SELECT id,execdata FROM quests_running WHERE id='",rquestid,"'"); 
    795798                        Blob execdata = null; 
    796799                 
     
    805808                                } 
    806809                                catch( Exception e ) { 
    807                                         LOG.warn("Setting Script-ExecData failed (Ship: "+ship.getInt("id")+": ",e); 
     810                                        LOG.warn("Setting Script-ExecData failed (Ship: "+ship.getId()+": ",e); 
    808811                                        return; 
    809812                                } 
     
    816819                        } 
    817820                 
    818                         String script = db.first("SELECT script FROM scripts WHERE id='",usescript,"'").getString("script"); 
     821                        String script = database.first("SELECT script FROM scripts WHERE id='",usescript,"'").getString("script"); 
    819822                        scriptparser.setRegister("USER", Integer.toString(user.getID())); 
    820823                        if( !usequest.equals("") ) { 
     
    822825                        } 
    823826                        scriptparser.setRegister("SCRIPT", usescript); 
    824                         scriptparser.setRegister("SECTOR", Location.fromResult(ship).toString()); 
     827                        scriptparser.setRegister("SECTOR", ship.getLocation().toString()); 
    825828                        if( (lock.length > 2) ) {                
    826829                                scriptparser.setRegister("LOCKEXEC", "1"); 
    827830                        } 
    828831 
    829                         scriptparser.executeScript(db, script, execparameter); 
     832                        scriptparser.executeScript(database, script, execparameter); 
    830833                 
    831834                        usequest = scriptparser.getRegister("QUEST"); 
     
    834837                                try { 
    835838                                        scriptparser.getContext().toStream(execdata.setBinaryStream(1)); 
    836                                         db.prepare("UPDATE quests_running SET execdata=? WHERE id=? ") 
     839                                        database.prepare("UPDATE quests_running SET execdata=? WHERE id=? ") 
    837840                                                .update(execdata, runningdata.getInt("id")); 
    838841                                } 
    839842                                catch( Exception e ) { 
    840                                         LOG.warn("Writing back Script-ExecData failed (Ship: "+ship.getInt("id")+": ",e); 
     843                                        LOG.warn("Writing back Script-ExecData failed (Ship: "+ship.getId()+": ",e); 
    841844                                        return; 
    842845                                } 
     
    991994                } 
    992995                 
    993                 int negdata = db.first("SELECT id FROM ships WHERE id='",(-ship.getInt("id")),"'").getInt("id"); 
     996                int negdata = db.first("SELECT id FROM ships WHERE id='",(-ship.getId()),"'").getInt("id"); 
    994997                if( negdata < 0 ) { 
    995                         deleteRespawnEntry(ship.getInt("id")); 
    996                          
    997                         SQLQuery sid = db.query("SELECT id FROM ships WHERE id>0 AND docked IN ('",ship.getInt("id"),"','l ",ship.getInt("id"),"')"); 
     998                        deleteRespawnEntry(ship.getId()); 
     999                         
     1000                        SQLQuery sid = db.query("SELECT id FROM ships WHERE id>0 AND docked IN ('",ship.getId(),"','l ",ship.getId(),"')"); 
    9981001                        while( sid.next() ) { 
    9991002                                deleteRespawnEntry(sid.getInt("id")); 
     
    10071010                        int respawntime = getInteger("respawntime"); 
    10081011                         
    1009                         createRespawnEntry(ship.getInt("id"), respawntime); 
    1010                          
    1011                         SQLQuery sid = db.query("SELECT id FROM ships WHERE id>0 AND docked IN ('",ship.getInt("id"),"','l ",ship.getInt("id"),"')"); 
     1012                        createRespawnEntry(ship.getId(), respawntime); 
     1013                         
     1014                        SQLQuery sid = db.query("SELECT id FROM ships WHERE id>0 AND docked IN ('",ship.getId(),"','l ",ship.getId(),"')"); 
    10121015                        while( sid.next() ) { 
    10131016                                createRespawnEntry(sid.getInt("id"),respawntime); 
     
    10261029         */ 
    10271030        public void inselAction() { 
    1028                 Database db = getDatabase(); 
    10291031                TemplateEngine t = getTemplateEngine(); 
    10301032                User user = (User)getUser();  
     
    10351037                } 
    10361038                 
    1037                 db.update("UPDATE ships SET x='10',y='10',system='99' WHERE id='",ship.getInt("id"),"'"); 
     1039                ship.setX(10); 
     1040                ship.setY(10); 
     1041                ship.setSystem(99); 
     1042                 
    10381043                t.set_var("ship.message", "<span style=\"color:green\">Willkommen auf der Insel <img align=\"middle\" src=\""+Configuration.getSetting("SMILIE_PATH")+"/icon_smile.gif\" alt=\":)\" /></span><br />"); 
    10391044                 
     
    10751080                User user = (User)getUser(); 
    10761081                TemplateEngine t = getTemplateEngine(); 
    1077                 Database db = getDatabase(); 
    1078  
    1079                 ship = db.first("SELECT * FROM ships WHERE id>0 AND owner='",user.getID(),"' AND id=",ship.getInt("id")); 
    1080                 if( ship.isEmpty() ) { 
    1081                         addError("Das Schiff existiert nicht mehr oder geh&ouml;rt nicht mehr ihnen"); 
    1082                         return; 
    1083                 } 
    1084                  
    1085                 shiptype = Ship.getShipType(ship); 
    1086                  
     1082                org.hibernate.Session db = getDB(); 
     1083 
     1084                db.flush(); 
     1085                db.refresh(ship); 
     1086                         
    10871087                ScriptParser scriptparser = getContext().get(ContextCommon.class).getScriptParser( ScriptParser.NameSpace.QUEST ); 
    1088                 if( ship.isEmpty() ) { 
     1088                if( ship == null ) { 
    10891089                        if( (scriptparser != null) && (scriptparser.getContext().getOutput().length() != 0) ) { 
    10901090                                t.set_var("ship.scriptparseroutput", 
    10911091                                                scriptparser.getContext().getOutput().replace("{{var.sessid}}", getString("sess")) ); 
    10921092                        } 
    1093                                  
     1093                        else { 
     1094                                addError("Das Schiff existiert nicht mehr oder geh&ouml;rt nicht mehr ihnen"); 
     1095                        } 
    10941096                        return; 
    10951097                } 
    10961098 
    1097                 if( ship.getInt("battle") > 0 ) { 
     1099                shiptype = ship.getTypeData(); 
     1100                 
     1101                if( ship.getBattle() > 0 ) { 
    10981102                        if( (scriptparser != null) && (scriptparser.getContext().getOutput().length() > 0) ) { 
    10991103                                t.set_var("ship.scriptparseroutput", 
     
    11011105                        } 
    11021106                 
    1103                         addError("Das Schiff ist in einen Kampf verwickelt (hier klicken um zu diesem zu gelangen)!", Common.buildUrl(getContext(), "default", "module", "angriff", "battle", ship.getString("battle"), "ship", ship.getInt("id")) ); 
     1107                        addError("Das Schiff ist in einen Kampf verwickelt (hier klicken um zu diesem zu gelangen)!", Common.buildUrl(getContext(), "default", "module", "angriff", "battle", ship.getBattle(), "ship", ship.getId()) ); 
    11041108                        return; 
    11051109                } 
    11061110                 
    1107                 offizier = Offizier.getOffizierByDest('s', ship.getInt("id")); 
     1111                offizier = Offizier.getOffizierByDest('s', ship.getId()); 
    11081112                 
    11091113                StringBuilder tooltiptext = new StringBuilder(100); 
    11101114                tooltiptext.append(Common.tableBegin(340, "center").replace('"', '\'') ); 
    1111                 tooltiptext.append("<iframe src='"+Common.buildUrl(getContext(), "default", "module", "impobjects", "system", ship.getInt("system"))+"' name='sector' width='320' height='300' scrolling='auto' marginheight='0' marginwidth='0' frameborder='0'>Ihr Browser unterst&uuml;tzt keine iframes</iframe>"); 
     1115                tooltiptext.append("<iframe src='"+Common.buildUrl(getContext(), "default", "module", "impobjects", "system", ship.getSystem())+"' name='sector' width='320' height='300' scrolling='auto' marginheight='0' marginwidth='0' frameborder='0'>Ihr Browser unterst&uuml;tzt keine iframes</iframe>"); 
    11121116                tooltiptext.append(Common.tableEnd().replace('"', '\'') ); 
    11131117                String tooltiptextStr = StringEscapeUtils.escapeJavaScript(tooltiptext.toString().replace(">", "&gt;").replace("<", "&lt;")); 
    11141118 
    11151119                t.set_var(      "ship.showui",                  1, 
    1116                                         "ship.id",                              ship.getInt("id"), 
    1117                                         "ship.name",                    Common._plaintitle(ship.getString("name")), 
    1118                                         "ship.location",                Ships.getLocationText(ship, false), 
    1119                                         "ship.type",                    ship.getInt("type"), 
     1120                                        "ship.id",                              ship.getId(), 
     1121                                        "ship.name",                    Common._plaintitle(ship.getName()), 
     1122                                        "ship.location",                Ships.getLocationText(ship.getLocation(), false), 
     1123                                        "ship.type",                    ship.getType(), 
    11201124                                        "shiptype.picture",             shiptype.getPicture(), 
    11211125                                        "shiptype.name",                shiptype.getNickname(), 
    1122                                         "ship.hull.color",              genSubColor(ship.getInt("hull"), shiptype.getHull()), 
    1123                                         "ship.hull",                    Common.ln(ship.getInt("hull")), 
     1126                                        "ship.hull.color",              genSubColor(ship.getHull(), shiptype.getHull()), 
     1127                                        "ship.hull",                    Common.ln(ship.getHull()), 
    11241128                                        "shiptype.hull",                Common.ln(shiptype.getHull())