Changeset a8c7a5744c9378c3a594174320715e82927776f9
- Timestamp:
- 03/24/07 14:07:50 (2 years ago)
- git-parent:
- Files:
-
- src/net/driftingsouls/ds2/server/modules/schiffplugins/NavigationDefault.java (modified) (6 diffs)
- src/net/driftingsouls/ds2/server/scripting/ActionFunctions.java (modified) (3 diffs)
- src/net/driftingsouls/ds2/server/scripting/QuestFunctions.java (modified) (3 diffs)
- src/net/driftingsouls/ds2/server/ships/Ships.java (modified) (3 diffs)
- templates/schiff.navigation.default.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
src/net/driftingsouls/ds2/server/modules/schiffplugins/NavigationDefault.java
rdc81135 ra8c7a57 18 18 */ 19 19 package net.driftingsouls.ds2.server.modules.schiffplugins; 20 21 import java.util.List; 20 22 21 23 import net.driftingsouls.ds2.server.ContextCommon; … … 33 35 import net.driftingsouls.ds2.server.scripting.Quests; 34 36 import net.driftingsouls.ds2.server.scripting.ScriptParser; 37 import net.driftingsouls.ds2.server.ships.RouteFactory; 35 38 import net.driftingsouls.ds2.server.ships.Ships; 39 import net.driftingsouls.ds2.server.ships.Waypoint; 36 40 37 41 /** … … 56 60 57 61 controller.parameterString("setdest"); 58 String setdest = controller.getString("setdest"); 62 String setdest = controller.getString("setdest"); 59 63 60 64 //Wird eine neue Beschreibung gesetzt? 61 if( !setdest.equals("")) {65 if( setdest.length() > 0 ) { 62 66 controller.parameterNumber("system"); 63 67 controller.parameterNumber("x"); … … 85 89 controller.parameterNumber("act"); 86 90 controller.parameterNumber("count"); 91 controller.parameterNumber("targetx"); 92 controller.parameterNumber("targety"); 87 93 int act = controller.getInteger("act"); 88 94 int count = controller.getInteger("count"); 89 90 if( (act != 5) && (act >= 1) && (act <= 9) && !ship.getString("onmove").equals("") ) { 95 int targetx = controller.getInteger("targetx"); 96 int targety = controller.getInteger("targety"); 97 98 if( (act > 9) || (act < 1) || count <= 0 ) { 99 return "Ungültige Flugparameter<br />\n"; 100 } 101 102 if( (ship.getString("onmove").length() > 0) && 103 ((targetx != 0) && (targety != 0)) || ((act != 5) && (act >= 1) && (act <= 9)) ) { 91 104 ScriptParser scriptparser = ContextMap.getContext().get(ContextCommon.class).getScriptParser( ScriptParser.NameSpace.QUEST ); 92 105 scriptparser.setShip(ship); … … 94 107 scriptparser.setRegister("DIRECTION",Integer.toString(act)); 95 108 scriptparser.setRegister("MOVEMENTCOUNT",Integer.toString(count)); 109 scriptparser.setRegister("TARGETX",Integer.toString(targetx)); 110 scriptparser.setRegister("TARGETY",Integer.toString(targety)); 96 111 scriptparser.setRegister("SECTOR", Location.fromResult(ship).toString()); 97 112 … … 102 117 act = Integer.parseInt(scriptparser.getRegister("DIRECTION")); 103 118 count = Integer.parseInt(scriptparser.getRegister("MOVEMENTCOUNT")); 119 targetx = Integer.parseInt(scriptparser.getRegister("TARGETX")); 120 targety = Integer.parseInt(scriptparser.getRegister("TARGETY")); 104 121 } 105 122 catch( NumberFormatException e ) { 106 123 LOG.warn("Illegales Zahlenformat nach Ausfuehrung von 'onmove'", e); 107 124 } 108 } 109 125 126 127 if( (act > 9) || (act < 1) || count <= 0 ) { 128 return "Ungültige Flugparameter<br />\n"; 129 } 130 } 131 132 RouteFactory router = new RouteFactory(); 133 List<Waypoint> route = null; 134 if( targetx == 0 || targety == 0 ) { 135 route = router.getMovementRoute(act, count); 136 } 137 else { 138 Location from = Location.fromResult(ship); 139 route = router.findRoute(from, new Location(from.getSystem(), targetx, targety)); 140 } 141 110 142 //Das Schiff soll sich offenbar bewegen 111 Ships.move(ship.getInt("id"), act, count, false, false);143 Ships.move(ship.getInt("id"), route, true, false); 112 144 output += Ships.MESSAGE.getMessage(); 113 145 src/net/driftingsouls/ds2/server/scripting/ActionFunctions.java
r4be6f46 ra8c7a57 19 19 package net.driftingsouls.ds2.server.scripting; 20 20 21 import java.util.List; 22 21 23 import net.driftingsouls.ds2.server.ContextCommon; 22 24 import net.driftingsouls.ds2.server.Location; … … 30 32 import net.driftingsouls.ds2.server.framework.db.Database; 31 33 import net.driftingsouls.ds2.server.framework.db.SQLResultRow; 34 import net.driftingsouls.ds2.server.ships.RouteFactory; 32 35 import net.driftingsouls.ds2.server.ships.ShipTypes; 33 36 import net.driftingsouls.ds2.server.ships.Ships; 37 import net.driftingsouls.ds2.server.ships.Waypoint; 34 38 import net.driftingsouls.ds2.server.tasks.Taskmanager; 35 39 … … 85 89 return STOP; 86 90 } 91 92 RouteFactory router = new RouteFactory(); 93 List<Waypoint> route = router.findRoute(Location.fromResult(curpos), target, maxcount); 87 94 88 int direction = -1; 89 int count = 0; 90 boolean wait = false; 91 while( true ) { 92 int newdirection = 5; 93 if( deltax > 0 ) { 94 newdirection += 1; 95 } 96 else if( deltax < 0 ) { 97 newdirection -= 1; 98 } 99 100 if( deltay > 0 ) { 101 newdirection += 3; 102 } 103 else if( deltay < 0 ) { 104 newdirection -= 3; 105 } 106 107 if( ((direction != -1) && (direction != newdirection)) || (maxcount == 0) ) { 108 boolean result = Ships.move(ship.getInt("id"), direction, count, true, false); 109 scriptparser.log(Common._stripHTML(Ships.MESSAGE.getMessage())); 110 111 if( result ) { 112 wait = true; 113 break; 114 } 115 116 if( newdirection == 5 ) { 117 break; 118 } 119 count = 1; 120 if( maxcount > 0 ) { 121 maxcount--; 122 } 123 else { 124 wait = true; 125 break; 126 } 127 direction = newdirection; 128 } 129 else { 130 count++; 131 if( maxcount > 0 ) { 132 maxcount--; 133 } 134 else { 135 count--; 136 if( count == 0 ) { 137 wait = true; 138 break; 139 } 140 } 141 direction = newdirection; 142 } 143 int xOffset = 0; 144 int yOffset = 0; 145 146 if( direction == 1 ) { xOffset--; yOffset--;} 147 else if( direction == 2 ) { yOffset--;} 148 else if( direction == 3 ) { xOffset++; yOffset--;} 149 else if( direction == 4 ) { xOffset--;} 150 else if( direction == 6 ) { xOffset++;} 151 else if( direction == 7 ) { xOffset--; yOffset++;} 152 else if( direction == 8 ) { yOffset++;} 153 else if( direction == 9 ) { xOffset++; yOffset++;} 154 155 curpos.put("x", curpos.getInt("x")+xOffset); 156 curpos.put("y", curpos.getInt("y")+yOffset); 157 158 deltax = target.getX()-curpos.getInt("x"); 159 deltay = target.getY()-curpos.getInt("y"); 160 } 95 boolean result = Ships.move(ship.getInt("id"), route, true, false); 96 scriptparser.log(Common._stripHTML(Ships.MESSAGE.getMessage())); 161 97 ship = db.first("SELECT * FROM ships WHERE id=",ship.getInt("id")); 162 98 scriptparser.setShip(ship); 163 99 164 if( wait ) { 165 scriptparser.log("Ausfuehrung bis zum naechsten Tick angehalten\n\n"); 166 return STOP; 167 } 168 if( Math.abs(deltax)+Math.abs(deltay) == 0 ) { 169 scriptparser.log("\n"); 170 return CONTINUE; 100 if( result ) { 101 scriptparser.log("Ausfuehrung bis zum naechsten Tick angehalten\n\n"); 102 return STOP; 171 103 } 172 104 src/net/driftingsouls/ds2/server/scripting/QuestFunctions.java
r2a7339d ra8c7a57 49 49 import net.driftingsouls.ds2.server.framework.db.SQLQuery; 50 50 import net.driftingsouls.ds2.server.framework.db.SQLResultRow; 51 import net.driftingsouls.ds2.server.ships.RouteFactory; 51 52 import net.driftingsouls.ds2.server.ships.Ships; 53 import net.driftingsouls.ds2.server.ships.Waypoint; 52 54 53 55 import org.apache.commons.lang.StringUtils; … … 1517 1519 scriptparser.log("target: "+target+"\n"); 1518 1520 1519 SQLResultRow ship = db.first("SELECT * FROM ships WHERE id>0 AND id="+shipid); 1520 Location curpos = Location.fromResult(ship); 1521 1522 int deltax = target.getX()-curpos.getX(); 1523 int deltay = target.getY()-curpos.getY(); 1521 SQLResultRow curpos = db.first("SELECT x,y,system,s FROM ships WHERE id=",shipid); 1522 1523 int deltax = target.getX()-curpos.getInt("x"); 1524 int deltay = target.getY()-curpos.getInt("y"); 1524 1525 1525 1526 if( (deltax == 0) && (deltay == 0) ) { … … 1528 1529 } 1529 1530 1530 if( ship.getInt("s") > 100 ) {1531 if( curpos.getInt("s") > 100 ) { 1531 1532 scriptparser.log("Ausfuehrung bis zum naechsten Tick angehalten\n\n"); 1532 1533 return STOP; 1533 1534 } 1534 1535 int direction = -1; 1536 int count = 0; 1537 boolean wait = false; 1538 while( true ) { 1539 int newdirection = 5; 1540 if( deltax > 0 ) { 1541 newdirection += 1; 1542 } 1543 else if( deltax < 0 ) { 1544 newdirection -= 1; 1545 } 1546 1547 if( deltay > 0 ) { 1548 newdirection += 3; 1549 } 1550 else if( deltay < 0 ) { 1551 newdirection -= 3; 1552 } 1553 1554 if( (direction != -1) && (direction != newdirection) ) { 1555 boolean result = Ships.move(ship.getInt("id"), direction, count, true, true); 1556 scriptparser.log( Common._stripHTML(Ships.MESSAGE.getMessage()) ); 1557 1558 if( result ) { 1559 wait = true; 1560 break; 1561 } 1562 1563 if( newdirection == 5 ) { 1564 break; 1565 } 1566 count = 1; 1567 direction = newdirection; 1568 } 1569 else { 1570 count++; 1571 direction = newdirection; 1572 } 1573 int xOffset = 0; 1574 int yOffset = 0; 1575 1576 if( direction == 1 ) { xOffset--; yOffset--;} 1577 else if( direction == 2 ) { yOffset--;} 1578 else if( direction == 3 ) { xOffset++; yOffset--;} 1579 else if( direction == 4 ) { xOffset--;} 1580 else if( direction == 6 ) { xOffset++;} 1581 else if( direction == 7 ) { xOffset--; yOffset++;} 1582 else if( direction == 8 ) { yOffset++;} 1583 else if( direction == 9 ) { xOffset++; yOffset++;} 1584 1585 curpos = new Location(curpos.getSystem(), 1586 curpos.getX()+xOffset, 1587 curpos.getY()+yOffset); 1588 1589 deltax = target.getX()-curpos.getX(); 1590 deltay = target.getY()-curpos.getY(); 1591 } 1592 if( wait ) { 1535 1536 RouteFactory router = new RouteFactory(); 1537 List<Waypoint> route = router.findRoute(Location.fromResult(curpos), target); 1538 1539 boolean result = Ships.move(shipid, route, true, false); 1540 scriptparser.log(Common._stripHTML(Ships.MESSAGE.getMessage())); 1541 1542 if( result ) { 1593 1543 scriptparser.setRegister("A","1"); 1594 1544 } src/net/driftingsouls/ds2/server/ships/Ships.java
r4be6f46 ra8c7a57 925 925 926 926 /** 927 * <p>Fliegt ein Schiff n Felder in eine Richtung. Falls das Schiff einer Flotte angehoert, fliegt927 * <p>Fliegt ein Schiff eine Flugroute entlang. Falls das Schiff einer Flotte angehoert, fliegt 928 928 * diese ebenfalls n Felder in diese Richtung.</p> 929 * Die Richtungen:<br>930 * 1 2 3<br>931 * 4 6<br>932 * 7 8 9<br>933 929 * <p>Der Flug wird abgebrochen sobald eines der Schiffe nicht mehr weiterfliegen kann</p> 930 * Die Flugrouteninformationen werden waehrend des Fluges modifiziert 934 931 * 935 932 * @param shipID Die ID des Schiffes, welches fliegen soll 936 * @param direction Die Richtung 937 * @param distance Die Anzahl der zu fliegenden Felder 933 * @param route Die Flugroute 938 934 * @param forceLowHeat Soll bei Ueberhitzung sofort abgebrochen werden? 939 935 * @param disableQuests Sollen Questhandler ignoriert werden? 940 936 * @return <code>true</code>, falls ein Fehler aufgetreten ist 941 937 */ 942 public static boolean move(int shipID, int direction, int distance, boolean forceLowHeat, boolean disableQuests) {938 public static boolean move(int shipID, List<Waypoint> route, boolean forceLowHeat, boolean disableQuests) { 943 939 StringBuilder out = MESSAGE.get(); 944 940 945 if( (direction < 1) || (direction > 9) || (direction == 5) ) {946 return true;947 }948 949 941 Database db = ContextMap.getContext().getDatabase(); 950 942 … … 999 991 boolean moved = false; 1000 992 1001 // Zielkoordinaten/Bewegungsrichtung berechnen 1002 String xbetween = "x='"+ship.getInt("x")+"'"; 1003 String ybetween = "y='"+ship.getInt("y")+"'"; 1004 int xoffset = 0; 1005 int yoffset = 0; 1006 if( direction <= 3 ) { 1007 ybetween = "y BETWEEN '"+(ship.getInt("y")-distance)+"' AND '"+ship.getInt("y")+"'"; 1008 yoffset--; 1009 } 1010 else if( direction >= 7 ) { 1011 ybetween = "y BETWEEN '"+ship.getInt("y")+"' AND '"+(ship.getInt("y")+distance)+"'"; 1012 yoffset++; 1013 } 1014 1015 if( (direction-1) % 3 == 0 ) { 1016 xbetween = "x BETWEEN '"+(ship.getInt("x")-distance)+"' AND '"+ship.getInt("x")+"'"; 1017 xoffset--; 1018 } 1019 else if( direction % 3 == 0 ) { 1020 xbetween = "x BETWEEN '"+ship.getInt("x")+"' AND '"+(ship.getInt("x")+distance)+"'"; 1021 xoffset++; 1022 } 1023 1024 // Alle potentiell relevanten Sektoren (ok..und ein wenig ueberfluessiges Zeug bei schraegen Bewegungen) auslesen 1025 Map<Location,SQLResultRow> sectorlist = new HashMap<Location,SQLResultRow>(); 1026 SQLQuery sectorRow = db.query("SELECT * FROM sectors " , 1027 "WHERE system IN (",ship.getInt("system"),",-1) AND (x='-1' OR ",xbetween,") AND (y='-1' OR ",ybetween,") ORDER BY system DESC"); 993 while( !error && route.size() > 0 ) { 994 Waypoint waypoint = route.remove(0); 995 996 if( waypoint.type != Waypoint.Type.MOVEMENT ) { 997 throw new RuntimeException("Es wird nur "+Waypoint.Type.MOVEMENT+" als Wegpunkt unterstuetzt"); 998 } 999 1000 if( waypoint.direction == 5 ) { 1001 continue; 1002 } 1003 1004 // Zielkoordinaten/Bewegungsrichtung berechnen 1005 String xbetween = "x='"+ship.getInt("x")+"'"; 1006 String ybetween = "y='"+ship.getInt("y")+"'"; 1007 int xoffset = 0; 1008 int yoffset = 0; 1009 if( waypoint.direction <= 3 ) { 1010 ybetween = "y BETWEEN '"+(ship.getInt("y")-waypoint.distance)+"' AND '"+ship.getInt("y")+"'"; 1011 yoffset--; 1012 } 1013 else if( waypoint.direction >= 7 ) { 1014 ybetween = "y BETWEEN '"+ship.getInt("y")+"' AND '"+(ship.getInt("y")+waypoint.distance)+"'"; 1015 yoffset++; 1016 } 1017 1018 if( (waypoint.direction-1) % 3 == 0 ) { 1019 xbetween = "x BETWEEN '"+(ship.getInt("x")-waypoint.distance)+"' AND '"+ship.getInt("x")+"'"; 1020 xoffset--; 1021 } 1022 else if( waypoint.direction % 3 == 0 ) { 1023 xbetween = "x BETWEEN '"+ship.getInt("x")+"' AND '"+(ship.getInt("x")+waypoint.distance)+"'"; 1024 xoffset++; 1025 } 1026 1027 // Alle potentiell relevanten Sektoren (ok..und ein wenig ueberfluessiges Zeug bei schraegen Bewegungen) auslesen 1028 Map<Location,SQLResultRow> sectorlist = new HashMap<Location,SQLResultRow>(); 1029 SQLQuery sectorRow = db.query("SELECT * FROM sectors " , 1030 "WHERE system IN (",ship.getInt("system"),",-1) AND (x='-1' OR ",xbetween,") AND (y='-1' OR ",ybetween,") ORDER BY system DESC"); 1031 1032 while( sectorRow.next() ) { 1033 SQLResultRow row = sectorRow.getRow(); 1034 sectorlist.put(Location.fromResult(row), row); 1035 } 1036 sectorRow.free(); 1037 1038 // Alle potentiell relevanten Sektoren mit Schiffen auf rotem Alarm (ok..und ein wenig ueberfluessiges Zeug bei schraegen Bewegungen) auslesen 1039 Map<Location,Boolean> redalertlist = new HashMap<Location,Boolean>(); 1040 sectorRow = db.query("SELECT x,y FROM ships " , 1041 "WHERE owner!='",ship.getInt("owner"),"' AND alarm='1' AND system=",ship.getInt("system")," AND ",xbetween," AND ",ybetween); 1042 1043 while( sectorRow.next() ) { 1044 redalertlist.put(new Location(ship.getInt("system"), sectorRow.getInt("x"), sectorRow.getInt("y")), Boolean.TRUE); 1045 } 1046 sectorRow.free(); 1047 1048 // Alle potentiell relevanten Sektoren mit EMP-Nebeln (ok..und ein wenig ueberfluessiges Zeug bei schraegen Bewegungen) auslesen 1049 Map<Location,Boolean> nebulaemplist = new HashMap<Location,Boolean>(); 1050 sectorRow = db.query("SELECT system,x,y,type FROM nebel ", 1051 "WHERE type>=3 AND type<=5 AND system=",ship.getInt("system")," AND ",xbetween," AND ",ybetween); 1052 1053 while( sectorRow.next() ) { 1054 cacheNebula(sectorRow.getRow()); 1055 nebulaemplist.put(new Location(ship.getInt("system"), sectorRow.getInt("x"), sectorRow.getInt("y")), Boolean.TRUE); 1056 } 1057 sectorRow.free(); 1058 1059 if( (waypoint.distance > 1) && nebulaemplist.containsKey(Location.fromResult(ship)) ) { 1060 out.append("<span style=\"color:#ff0000\">Der Autopilot funktioniert in EMP-Nebeln nicht</span><br />\n"); 1061 return true; 1062 } 1063 1064 long starttime = System.currentTimeMillis(); 1065 1066 int startdistance = waypoint.distance; 1067 1068 // Und nun fliegen wir mal ne Runde.... 1069 while( waypoint.distance > 0 ) { 1070 // Schauen wir mal ob wir vor rotem Alarm warnen muessen 1071 if( (startdistance > 1) && redalertlist.containsKey(new Location(ship.getInt("system"),ship.getInt("x")+xoffset, ship.getInt("y")+yoffset)) ) { 1072 SQLResultRow newship = new SQLResultRow(); 1073 newship.putAll(ship); 1074 newship.put("x", newship.getInt("x") + xoffset); 1075 newship.put("y", newship.getInt("y") + yoffset); 1076 Integer[] attackers = redAlertCheck(newship, false); 1077 if( attackers.length != 0 ) { 1078 out.append("<span style=\"color:#ff0000\">Feindliche Schiffe in Alarmbereitschaft im nächsten Sektor geortet</span><br />\n"); 1079 out.append("<span style=\"color:#ff0000\">Autopilot bricht ab</span><br />\n"); 1080 error = true; 1081 waypoint.distance = 0; 1082 break; 1083 } 1084 } 1085 1086 if( (startdistance > 1) && nebulaemplist.containsKey(new Location(ship.getInt("system"),ship.getInt("x")+xoffset, ship.getInt("y")+yoffset)) ) { 1087 out.append("<span style=\"color:#ff0000\">EMP-Nebel im nächsten Sektor geortet</span><br />\n"); 1088 out.append("<span style=\"color:#ff0000\">Autopilot bricht ab</span><br />\n"); 1089 error = true; 1090 waypoint.distance = 0; 1091 break; 1092 } 1093 1094 int olddirection = waypoint.direction; 1095 1096 // ACHTUNG: Ob das ganze hier noch sinnvoll funktioniert, wenn distance > 1 ist, ist mehr als fraglich... 1097 if( nebulaemplist.containsKey(new Location(ship.getInt("system"),ship.getInt("x")+xoffset, ship.getInt("y")+yoffset)) && 1098 (RandomUtils.nextInt(100+1) > 75) ) { 1099 int nebel = getNebula(ship); 1100 if( nebel == 5 ) { 1101 waypoint.direction = RandomUtils.nextInt(10)+1; 1102 if( waypoint.direction > 4 ) { 1103 waypoint.direction++; 1104 1105 } 1106 // Nun muessen wir noch die Caches fuellen 1107 if( waypoint.direction != olddirection ) { 1108 int tmpxoff = 0; 1109 int tmpyoff = 0; 1110 1111 if( waypoint.direction <= 3 ) { 1112 tmpyoff--; 1113 } 1114 else if( waypoint.direction >= 7 ) { 1115 tmpyoff++; 1116 } 1117 1118 if( (waypoint.direction-1) % 3 == 0 ) { 1119 tmpxoff--; 1120 } 1121 else if( waypoint.direction % 3 == 0 ) { 1122 tmpxoff++; 1123 } 1124 1125 SQLQuery sector = db.query("SELECT * FROM sectors " , 1126 "WHERE system IN (",ship.getInt("system"),",-1) AND (x='-1' OR ",(ship.getInt("x")+tmpxoff),") AND (y='-1' OR ",(ship.getInt("y")+tmpyoff),") ORDER BY system DESC"); 1127 while( sector.next() ) { 1128 SQLResultRow row = sector.getRow(); 1129 sectorlist.put(Location.fromResult(row), row); 1130 } 1131 sector.free(); 1132 1133 SQLResultRow rasect = db.first("SELECT x,y FROM ships " , 1134 "WHERE owner!='",ship.getInt("owner"),"' AND alarm='1' AND system=",ship.getInt("system")," AND x='",(ship.getInt("x")+tmpxoff),"' AND y='",(ship.getInt("y")+tmpyoff),"'"); 1028 1135 1029 while( sectorRow.next() ) { 1030 SQLResultRow row = sectorRow.getRow(); 1031 sectorlist.put(Location.fromResult(row), row); 1032 } 1033 sectorRow.free(); 1034 1035 // Alle potentiell relevanten Sektoren mit Schiffen auf rotem Alarm (ok..und ein wenig ueberfluessiges Zeug bei schraegen Bewegungen) auslesen 1036 Map<Location,Boolean> redalertlist = new HashMap<Location,Boolean>(); 1037 sectorRow = db.query("SELECT x,y FROM ships " , 1038 "WHERE owner!='",ship.getInt("owner"),"' AND alarm='1' AND system=",ship.getInt("system")," AND ",xbetween," AND ",ybetween); 1039 1040 while( sectorRow.next() ) { 1041 redalertlist.put(new Location(ship.getInt("system"), sectorRow.getInt("x"), sectorRow.getInt("y")), Boolean.TRUE); 1042 } 1043 sectorRow.free(); 1044 1045 // Alle potentiell relevanten Sektoren mit EMP-Nebeln (ok..und ein wenig ueberfluessiges Zeug bei schraegen Bewegungen) auslesen 1046 Map<Location,Boolean> nebulaemplist = new HashMap<Location,Boolean>(); 1047 sectorRow = db.query("SELECT system,x,y,type FROM nebel ", 1048 "WHERE type>=3 AND type<=5 AND system=",ship.getInt("system")," AND ",xbetween," AND ",ybetween); 1049 1050 while( sectorRow.next() ) { 1051 cacheNebula(sectorRow.getRow()); 1052 nebulaemplist.put(new Location(ship.getInt("system"), sectorRow.getInt("x"), sectorRow.getInt("y")), Boolean.TRUE); 1053 } 1054 sectorRow.free(); 1055 1056 if( (distance > 1) && nebulaemplist.containsKey(Location.fromResult(ship)) ) { 1057 out.append("<span style=\"color:#ff0000\">Der Autopilot funktioniert in EMP-Nebeln nicht</span><br />\n"); 1058 return true; 1059 } 1060 1061 long starttime = System.currentTimeMillis(); 1062 1063 int startdistance = distance; 1064 1065 // Und nun fliegen wir mal ne Runde.... 1066 while( distance > 0 ) { 1067 // Schauen wir mal ob wir vor rotem Alarm warnen muessen 1068 if( (startdistance > 1) && redalertlist.containsKey(new Location(ship.getInt("system"),ship.getInt("x")+xoffset, ship.getInt("y")+yoffset)) ) { 1069 SQLResultRow newship = new SQLResultRow(); 1070 newship.putAll(ship); 1071 newship.put("x", newship.getInt("x") + xoffset); 1072 newship.put("y", newship.getInt("y") + yoffset); 1073 Integer[] attackers = redAlertCheck(newship, false); 1074 if( attackers.length != 0 ) { 1075 out.append("<span style=\"color:#ff0000\">Feindliche Schiffe in Alarmbereitschaft im nächsten Sektor geortet</span><br />\n"); 1076 out.append("<span style=\"color:#ff0000\">Autopilot bricht ab</span><br />\n"); 1077 distance = 0; 1078 break; 1079 } 1080 } 1081 1082 if( (startdistance > 1) && nebulaemplist.containsKey(new Location(ship.getInt("system"),ship.getInt("x")+xoffset, ship.getInt("y")+yoffset)) ) { 1083 out.append("<span style=\"color:#ff0000\">EMP-Nebel im nächsten Sektor geortet</span><br />\n"); 1084 out.append("<span style=\"color:#ff0000\">Autopilot bricht ab</span><br />\n"); 1085 distance = 0; 1086 break; 1087 } 1088 1089 int olddirection = direction; 1090 1091 // ACHTUNG: Ob das ganze hier noch sinnvoll funktioniert, wenn distance > 1 ist, ist mehr als fraglich... 1092 if( nebulaemplist.containsKey(new Location(ship.getInt("system"),ship.getInt("x")+xoffset, ship.getInt("y")+yoffset)) && 1093 (RandomUtils.nextInt(100+1) > 75) ) { 1094 int nebel = getNebula(ship); 1095 if( nebel == 5 ) { 1096 direction = RandomUtils.nextInt(10)+1; 1097 if( direction > 4 ) { 1098 direction++; 1136 if( !rasect.isEmpty() ) { 1137 redalertlist.put(new Location(ship.getInt("system"), rasect.getInt("x"), rasect.getInt("y")), Boolean.TRUE); 1138 } 1139 } 1140 } 1141 } 1142 1143 waypoint.distance--; 1144 1145 SQLResultRow oldship = new SQLResultRow(); 1146 oldship.putAll(ship); 1147 1148 MovementResult result = moveSingle(ship, shiptype, offizier, waypoint.direction, waypoint.distance, adocked, forceLowHeat); 1149 error = result.error; 1150 waypoint.distance = result.distance; 1151 1152 if( result.moved ) { 1153 // Jetzt, da sich unser Schiff korrekt bewegt hat, fliegen wir auch die Flotte ein stueck weiter 1154 if( ship.getInt("fleet") > 0 ) { 1155 boolean fleetResult = moveFleet(oldship, waypoint.direction, forceLowHeat); 1156 if( fleetResult != false ) { 1157 error = true; 1158
