Changeset 23d6d8b37036e4077d22eab2901a279414fcc775

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

[b7af64d1c4640f42e27a57c4504c94aae4b8c9fb]

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

Foreign Key Ships.fleet -> ship_fleets.id eingebaut

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • db/tables/ships.sql

    r37644ad r23d6d8b  
    2121  `docked` varchar(20) NOT NULL default '', 
    2222  `alarm` int(11) NOT NULL default '0', 
    23   `fleet` int(11) NOT NULL default '0'
     23  `fleet` int(11) default NULL
    2424  `destsystem` int(11) NOT NULL default '0', 
    2525  `destx` int(11) NOT NULL default '0', 
     
    5151ALTER TABLE ships ADD CONSTRAINT ships_fk_users FOREIGN KEY (owner) REFERENCES users(id); 
    5252ALTER TABLE ships ADD CONSTRAINT ships_type_fk FOREIGN KEY (type) REFERENCES ship_types(id); 
     53ALTER TABLE ships ADD CONSTRAINT ships_fk_ship_fleets FOREIGN KEY (fleet) REFERENCES ship_fleets(id); 
    5354 
    54 INSERT INTO `ships` (`id`, `owner`, `name`, `type`, `cargo`, `x`, `y`, `system`, `status`, `crew`, `e`, `s`, `hull`, `shields`, `heat`, `engine`, `weapons`, `comm`, `sensors`, `docked`, `alarm`, `fleet`, `destsystem`, `destx`, `desty`, `destcom`, `bookmark`, `battle`, `battleAction`, `jumptarget`, `autodeut`, `history`, `script`, `scriptexedata`, `oncommunicate`, `lock`, `visibility`, `onmove`, `respawn`) VALUES (2, -1, 'Frachter', 27, '0,0,0,0,50,0,0,0,0,0,0,0,0,0,0,0,0,0,', 1, 1, 0, 'noconsign', 50, 80, 0, 5000, 0, '', 100, 100, 100, 100, '', 0, 0, 0, 0, 0, '', 0, 0, 0, '', 1, '', NULL, NULL, NULL, NULL, NULL, NULL, NULL); 
    55 INSERT INTO `ships` (`id`, `owner`, `name`, `type`, `cargo`, `x`, `y`, `system`, `status`, `crew`, `e`, `s`, `hull`, `shields`, `heat`, `engine`, `weapons`, `comm`, `sensors`, `docked`, `alarm`, `fleet`, `destsystem`, `destx`, `desty`, `destcom`, `bookmark`, `battle`, `battleAction`, `jumptarget`, `autodeut`, `history`, `script`, `scriptexedata`, `oncommunicate`, `lock`, `visibility`, `onmove`, `respawn`) VALUES (3, -1, 'Tanker', 2, '0,300,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,', 1, 2, 0, 'noconsign', 30, 40, 0, 10000, 0, '', 100, 100, 100, 100, '', 0, 0, 0, 0, 0, '', 0, 0, 0, '', 1, '', NULL, NULL, NULL, NULL, NULL, NULL, NULL); 
    56 INSERT INTO `ships` (`id`, `owner`, `name`, `type`, `cargo`, `x`, `y`, `system`, `status`, `crew`, `e`, `s`, `hull`, `shields`, `heat`, `engine`, `weapons`, `comm`, `sensors`, `docked`, `alarm`, `fleet`, `destsystem`, `destx`, `desty`, `destcom`, `bookmark`, `battle`, `battleAction`, `jumptarget`, `autodeut`, `history`, `script`, `scriptexedata`, `oncommunicate`, `lock`, `visibility`, `onmove`, `respawn`) VALUES (5, -1, 'Frachter', 31, '0,60,0,0,50,0,0,0,0,0,0,0,0,0,0,0,0,0,', 2, 1, 0, 'noconsign', 30, 80, 0, 8500, 0, '', 100, 100, 100, 100, '', 0, 0, 0, 0, 0, '', 0, 0, 0, '', 1, '', NULL, NULL, NULL, NULL, NULL, NULL, NULL); 
    57 INSERT INTO `ships` (`id`, `owner`, `name`, `type`, `cargo`, `x`, `y`, `system`, `status`, `crew`, `e`, `s`, `hull`, `shields`, `heat`, `engine`, `weapons`, `comm`, `sensors`, `docked`, `alarm`, `fleet`, `destsystem`, `destx`, `desty`, `destcom`, `bookmark`, `battle`, `battleAction`, `jumptarget`, `autodeut`, `history`, `script`, `scriptexedata`, `oncommunicate`, `lock`, `visibility`, `onmove`, `respawn`) VALUES (6, -1, 'Tanker', 30, '0,240,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,', 2, 2, 0, 'noconsign', 30, 50, 0, 4000, 0, '', 100, 100, 100, 100, '', 0, 0, 0, 0, 0, '', 0, 0, 0, '', 1, '', NULL, NULL, NULL, NULL, NULL, NULL, NULL); 
    58 INSERT INTO `ships` (`id`, `owner`, `name`, `type`, `cargo`, `x`, `y`, `system`, `status`, `crew`, `e`, `s`, `hull`, `shields`, `heat`, `engine`, `weapons`, `comm`, `sensors`, `docked`, `alarm`, `fleet`, `destsystem`, `destx`, `desty`, `destcom`, `bookmark`, `battle`, `battleAction`, `jumptarget`, `autodeut`, `history`, `script`, `scriptexedata`, `oncommunicate`, `lock`, `visibility`, `onmove`, `respawn`) VALUES (666, -2, 'GTU Handelsposten Delta Serpentis', 10, '0,2000,0,0,500,2000,0,0,0,0,0,0,5000,0,0,0,0,0,300|10|0|0;301|3|0|0;325|3|0|0;326|3|0|0;161|500|0|0;170|500|0|0;150|500|0|0;154|500|0|0;172|500|0|0', 75, 75, 1, 'tradepost nocrew', 0, 4700, 0, 100000, 0, '', 100, 100, 100, 100, '', 0, 0, 0, 0, 0, '', 0, 0, 0, '2:150/150', 1, '', NULL, NULL, '*:26:0', NULL, NULL, NULL, NULL); 
     55INSERT INTO `ships` (`id`, `owner`, `name`, `type`, `cargo`, `x`, `y`, `system`, `status`, `crew`, `e`, `s`, `hull`, `shields`, `heat`, `engine`, `weapons`, `comm`, `sensors`, `docked`, `alarm`, `fleet`, `destsystem`, `destx`, `desty`, `destcom`, `bookmark`, `battle`, `battleAction`, `jumptarget`, `autodeut`, `history`, `script`, `scriptexedata`, `oncommunicate`, `lock`, `visibility`, `onmove`, `respawn`) VALUES (2, -1, 'Frachter', 27, '0,0,0,0,50,0,0,0,0,0,0,0,0,0,0,0,0,0,', 1, 1, 0, 'noconsign', 50, 80, 0, 5000, 0, '', 100, 100, 100, 100, '', 0, null, 0, 0, 0, '', 0, 0, 0, '', 1, '', NULL, NULL, NULL, NULL, NULL, NULL, NULL); 
     56INSERT INTO `ships` (`id`, `owner`, `name`, `type`, `cargo`, `x`, `y`, `system`, `status`, `crew`, `e`, `s`, `hull`, `shields`, `heat`, `engine`, `weapons`, `comm`, `sensors`, `docked`, `alarm`, `fleet`, `destsystem`, `destx`, `desty`, `destcom`, `bookmark`, `battle`, `battleAction`, `jumptarget`, `autodeut`, `history`, `script`, `scriptexedata`, `oncommunicate`, `lock`, `visibility`, `onmove`, `respawn`) VALUES (3, -1, 'Tanker', 2, '0,300,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,', 1, 2, 0, 'noconsign', 30, 40, 0, 10000, 0, '', 100, 100, 100, 100, '', 0, null, 0, 0, 0, '', 0, 0, 0, '', 1, '', NULL, NULL, NULL, NULL, NULL, NULL, NULL); 
     57INSERT INTO `ships` (`id`, `owner`, `name`, `type`, `cargo`, `x`, `y`, `system`, `status`, `crew`, `e`, `s`, `hull`, `shields`, `heat`, `engine`, `weapons`, `comm`, `sensors`, `docked`, `alarm`, `fleet`, `destsystem`, `destx`, `desty`, `destcom`, `bookmark`, `battle`, `battleAction`, `jumptarget`, `autodeut`, `history`, `script`, `scriptexedata`, `oncommunicate`, `lock`, `visibility`, `onmove`, `respawn`) VALUES (5, -1, 'Frachter', 31, '0,60,0,0,50,0,0,0,0,0,0,0,0,0,0,0,0,0,', 2, 1, 0, 'noconsign', 30, 80, 0, 8500, 0, '', 100, 100, 100, 100, '', 0, null, 0, 0, 0, '', 0, 0, 0, '', 1, '', NULL, NULL, NULL, NULL, NULL, NULL, NULL); 
     58INSERT INTO `ships` (`id`, `owner`, `name`, `type`, `cargo`, `x`, `y`, `system`, `status`, `crew`, `e`, `s`, `hull`, `shields`, `heat`, `engine`, `weapons`, `comm`, `sensors`, `docked`, `alarm`, `fleet`, `destsystem`, `destx`, `desty`, `destcom`, `bookmark`, `battle`, `battleAction`, `jumptarget`, `autodeut`, `history`, `script`, `scriptexedata`, `oncommunicate`, `lock`, `visibility`, `onmove`, `respawn`) VALUES (6, -1, 'Tanker', 30, '0,240,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,', 2, 2, 0, 'noconsign', 30, 50, 0, 4000, 0, '', 100, 100, 100, 100, '', 0, null, 0, 0, 0, '', 0, 0, 0, '', 1, '', NULL, NULL, NULL, NULL, NULL, NULL, NULL); 
     59INSERT INTO `ships` (`id`, `owner`, `name`, `type`, `cargo`, `x`, `y`, `system`, `status`, `crew`, `e`, `s`, `hull`, `shields`, `heat`, `engine`, `weapons`, `comm`, `sensors`, `docked`, `alarm`, `fleet`, `destsystem`, `destx`, `desty`, `destcom`, `bookmark`, `battle`, `battleAction`, `jumptarget`, `autodeut`, `history`, `script`, `scriptexedata`, `oncommunicate`, `lock`, `visibility`, `onmove`, `respawn`) VALUES (666, -2, 'GTU Handelsposten Delta Serpentis', 10, '0,2000,0,0,500,2000,0,0,0,0,0,0,5000,0,0,0,0,0,300|10|0|0;301|3|0|0;325|3|0|0;326|3|0|0;161|500|0|0;170|500|0|0;150|500|0|0;154|500|0|0;172|500|0|0', 75, 75, 1, 'tradepost nocrew', 0, 4700, 0, 100000, 0, '', 100, 100, 100, 100, '', 0, null, 0, 0, 0, '', 0, 0, 0, '2:150/150', 1, '', NULL, NULL, '*:26:0', NULL, NULL, NULL, NULL); 
  • db/updates.xml

    r3924571 r23d6d8b  
    279279                ALTER TABLE ammo ADD CONSTRAINT ammo_fk_ammo FOREIGN KEY (replaces) REFERENCES ammo(id); 
    280280        ]]></update> 
     281        <update type="structure" datum="2007-06-09"><![CDATA[ 
     282                ALTER TABLE ships CHANGE fleet fleet int DEFAULT NULL; 
     283                UPDATE ships SET fleet=NULL WHERE fleet=0; 
     284                ALTER TABLE ships ADD CONSTRAINT ships_fk_ship_fleets FOREIGN KEY (fleet) REFERENCES ship_fleets(id); 
     285        ]]></update> 
    281286</updates> 
  • src/net/driftingsouls/ds2/server/modules/FleetMgntController.java

    r283e6c7 r23d6d8b  
    378378                Database db = getDatabase(); 
    379379                         
    380                 db.update("UPDATE ships SET fleet=0 WHERE fleet='",fleet.getInt("id"),"'"); 
     380                db.update("UPDATE ships SET fleet=null WHERE fleet='",fleet.getInt("id"),"'"); 
    381381                db.update("DELETE FROM ship_fleets WHERE id='",fleet.getInt("id"),"'"); 
    382382 
  • src/net/driftingsouls/ds2/server/modules/SchiffController.java

    r283e6c7 r23d6d8b  
    263263                         
    264264                                if( fleetcount < 3 ) { 
    265                                         db.update("UPDATE ships SET fleet=0 WHERE id>0 AND fleet="+fleet); 
     265                                        db.update("UPDATE ships SET fleet=null WHERE id>0 AND fleet="+fleet); 
    266266                                        db.update("DELETE FROM ship_fleets WHERE id>0 AND id="+fleet); 
    267267                                } 
     
    11811181                        else { 
    11821182                                t.set_var("ship.fleet", 0); 
    1183                                 db.update("UPDATE ships SET fleet=0 WHERE id>0 AND id=",ship.getInt("id")); 
     1183                                db.update("UPDATE ships SET fleet=null WHERE id>0 AND id=",ship.getInt("id")); 
    11841184                        } 
    11851185                } 
  • src/net/driftingsouls/ds2/server/modules/ks/KSKapernAction.java

    r283e6c7 r23d6d8b  
    260260                        enemyShip.put("history", enemyShip.getString("history") + "Im Kampf gekapert am "+currentTime+" durch "+user.getName()+" ("+user.getID()+")\n"); 
    261261                         
    262                         db.update("UPDATE ships SET owner=",user.getID(),",fleet=0,battleAction=1,engine=",enemyShip.getInt("engine"),",weapons=",enemyShip.getInt("weapons"),",crew=",newshipcrew," WHERE id>0 AND id=",enemyShip.getInt("id")); 
     262                        db.update("UPDATE ships SET owner=",user.getID(),",fleet=null,battleAction=1,engine=",enemyShip.getInt("engine"),",weapons=",enemyShip.getInt("weapons"),",crew=",newshipcrew," WHERE id>0 AND id=",enemyShip.getInt("id")); 
    263263                        db.update("UPDATE battles_ships SET side=",battle.getOwnSide(),",engine=",enemyShip.getInt("engine"),",weapons=",enemyShip.getInt("weapons")," WHERE shipid=",enemyShip.getInt("id")); 
    264264                                 
    265                         db.update("UPDATE ships SET owner=",user.getID(),",fleet=0,battleAction=1 WHERE id>0 AND docked IN ('",enemyShip.getInt("id"),"','l ",enemyShip.getInt("id"),"')"); 
     265                        db.update("UPDATE ships SET owner=",user.getID(),",fleet=null,battleAction=1 WHERE id>0 AND docked IN ('",enemyShip.getInt("id"),"','l ",enemyShip.getInt("id"),"')"); 
    266266                                 
    267267                        db.update("UPDATE offiziere SET userid=",user.getID()," WHERE dest='s ",enemyShip.getInt("id"),"'"); 
  • src/net/driftingsouls/ds2/server/modules/schiffplugins/SensorsDefault.java

    r283e6c7 r23d6d8b  
    408408                                        String groupidlist = "";                                 
    409409                                        if( datas.getInt("owner") == user.getID() ) { 
    410                                                 fleetlesscount = db.first("SELECT count(*) count FROM ships WHERE id>0 AND system='",data.getInt("system"),"' AND x='",data.getInt("x"),"' AND y='",data.getInt("y"),"' AND owner='",user.getID(),"' AND type='",datas.getInt("type"),"' AND !LOCATE('l ',docked) AND !LOCATE('disable_iff',status) AND fleet=0").getInt("count"); 
     410                                                fleetlesscount = db.first("SELECT count(*) count FROM ships WHERE id>0 AND system='",data.getInt("system"),"' AND x='",data.getInt("x"),"' AND y='",data.getInt("y"),"' AND owner='",user.getID(),"' AND type='",datas.getInt("type"),"' AND !LOCATE('l ',docked) AND !LOCATE('disable_iff',status) AND fleet is null").getInt("count"); 
    411411                                                if( data.getInt("fleet") != 0 ) { 
    412412                                                        ownfleetcount = db.first("SELECT count(*) count FROM ships WHERE id>0 AND system='",data.getInt("system"),"' AND x='",data.getInt("x"),"' AND y='",data.getInt("y"),"' AND owner='",user.getID(),"' AND type='",datas.getInt("type"),"'  AND !LOCATE('l ',docked) AND !LOCATE('disable_iff',status) AND fleet=",data.getInt("fleet")).getInt("count"); 
     
    446446                                                int ownfleetcount = 0;                                   
    447447                                                if( datas.getInt("owner") == user.getID() ) { 
    448                                                         fleetlesscount = db.first("SELECT count(*) count FROM ships WHERE id>0 AND system='",data.getInt("system"),"' AND x='",data.getInt("x"),"' AND y='",data.getInt("y"),"' AND owner='",user.getID(),"' AND type='",datas.getInt("type"),"' AND docked='' AND fleet=0").getInt("count"); 
     448                                                        fleetlesscount = db.first("SELECT count(*) count FROM ships WHERE id>0 AND system='",data.getInt("system"),"' AND x='",data.getInt("x"),"' AND y='",data.getInt("y"),"' AND owner='",user.getID(),"' AND type='",datas.getInt("type"),"' AND docked='' AND fleet is null").getInt("count"); 
    449449                                                        if( data.getInt("fleet") != 0 ) { 
    450450                                                                ownfleetcount = db.first("SELECT count(*) count FROM ships WHERE id>0 AND system='",data.getInt("system"),"' AND x='",data.getInt("x"),"' AND y='",data.getInt("y"),"' AND owner='",user.getID(),"' AND type='",datas.getInt("type"),"' AND docked='' AND fleet=",data.getInt("fleet")).getInt("count"); 
  • src/net/driftingsouls/ds2/server/ships/Ship.java

    r283e6c7 r23d6d8b  
    7575        private String docked; 
    7676        private int alarm; 
    77         private int fleet; 
     77        @ManyToOne(fetch=FetchType.LAZY) 
     78        @JoinColumn(name="fleet", nullable=true) 
     79        private ShipFleet fleet; 
    7880        private int destsystem; 
    7981        private int destx; 
     
    424426        /** 
    425427         * Gibt die Flotte zurueck in der sich das Schiff befindet 
    426          * @return Die ID der Flotte oder <code>0</code> 
    427          */ 
    428         public int getFleet() { 
     428         * @return Die Flotte 
     429         */ 
     430        public ShipFleet getFleet() { 
    429431                return fleet; 
    430432        } 
     
    432434        /** 
    433435         * Setzt die Flotte in der sich das Schiff befindet 
    434          * @param fleet Die neue Flotten-ID 
    435          */ 
    436         public void setFleet(int fleet) { 
     436         * @param fleet Die neue Flotte 
     437         */ 
     438        public void setFleet(ShipFleet fleet) { 
    437439                this.fleet = fleet; 
    438440        } 
  • src/net/driftingsouls/ds2/server/ships/Ships.java

    r283e6c7 r23d6d8b  
    19731973                        if( fleetcount <= 2 ) { 
    19741974                                db.update("DELETE FROM ship_fleets WHERE id=",ship.getInt("fleet")); 
    1975                                 db.update("UPDATE ships SET fleet=0 WHERE fleet=",ship.getInt("fleet")); 
     1975                                db.update("UPDATE ships SET fleet=null WHERE fleet=",ship.getInt("fleet")); 
    19761976                        } 
    19771977                } 
     
    21852185                        ship.put("history", ship.getString("history")+"&Uuml;bergeben am [tick="+ContextMap.getContext().get(ContextCommon.class).getTick()+"] an "+newowner.getName()+" ("+newowner.getID()+")\n"); 
    21862186                                 
    2187                         db.prepare("UPDATE ships SET owner= ?,fleet=0,history= ? ,alarm='0' WHERE id= ? AND owner= ?") 
     2187                        db.prepare("UPDATE ships SET owner= ?,fleet=null,history= ? ,alarm='0' WHERE id= ? AND owner= ?") 
    21882188                                        .update(newowner.getID(), ship.getString("history"), ship.getInt("id"), ship.getInt("owner")); 
    21892189                        db.update("UPDATE offiziere SET userid='",newowner.getID(),"' WHERE dest='s ",ship.getInt("id"),"'"); 
     
    23342334                                 
    23352335                if( fleetcount > 2 ) { 
    2336                         db.tUpdate(1, "UPDATE ships SET fleet=0 WHERE id>0 AND id=",ship.getInt("id")); 
     2336                        db.tUpdate(1, "UPDATE ships SET fleet=null WHERE id>0 AND id=",ship.getInt("id")); 
    23372337                        MESSAGE.get().append("aus der Flotte ausgetreten"); 
    23382338                         
     
    23402340                }  
    23412341                else { 
    2342                         db.tUpdate(1, "UPDATE ships SET fleet=0 WHERE fleet="+ship.getInt("fleet")); 
     2342                        db.tUpdate(1, "UPDATE ships SET fleet=null WHERE fleet="+ship.getInt("fleet")); 
    23432343                        db.tUpdate(1, "DELETE FROM ship_fleets WHERE id="+ship.getInt("fleet")); 
    23442344                        MESSAGE.get().append("Flotte aufgel&ouml;&szlig;t");