| 63 | | Database db = getContext().getDatabase(); |
|---|
| 64 | | |
|---|
| 65 | | this.log("Sprungantrieb"); |
|---|
| 66 | | SQLQuery jump = db.query("SELECT id,x,y,system,shipid FROM jumps"); |
|---|
| 67 | | while( jump.next() ) { |
|---|
| 68 | | this.log( jump.getInt("shipid")+" springt nach "+jump.getInt("system")+":"+jump.getInt("x")+"/"+jump.getInt("y")); |
|---|
| 69 | | |
|---|
| 70 | | db.update("UPDATE ships SET x=",jump.getInt("x"),",y=",jump.getInt("y"),",system=",jump.getInt("system")," WHERE id>0 AND id=",jump.getInt("shipid")," OR docked='",jump.getInt("shipid"),"' OR docked='l ",jump.getInt("shipid"),"'"); |
|---|
| 71 | | db.update("DELETE FROM jumps WHERE id=",jump.getInt("id")); |
|---|
| 72 | | } |
|---|
| 73 | | jump.free(); |
|---|
| | 63 | try { |
|---|
| | 64 | Database db = getContext().getDatabase(); |
|---|
| | 65 | |
|---|
| | 66 | this.log("Sprungantrieb"); |
|---|
| | 67 | SQLQuery jump = db.query("SELECT id,x,y,system,shipid FROM jumps"); |
|---|
| | 68 | while( jump.next() ) { |
|---|
| | 69 | this.log( jump.getInt("shipid")+" springt nach "+jump.getInt("system")+":"+jump.getInt("x")+"/"+jump.getInt("y")); |
|---|
| | 70 | |
|---|
| | 71 | db.update("UPDATE ships SET x=",jump.getInt("x"),",y=",jump.getInt("y"),",system=",jump.getInt("system")," WHERE id>0 AND id=",jump.getInt("shipid")," OR docked='",jump.getInt("shipid"),"' OR docked='l ",jump.getInt("shipid"),"'"); |
|---|
| | 72 | db.update("DELETE FROM jumps WHERE id=",jump.getInt("id")); |
|---|
| | 73 | } |
|---|
| | 74 | jump.free(); |
|---|
| | 75 | } |
|---|
| | 76 | catch( Exception e ) { |
|---|
| | 77 | this.log("Fehler beim Verarbeiten der Sprungantriebe: "+e); |
|---|
| | 78 | e.printStackTrace(); |
|---|
| | 79 | } |
|---|
| 80 | | Database db = getContext().getDatabase(); |
|---|
| 81 | | |
|---|
| 82 | | this.log(""); |
|---|
| 83 | | this.log("Erstelle Statistiken"); |
|---|
| 84 | | |
|---|
| 85 | | int shipcount = db.first("SELECT count(*) count FROM ships WHERE id>0 AND owner>1").getInt("count"); |
|---|
| 86 | | long crewcount = db.first("SELECT sum(crew) totalcrew FROM ships WHERE id>0 AND owner > 0").getLong("totalcrew"); |
|---|
| 87 | | int tick = getContext().get(ContextCommon.class).getTick(); |
|---|
| 88 | | |
|---|
| 89 | | db.update("INSERT INTO stats_ships (tick,shipcount,crewcount) VALUES (",tick,",",shipcount,",",crewcount,")"); |
|---|
| | 86 | try { |
|---|
| | 87 | Database db = getContext().getDatabase(); |
|---|
| | 88 | |
|---|
| | 89 | this.log(""); |
|---|
| | 90 | this.log("Erstelle Statistiken"); |
|---|
| | 91 | |
|---|
| | 92 | int shipcount = db.first("SELECT count(*) count FROM ships WHERE id>0 AND owner>1").getInt("count"); |
|---|
| | 93 | long crewcount = db.first("SELECT sum(crew) totalcrew FROM ships WHERE id>0 AND owner > 0").getLong("totalcrew"); |
|---|
| | 94 | int tick = getContext().get(ContextCommon.class).getTick(); |
|---|
| | 95 | |
|---|
| | 96 | db.update("INSERT INTO stats_ships (tick,shipcount,crewcount) VALUES (",tick,",",shipcount,",",crewcount,")"); |
|---|
| | 97 | } |
|---|
| | 98 | catch( Exception e ) { |
|---|
| | 99 | this.log("Fehler beim Anlegen der Statistiken: "+e); |
|---|
| | 100 | e.printStackTrace(); |
|---|
| | 101 | } |
|---|
| 96 | | Database db = getDatabase(); |
|---|
| 97 | | |
|---|
| 98 | | this.log(""); |
|---|
| 99 | | this.log("Bearbeite Vacation-Modus"); |
|---|
| 100 | | db.update("UPDATE users SET name=REPLACE(name,' [VAC]',''),nickname=REPLACE(nickname,' [VAC]','') WHERE vaccount=1"); |
|---|
| 101 | | this.log("\t"+db.affectedRows()+" Spieler haben den VAC-Modus verlassen"); |
|---|
| 102 | | db.update("UPDATE users SET vaccount=vaccount-1 WHERE vaccount>0 AND wait4vac=0"); |
|---|
| 103 | | |
|---|
| 104 | | UserIterator iter = getContext().createUserIterator("SELECT id,ally FROM users WHERE wait4vac=1"); |
|---|
| 105 | | for( User user : iter ) { |
|---|
| 106 | | SQLResultRow newcommander = null; |
|---|
| 107 | | if( user.getAlly() > 0 ) { |
|---|
| 108 | | newcommander = db.first("SELECT id,name FROM users WHERE ally=",user.getAlly()," AND inakt <= 7 AND vaccount=0 AND (wait4vac>6 OR wait4vac=0)"); |
|---|
| 109 | | } |
|---|
| 110 | | |
|---|
| 111 | | SQLQuery battleid = db.query("SELECT id FROM battles WHERE commander1=",user.getID()," OR commander2=",user.getID()); |
|---|
| 112 | | while( battleid.next() ) { |
|---|
| 113 | | Battle battle = new Battle(); |
|---|
| 114 | | battle.load(battleid.getInt("id"), user.getID(), 0, 0, 0 ); |
|---|
| 115 | | |
|---|
| 116 | | if( newcommander != null ) { |
|---|
| 117 | | this.log("\t\tUser"+user.getID()+": Die Leitung der Schlacht "+battleid.getInt("id")+" wurde an "+newcommander.getString("name")+" ("+newcommander.getInt("id")+") uebergeben"); |
|---|
| | 108 | try { |
|---|
| | 109 | Database db = getDatabase(); |
|---|
| | 110 | |
|---|
| | 111 | this.log(""); |
|---|
| | 112 | this.log("Bearbeite Vacation-Modus"); |
|---|
| | 113 | db.update("UPDATE users SET name=REPLACE(name,' [VAC]',''),nickname=REPLACE(nickname,' [VAC]','') WHERE vaccount=1"); |
|---|
| | 114 | this.log("\t"+db.affectedRows()+" Spieler haben den VAC-Modus verlassen"); |
|---|
| | 115 | db.update("UPDATE users SET vaccount=vaccount-1 WHERE vaccount>0 AND wait4vac=0"); |
|---|
| | 116 | |
|---|
| | 117 | UserIterator iter = getContext().createUserIterator("SELECT id,ally FROM users WHERE wait4vac=1"); |
|---|
| | 118 | for( User user : iter ) { |
|---|
| | 119 | SQLResultRow newcommander = null; |
|---|
| | 120 | if( user.getAlly() > 0 ) { |
|---|
| | 121 | newcommander = db.first("SELECT id,name FROM users WHERE ally=",user.getAlly()," AND inakt <= 7 AND vaccount=0 AND (wait4vac>6 OR wait4vac=0)"); |
|---|
| | 122 | } |
|---|
| | 123 | |
|---|
| | 124 | SQLQuery battleid = db.query("SELECT id FROM battles WHERE commander1=",user.getID()," OR commander2=",user.getID()); |
|---|
| | 125 | while( battleid.next() ) { |
|---|
| | 126 | Battle battle = new Battle(); |
|---|
| | 127 | battle.load(battleid.getInt("id"), user.getID(), 0, 0, 0 ); |
|---|
| 119 | | battle.logenemy("<action side=\""+battle.getOwnSide()+"\" time=\""+Common.time()+"\" tick=\""+getContext().get(ContextCommon.class).getTick()+"\"><![CDATA[\n"); |
|---|
| 120 | | |
|---|
| 121 | | PM.send(getContext(), user.getID(), newcommander.getInt("id"), "Schlacht übernommen", "Die Leitung der Schlacht bei "+battle.getSystem()+" : "+battle.getX()+"/"+battle.getY()+" wurde dir automatisch übergeben, da der bisherige Kommandant in den Vacationmodus gewechselt ist"); |
|---|
| 122 | | |
|---|
| 123 | | battle.logenemy(Common._titleNoFormat(newcommander.getString("name"))+" kommandiert nun die gegnerischen Truppen\n\n"); |
|---|
| 124 | | |
|---|
| 125 | | battle.setCommander(battle.getOwnSide(), newcommander.getInt("id")); |
|---|
| 126 | | |
|---|
| 127 | | battle.logenemy("]]></action>\n"); |
|---|
| 128 | | |
|---|
| 129 | | battle.logenemy("<side"+(battle.getOwnSide()+1)+" commander=\""+battle.getCommander(battle.getOwnSide())+"\" ally=\""+battle.getAlly(battle.getOwnSide())+"\" />\n"); |
|---|
| 130 | | |
|---|
| 131 | | battle.setTakeCommand(battle.getOwnSide(), 0); |
|---|
| 132 | | |
|---|
| 133 | | battle.save(true); |
|---|
| | 129 | if( newcommander != null ) { |
|---|
| | 130 | this.log("\t\tUser"+user.getID()+": Die Leitung der Schlacht "+battleid.getInt("id")+" wurde an "+newcommander.getString("name")+" ("+newcommander.getInt("id")+") uebergeben"); |
|---|
| | 131 | |
|---|
| | 132 | battle.logenemy("<action side=\""+battle.getOwnSide()+"\" time=\""+Common.time()+"\" tick=\""+getContext().get(ContextCommon.class).getTick()+"\"><![CDATA[\n"); |
|---|
| | 133 | |
|---|
| | 134 | PM.send(getContext(), user.getID(), newcommander.getInt("id"), "Schlacht übernommen", "Die Leitung der Schlacht bei "+battle.getSystem()+" : "+battle.getX()+"/"+battle.getY()+" wurde dir automatisch übergeben, da der bisherige Kommandant in den Vacationmodus gewechselt ist"); |
|---|
| | 135 | |
|---|
| | 136 | battle.logenemy(Common._titleNoFormat(newcommander.getString("name"))+" kommandiert nun die gegnerischen Truppen\n\n"); |
|---|
| | 137 | |
|---|
| | 138 | battle.setCommander(battle.getOwnSide(), newcommander.getInt("id")); |
|---|
| | 139 | |
|---|
| | 140 | battle.logenemy("]]></action>\n"); |
|---|
| | 141 | |
|---|
| | 142 | battle.logenemy("<side"+(battle.getOwnSide()+1)+" commander=\""+battle.getCommander(battle.getOwnSide())+"\" ally=\""+battle.getAlly(battle.getOwnSide())+"\" />\n"); |
|---|
| | 143 | |
|---|
| | 144 | battle.setTakeCommand(battle.getOwnSide(), 0); |
|---|
| | 145 | |
|---|
| | 146 | battle.save(true); |
|---|
| | 147 | |
|---|
| | 148 | battle.writeLog(); |
|---|
| | 149 | } |
|---|
| | 150 | else { |
|---|
| | 151 | this.log("\t\tUser"+user.getID()+": Die Schlacht "+battleid+" wurde beendet"); |
|---|
| 135 | | battle.writeLog(); |
|---|
| 136 | | } |
|---|
| 137 | | else { |
|---|
| 138 | | this.log("\t\tUser"+user.getID()+": Die Schlacht "+battleid+" wurde beendet"); |
|---|
| 139 | | |
|---|
| 140 | | battle.endBattle(0, 0, true); |
|---|
| 141 | | PM.send(getContext(), battle.getCommander(battle.getOwnSide()), battle.getCommander(battle.getEnemySide()), "Schlacht beendet", "Die Schlacht bei "+battle.getSystem()+" : "+battle.getX()+"/"+battle.getY()+" wurde automatisch beim wechseln in den Vacation-Modus beendet, da kein Ersatzkommandant ermittelt werden konnte!"); |
|---|
| 142 | | } |
|---|
| 143 | | } |
|---|
| 144 | | battleid.free(); |
|---|
| 145 | | } |
|---|
| 146 | | iter.free(); |
|---|
| 147 | | |
|---|
| 148 | | db.update("UPDATE users SET name=CONCAT(name,' [VAC]'),nickname=CONCAT(nickname,' [VAC]') WHERE wait4vac=1"); |
|---|
| 149 | | this.log("\t"+db.affectedRows()+" Spieler sind in den VAC-Modus gewechselt"); |
|---|
| 150 | | db.update("UPDATE users SET wait4vac=wait4vac-1 WHERE wait4vac>0"); |
|---|
| | 153 | battle.endBattle(0, 0, true); |
|---|
| | 154 | PM.send(getContext(), battle.getCommander(battle.getOwnSide()), battle.getCommander(battle.getEnemySide()), "Schlacht beendet", "Die Schlacht bei "+battle.getSystem()+" : "+battle.getX()+"/"+battle.getY()+" wurde automatisch beim wechseln in den Vacation-Modus beendet, da kein Ersatzkommandant ermittelt werden konnte!"); |
|---|
| | 155 | } |
|---|
| | 156 | } |
|---|
| | 157 | battleid.free(); |
|---|
| | 158 | } |
|---|
| | 159 | iter.free(); |
|---|
| | 160 | |
|---|
| | 161 | db.update("UPDATE users SET name=CONCAT(name,' [VAC]'),nickname=CONCAT(nickname,' [VAC]') WHERE wait4vac=1"); |
|---|
| | 162 | this.log("\t"+db.affectedRows()+" Spieler sind in den VAC-Modus gewechselt"); |
|---|
| | 163 | db.update("UPDATE users SET wait4vac=wait4vac-1 WHERE wait4vac>0"); |
|---|
| | 164 | } |
|---|
| | 165 | catch( Exception e ) { |
|---|
| | 166 | this.log("Fehler beim Verarbeiten der Vacationdaten: "+e); |
|---|
| | 167 | e.printStackTrace(); |
|---|
| | 168 | } |
|---|
| 159 | | Database db = getDatabase(); |
|---|
| 160 | | |
|---|
| 161 | | this.log(""); |
|---|
| 162 | | this.log("Fuege Felsbrocken ein"); |
|---|
| 163 | | |
|---|
| 164 | | int shouldId = 9999; |
|---|
| 165 | | |
|---|
| 166 | | SQLQuery system = db.query("SELECT system,count," + |
|---|
| 167 | | "(SELECT count(*) FROM ships WHERE system=config_felsbrocken_systems.system AND type IN " + |
|---|
| 168 | | " (SELECT shiptype FROM config_felsbrocken WHERE system=config_felsbrocken_systems.system)" + |
|---|
| 169 | | ") present " + |
|---|
| 170 | | "FROM config_felsbrocken_systems ORDER BY system"); |
|---|
| 171 | | while( system.next() ) { |
|---|
| 172 | | int shipcount = system.getInt("present"); |
|---|
| 173 | | |
|---|
| 174 | | this.log("\tSystem "+system.getInt("system")+": "+shipcount+" / "+system.getInt("count")+" Felsbrocken"); |
|---|
| 175 | | |
|---|
| 176 | | if( system.getInt("count") < shipcount ) { |
|---|
| 177 | | continue; |
|---|
| 178 | | } |
|---|
| 179 | | |
|---|
| 180 | | List<SQLResultRow> loadout = new ArrayList<SQLResultRow>(); |
|---|
| 181 | | SQLQuery aLoadOut = db.query("SELECT * FROM config_felsbrocken WHERE system=",system.getInt("system")); |
|---|
| 182 | | while( aLoadOut.next() ) { |
|---|
| 183 | | loadout.add(aLoadOut.getRow()); |
|---|
| 184 | | } |
|---|
| 185 | | aLoadOut.free(); |
|---|
| 186 | | |
|---|
| 187 | | while( shipcount < system.getInt("count") ) { |
|---|
| 188 | | int rnd = RandomUtils.nextInt(100)+1; |
|---|
| 189 | | int currnd = 0; |
|---|
| 190 | | for( int i=0; i < loadout.size(); i++ ) { |
|---|
| 191 | | SQLResultRow aloadout = loadout.get(i); |
|---|
| 192 | | currnd += aloadout.getInt("chance"); |
|---|
| 193 | | |
|---|
| 194 | | if( currnd < rnd ) { |
|---|
| 195 | | continue; |
|---|
| 196 | | } |
|---|
| 197 | | |
|---|
| 198 | | // ID ermitteln |
|---|
| 199 | | shouldId++; |
|---|
| 200 | | shouldId = db.first("SELECT newIntelliShipID( "+shouldId+" ) AS sid").getInt("sid"); |
|---|
| 201 | | |
|---|
| 202 | | // Coords ermitteln |
|---|
| 203 | | int x = RandomUtils.nextInt(Systems.get().system(system.getInt("system")).getWidth())+1; |
|---|
| 204 | | int y = RandomUtils.nextInt(Systems.get().system(system.getInt("system")).getHeight())+1; |
|---|
| 205 | | |
|---|
| 206 | | this.log("\t*System "+system.getInt("system")+": Fuege Felsbrocken "+shouldId+" ein"); |
|---|
| 207 | | |
|---|
| 208 | | // Ladung einfuegen |
|---|
| 209 | | this.log("\t- Loadout: "); |
|---|
| 210 | | Cargo cargo = new Cargo(Cargo.Type.STRING, aloadout.getString("cargo")); |
|---|
| 211 | | ResourceList reslist = cargo.getResourceList(); |
|---|
| 212 | | for( ResourceEntry res : reslist ) { |
|---|
| 213 | | this.log("\t *"+res.getName()+" => "+res.getCount1()); |
|---|
| 214 | | } |
|---|
| 215 | | |
|---|
| 216 | | SQLResultRow shiptype = ShipTypes.getShipType(aloadout.getInt("shiptype"), false); |
|---|
| 217 | | |
|---|
| 218 | | // Schiffseintrag einfuegen |
|---|
| 219 | | db.update("INSERT INTO ships (id,name,type,owner,x,y,system,hull,crew,cargo) ", |
|---|
| 220 | | "VALUES (",shouldId,",'Felsbrocken',",aloadout.getInt("shiptype"),",-1,",x,",",y,",",system.getInt("system"),",",shiptype.getInt("hull"),",",shiptype.getInt("crew"),",'",cargo.save(),"')"); |
|---|
| 221 | | this.log(""); |
|---|
| 222 | | |
|---|
| 223 | | shipcount++; |
|---|
| 224 | | |
|---|
| 225 | | break; |
|---|
| 226 | | } |
|---|
| 227 | | } |
|---|
| | 177 | try { |
|---|
| | 178 | Database db = getDatabase(); |
|---|
| | 179 | |
|---|
| | 180 | this.log(""); |
|---|
| | 181 | this.log("Fuege Felsbrocken ein"); |
|---|
| | 182 | |
|---|
| | 183 | int shouldId = 9999; |
|---|
| | 184 | |
|---|
| | 185 | SQLQuery system = db.query("SELECT system,count," + |
|---|
| | 186 | "(SELECT count(*) FROM ships WHERE system=config_felsbrocken_systems.system AND type IN " + |
|---|
| | 187 | " (SELECT shiptype FROM config_felsbrocken WHERE system=config_felsbrocken_systems.system)" + |
|---|
| | 188 | ") present " + |
|---|
| | 189 | "FROM config_felsbrocken_systems ORDER BY system"); |
|---|
| | 190 | while( system.next() ) { |
|---|
| | 191 | int shipcount = system.getInt("present"); |
|---|
| | 192 | |
|---|
| | 193 | this.log("\tSystem "+system.getInt("system")+": "+shipcount+" / "+system.getInt("count")+" Felsbrocken"); |
|---|
| | 194 | |
|---|
| | 195 | if( system.getInt("count") < shipcount ) { |
|---|
| | 196 | continue; |
|---|
| | 197 | } |
|---|
| | 198 | |
|---|
| | 199 | List<SQLResultRow> loadout = new ArrayList<SQLResultRow>(); |
|---|
| | 200 | SQLQuery aLoadOut = db.query("SELECT * FROM config_felsbrocken WHERE system=",system.getInt("system")); |
|---|
| | 201 | while( aLoadOut.next() ) { |
|---|
| | 202 | loadout.add(aLoadOut.getRow()); |
|---|
| | 203 | } |
|---|
| | 204 | aLoadOut.free(); |
|---|
| | 205 | |
|---|
| | 206 | while( shipcount < system.getInt("count") ) { |
|---|
| | 207 | int rnd = RandomUtils.nextInt(100)+1; |
|---|
| | 208 | int currnd = 0; |
|---|
| | 209 | for( int i=0; i < loadout.size(); i++ ) { |
|---|
| | 210 | SQLResultRow aloadout = loadout.get(i); |
|---|
| | 211 | currnd += aloadout.getInt("chance"); |
|---|
| | 212 | |
|---|
| | 213 | if( currnd < rnd ) { |
|---|
| | 214 | continue; |
|---|
| | 215 | } |
|---|
| | 216 | |
|---|
| | 217 | // ID ermitteln |
|---|
| | 218 | shouldId++; |
|---|
| | 219 | shouldId = db.first("SELECT newIntelliShipID( "+shouldId+" ) AS sid").getInt("sid"); |
|---|
| | 220 | |
|---|
| | 221 | // Coords ermitteln |
|---|
| | 222 | int x = RandomUtils.nextInt(Systems.get().system(system.getInt("system")).getWidth())+1; |
|---|
| | 223 | int y = RandomUtils.nextInt(Systems.get().system(system.getInt("system")).getHeight())+1; |
|---|
| | 224 | |
|---|
| | 225 | this.log("\t*System "+system.getInt("system")+": Fuege Felsbrocken "+shouldId+" ein"); |
|---|
| | 226 | |
|---|
| | 227 | // Ladung einfuegen |
|---|
| | 228 | this.log("\t- Loadout: "); |
|---|
| | 229 | Cargo cargo = new Cargo(Cargo.Type.STRING, aloadout.getString("cargo")); |
|---|
| | 230 | ResourceList reslist = cargo.getResourceList(); |
|---|
| | 231 | for( ResourceEntry res : reslist ) { |
|---|
| | 232 | this.log("\t *"+res.getName()+" => "+res.getCount1()); |
|---|
| | 233 | } |
|---|
| | 234 | |
|---|
| | 235 | SQLResultRow shiptype = ShipTypes.getShipType(aloadout.getInt("shiptype"), false); |
|---|
| | 236 | |
|---|
| | 237 | // Schiffseintrag einfuegen |
|---|
| | 238 | db.update("INSERT INTO ships (id,name,type,owner,x,y,system,hull,crew,cargo) ", |
|---|
| | 239 | "VALUES (",shouldId,",'Felsbrocken',",aloadout.getInt("shiptype"),",-1,",x,",",y,",",system.getInt("system"),",",shiptype.getInt("hull"),",",shiptype.getInt("crew"),",'",cargo.save(),"')"); |
|---|
| | 240 | this.log(""); |
|---|
| | 241 | |
|---|
| | 242 | shipcount++; |
|---|
| | 243 | |
|---|
| | 244 | break; |
|---|
| | 245 | } |
|---|
| | 246 | } |
|---|
| | 247 | } |
|---|
| | 248 | } |
|---|
| | 249 | catch( Exception e ) { |
|---|
| | 250 | this.log("Fehler beim Erstellen der Felsbrocken: "+e); |
|---|
| | 251 | e.printStackTrace(); |
|---|
| 235 | | Database db = getContext().getDatabase(); |
|---|
| 236 | | |
|---|
| 237 | | this.log("Bearbeite Quests [ontick]"); |
|---|
| 238 | | SQLQuery rquest = db.query("SELECT * FROM quests_running WHERE ontick IS NOT NULL ORDER BY questid"); |
|---|
| 239 | | if( rquest.numRows() == 0 ) { |
|---|
| | 259 | try { |
|---|
| | 260 | Database db = getContext().getDatabase(); |
|---|
| | 261 | |
|---|
| | 262 | this.log("Bearbeite Quests [ontick]"); |
|---|
| | 263 | SQLQuery rquest = db.query("SELECT * FROM quests_running WHERE ontick IS NOT NULL ORDER BY questid"); |
|---|
| | 264 | if( rquest.numRows() == 0 ) { |
|---|
| | 265 | rquest.free(); |
|---|
| | 266 | return; |
|---|
| | 267 | } |
|---|
| | 268 | ScriptParser scriptparser = getContext().get(ContextCommon.class).getScriptParser(ScriptParser.NameSpace.QUEST); |
|---|
| | 269 | scriptparser.setLogFunction(ScriptParser.LOGGER_NULL); |
|---|
| | 270 | |
|---|
| | 271 | while( rquest.next() ) { |
|---|
| | 272 | scriptparser.cleanup(); |
|---|
| | 273 | try { |
|---|
| | 274 | Blob execdata = rquest.getBlob("execdata"); |
|---|
| | 275 | if( (execdata != null) && (execdata.length() > 0) ) { |
|---|
| | 276 | scriptparser.setContext(ScriptParserContext.fromStream(execdata.getBinaryStream())); |
|---|
| | 277 | } |
|---|
| | 278 | else { |
|---|
| | 279 | scriptparser.setContext(new ScriptParserContext()); |
|---|
| | 280 | } |
|---|
| | 281 | |
|---|
| | 282 | this.log("* quest: "+rquest.getInt("questid")+" - user:"+rquest.getInt("userid")+" - script: "+rquest.getInt("ontick")); |
|---|
| | 283 | |
|---|
| | 284 | String script = db.first("SELECT script FROM scripts WHERE id='"+rquest.getInt("ontick")+"'").getString("script"); |
|---|
| | 285 | scriptparser.setRegister("USER", Integer.toString(rquest.getInt("userid")) ); |
|---|
| | 286 | scriptparser.setRegister("QUEST", "r"+rquest.getInt("id")); |
|---|
| | 287 | scriptparser.setRegister("SCRIPT", Integer.toString(rquest.getInt("ontick")) ); |
|---|
| | 288 | scriptparser.executeScript(db, script, "0"); |
|---|
| | 289 | |
|---|
| | 290 | int usequest = Integer.parseInt(scriptparser.getRegister("QUEST")); |
|---|
| | 291 | |
|---|
| | 292 | if( usequest != 0 ) { |
|---|
| | 293 | scriptparser.getContext().toStream(execdata.setBinaryStream(1)); |
|---|
| | 294 | db.prepare("UPDATE quests_running SET execdata=? WHERE id=? ") |
|---|
| | 295 | .update(execdata, rquest.getInt("id")); |
|---|
| | 296 | } |
|---|
| | 297 | } |
|---|
| | 298 | catch( Exception e ) { |
|---|
| | 299 | this.log("[FEHLER] Konnte Quest-Tick fuehr Quest "+rquest.getInt("questid")+" (Running-ID: "+rquest.getInt("id")+") nicht ausfuehren."+e); |
|---|
| | 300 | e.printStackTrace(); |
|---|
| | 301 | } |
|---|
| | 302 | } |
|---|
| 241 | | return; |
|---|
| 242 | | } |
|---|
| 243 | | ScriptParser scriptparser = getContext().get(ContextCommon.class).getScriptParser(ScriptParser.NameSpace.QUEST); |
|---|
| 244 | | scriptparser.setLogFunction(ScriptParser.LOGGER_NULL); |
|---|
| 245 | | |
|---|
| 246 | | while( rquest.next() ) { |
|---|
| 247 | | scriptparser.cleanup(); |
|---|
| 248 | | try { |
|---|
| 249 | | Blob execdata = rquest.getBlob("execdata"); |
|---|
| 250 | | if( (execdata != null) && (execdata.length() > 0) ) { |
|---|
| 251 | | scriptparser.setContext(ScriptParserContext.fromStream(execdata.getBinaryStream())); |
|---|
| 252 | | } |
|---|
| 253 | | else { |
|---|
| 254 | | scriptparser.setContext(new ScriptParserContext()); |
|---|
| 255 | | } |
|---|
| 256 | | |
|---|
| 257 | | this.log("* quest: "+rquest.getInt("questid")+" - user:"+rquest.getInt("userid")+" - script: "+rquest.getInt("ontick")); |
|---|
| 258 | | |
|---|
| 259 | | String script = db.first("SELECT script FROM scripts WHERE id='"+rquest.getInt("ontick")+"'").getString("script"); |
|---|
| 260 | | scriptparser.setRegister("USER", Integer.toString(rquest.getInt("userid")) ); |
|---|
| 261 | | scriptparser.setRegister("QUEST", "r"+rquest.getInt("id")); |
|---|
| 262 | | scriptparser.setRegister("SCRIPT", Integer.toString(rquest.getInt("ontick")) ); |
|---|
| 263 | | scriptparser.executeScript(db, script, "0"); |
|---|
| 264 | | |
|---|
| 265 | | int usequest = Integer.parseInt(scriptparser.getRegister("QUEST")); |
|---|
| 266 | | |
|---|
| 267 | | if( usequest != 0 ) { |
|---|
| 268 | | scriptparser.getContext().toStream(execdata.setBinaryStream(1)); |
|---|
| 269 | | db.prepare("UPDATE quests_running SET execdata=? WHERE id=? ") |
|---|
| 270 | | .update(execdata, rquest.getInt("id")); |
|---|
| 271 | | } |
|---|
| 272 | | } |
|---|
| 273 | | catch( Exception e ) { |
|---|
| 274 | | this.log("[FEHLER] Konnte Quest-Tick fuehr Quest "+rquest.getInt("questid")+" (Running-ID: "+rquest.getInt("id")+") nicht ausfuehren."+e); |
|---|
| 275 | | e.printStackTrace(); |
|---|
| 276 | | } |
|---|
| 277 | | } |
|---|
| 278 | | rquest.free(); |
|---|
| | 304 | } |
|---|
| | 305 | catch( Exception e ) { |
|---|
| | 306 | this.log("Fehler beim Verarbeiten der Quests: "+e); |
|---|
| | 307 | e.printStackTrace(); |
|---|
| | 308 | } |
|---|