Changeset 87d912c69bd66466c4a36d55b794ca8a4416d8dc
- Timestamp:
- 09/09/07 12:44:35
(1 year ago)
- Author:
- Christopher Jung <bktheg@web.de>
- git-committer:
- Christopher Jung <bktheg@web.de> 1189334675 +0200
- git-parent:
[db473d3c0a40953e37799bcb1a0a00df229a7138]
- git-author:
- Christopher Jung <bktheg@web.de> 1189334675 +0200
- Message:
Uebersicht: Teilweise Umstellung auf Hibernate
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r4b6814a |
r87d912c |
|
| 28 | 28 | |
|---|
| 29 | 29 | import net.driftingsouls.ds2.server.ContextCommon; |
|---|
| 30 | | import net.driftingsouls.ds2.server.Location; |
|---|
| 31 | 30 | import net.driftingsouls.ds2.server.bases.Base; |
|---|
| 32 | 31 | import net.driftingsouls.ds2.server.bases.BaseStatus; |
|---|
| … | … | |
| 36 | 35 | import net.driftingsouls.ds2.server.cargo.Resources; |
|---|
| 37 | 36 | import net.driftingsouls.ds2.server.config.Rassen; |
|---|
| | 37 | import net.driftingsouls.ds2.server.entities.Ally; |
|---|
| | 38 | import net.driftingsouls.ds2.server.entities.IntTutorial; |
|---|
| 38 | 39 | import net.driftingsouls.ds2.server.entities.User; |
|---|
| 39 | 40 | import net.driftingsouls.ds2.server.entities.UserFlagschiffLocation; |
|---|
| … | … | |
| 51 | 52 | import net.driftingsouls.ds2.server.scripting.ScriptParser; |
|---|
| 52 | 53 | import net.driftingsouls.ds2.server.scripting.ScriptParserContext; |
|---|
| | 54 | import net.driftingsouls.ds2.server.scripting.entities.RunningQuest; |
|---|
| 53 | 55 | import net.driftingsouls.ds2.server.ships.Ship; |
|---|
| | 56 | import net.driftingsouls.ds2.server.ships.ShipFleet; |
|---|
| 54 | 57 | import net.driftingsouls.ds2.server.ships.ShipTypeData; |
|---|
| 55 | 58 | import net.driftingsouls.ds2.server.ships.Ships; |
|---|
| | 59 | import net.driftingsouls.ds2.server.werften.WerftObject; |
|---|
| | 60 | import net.driftingsouls.ds2.server.werften.WerftQueueEntry; |
|---|
| 56 | 61 | |
|---|
| 57 | 62 | /** |
|---|
| … | … | |
| 146 | 151 | @Action(ActionType.DEFAULT) |
|---|
| 147 | 152 | public void stopQuestAction() { |
|---|
| 148 | | Database db = getDatabase(); |
|---|
| | 153 | org.hibernate.Session db = getDB(); |
|---|
| 149 | 154 | |
|---|
| 150 | 155 | parameterNumber("questid"); |
|---|
| 151 | 156 | int questid = getInteger("questid"); |
|---|
| 152 | 157 | |
|---|
| 153 | | SQLQuery questdata = db.query("SELECT * FROM quests_running WHERE id='",questid,"'"); |
|---|
| 154 | | if( !questdata.next() || (questdata.getInt("userid") != getUser().getID()) ) { |
|---|
| 155 | | questdata.free(); |
|---|
| | 158 | RunningQuest questdata = (RunningQuest)db.get(RunningQuest.class, questid); |
|---|
| | 159 | if( (questdata == null) || (questdata.getUser().getID() != getUser().getID()) ) { |
|---|
| 156 | 160 | addError("Sie können dieses Quest nicht abbrechen"); |
|---|
| 157 | 161 | redirect(); |
|---|
| … | … | |
| 165 | 169 | |
|---|
| 166 | 170 | try { |
|---|
| 167 | | Blob execdata = questdata.getBlob("execdata"); |
|---|
| | 171 | Blob execdata = questdata.getExecData(); |
|---|
| 168 | 172 | if( (execdata != null) && (execdata.length() > 0) ) { |
|---|
| 169 | 173 | scriptparser.setContext(ScriptParserContext.fromStream(execdata.getBinaryStream())); |
|---|
| … | … | |
| 177 | 181 | scriptparser.setRegister("USER", Integer.toString(getUser().getID())); |
|---|
| 178 | 182 | scriptparser.setRegister("QUEST", "r"+questid); |
|---|
| 179 | | scriptparser.executeScript(db, ":0\n!ENDQUEST\n!QUIT","0"); |
|---|
| 180 | | |
|---|
| 181 | | questdata.free(); |
|---|
| | 183 | scriptparser.executeScript(getDatabase(), ":0\n!ENDQUEST\n!QUIT","0"); |
|---|
| 182 | 184 | |
|---|
| 183 | 185 | redirect(); |
|---|
| … | … | |
| 190 | 192 | @Action(ActionType.DEFAULT) |
|---|
| 191 | 193 | public void defaultAction() { |
|---|
| 192 | | Database db = getDatabase(); |
|---|
| | 194 | Database database = getDatabase(); |
|---|
| | 195 | org.hibernate.Session db = getDB(); |
|---|
| 193 | 196 | User user = (User)getUser(); |
|---|
| 194 | 197 | TemplateEngine t = getTemplateEngine(); |
|---|
| … | … | |
| 223 | 226 | |
|---|
| 224 | 227 | // Gibt es eine Umfrage an der wir teilnehmen koennen |
|---|
| 225 | | SQLResultRow survey = db.prepare("SELECT * FROM surveys WHERE enabled='1' AND minid<=? AND maxid>=? AND ", |
|---|
| | 228 | SQLResultRow survey = database.prepare("SELECT * FROM surveys WHERE enabled='1' AND minid<=? AND maxid>=? AND ", |
|---|
| 226 | 229 | " mintime<=? AND maxtime>=? AND timeout>0") |
|---|
| 227 | 230 | .first(user.getID(), user.getID(), user.getSignup(), user.getSignup()); |
|---|
| 228 | 231 | |
|---|
| 229 | 232 | if( !survey.isEmpty() ) { |
|---|
| 230 | | SQLResultRow voted = db.prepare("SELECT * FROM survey_voted WHERE survey_id=? AND user_id=?") |
|---|
| | 233 | SQLResultRow voted = database.prepare("SELECT * FROM survey_voted WHERE survey_id=? AND user_id=?") |
|---|
| 231 | 234 | .first(survey.getInt("id"), user.getID()); |
|---|
| 232 | 235 | |
|---|
| … | … | |
| 240 | 243 | switch( flagschiff.getType() ) { |
|---|
| 241 | 244 | case SHIP: |
|---|
| 242 | | SQLResultRow ship = db.prepare("SELECT id,name FROM ships WHERE id>0 AND id=?").first(flagschiff.getID()); |
|---|
| 243 | | if( ship.isEmpty() ) { |
|---|
| | 245 | Ship ship = (Ship)db.get(Ship.class, flagschiff.getID()); |
|---|
| | 246 | if( ship == null ) { |
|---|
| 244 | 247 | user.setFlagschiff(null); |
|---|
| 245 | 248 | } |
|---|
| 246 | 249 | else { |
|---|
| 247 | 250 | t.set_var( "flagschiff.id", flagschiff.getID(), |
|---|
| 248 | | "flagschiff.name", ship.getString("name") ) ; |
|---|
| | 251 | "flagschiff.name", ship.getName() ) ; |
|---|
| 249 | 252 | } |
|---|
| 250 | 253 | break; |
|---|
| 251 | 254 | |
|---|
| 252 | | case WERFT_SHIP: |
|---|
| 253 | | int dauer = db.first("SELECT remaining FROM werften WHERE shipid=",flagschiff.getID()).getInt("remaining"); |
|---|
| 254 | | t.set_var("flagschiff.dauer",dauer); |
|---|
| | 255 | case WERFT_SHIP: { |
|---|
| | 256 | WerftObject werft = (WerftObject)db.createQuery("from ShipWerft where ship=?") |
|---|
| | 257 | .setInteger(0, flagschiff.getID()) |
|---|
| | 258 | .uniqueResult(); |
|---|
| | 259 | WerftQueueEntry[] entries = werft.getBuildQueue(); |
|---|
| | 260 | for( int i=0; i < entries.length; i++ ) { |
|---|
| | 261 | if( entries[i].isBuildFlagschiff() ) { |
|---|
| | 262 | t.set_var("flagschiff.dauer", werft.getTicksTillFinished(entries[i])); |
|---|
| | 263 | break; |
|---|
| | 264 | } |
|---|
| | 265 | } |
|---|
| | 266 | |
|---|
| 255 | 267 | break; |
|---|
| 256 | | |
|---|
| 257 | | case WERFT_BASE: |
|---|
| 258 | | dauer = db.first("SELECT remaining FROM werften WHERE col=",flagschiff.getID()).getInt("remaining"); |
|---|
| 259 | | t.set_var("flagschiff.dauer",dauer); |
|---|
| | 268 | } |
|---|
| | 269 | case WERFT_BASE: { |
|---|
| | 270 | WerftObject werft = (WerftObject)db.createQuery("from BaseWerft where base=?") |
|---|
| | 271 | .setInteger(0, flagschiff.getID()) |
|---|
| | 272 | .uniqueResult(); |
|---|
| | 273 | WerftQueueEntry[] entries = werft.getBuildQueue(); |
|---|
| | 274 | for( int i=0; i < entries.length; i++ ) { |
|---|
| | 275 | if( entries[i].isBuildFlagschiff() ) { |
|---|
| | 276 | t.set_var("flagschiff.dauer", werft.getTicksTillFinished(entries[i])); |
|---|
| | 277 | break; |
|---|
| | 278 | } |
|---|
| | 279 | } |
|---|
| 260 | 280 | break; |
|---|
| | 281 | } |
|---|
| 261 | 282 | } |
|---|
| 262 | 283 | } |
|---|
| … | … | |
| 274 | 295 | //------------------------------ |
|---|
| 275 | 296 | |
|---|
| 276 | | int newCount = db.first("SELECT count(*) newmsgs FROM transmissionen WHERE empfaenger=",user.getID()," AND gelesen=0").getInt("newmsgs"); |
|---|
| | 297 | long newCount = (Long)db.createQuery("select count(*) from PM where empfaenger= :user and gelesen=0") |
|---|
| | 298 | .setEntity("user", user) |
|---|
| | 299 | .iterate().next(); |
|---|
| 277 | 300 | t.set_var("user.newmsgs", Common.ln(newCount)); |
|---|
| 278 | 301 | |
|---|
| … | … | |
| 316 | 339 | //------------------------------ |
|---|
| 317 | 340 | |
|---|
| 318 | | int sw = 0; |
|---|
| 319 | | int shipNoCrew = 0; |
|---|
| 320 | | |
|---|
| 321 | | sw = db.prepare("SELECT count(*) `count` ", |
|---|
| 322 | | "FROM ships ", |
|---|
| 323 | | "WHERE id>0 AND owner=? AND (LOCATE('mangel_nahrung',status) OR LOCATE('mangel_reaktor',status)) AND NOT LOCATE('nocrew',status) ORDER BY id") |
|---|
| 324 | | .first(user.getID()) |
|---|
| 325 | | .getInt("count"); |
|---|
| 326 | | |
|---|
| 327 | | shipNoCrew = db.prepare("SELECT count(id) `count` FROM ships ", |
|---|
| 328 | | "WHERE id>0 AND owner=? AND LOCATE('nocrew',status)" ) |
|---|
| 329 | | .first(user.getID()) |
|---|
| 330 | | .getInt("count"); |
|---|
| | 341 | long sw = 0; |
|---|
| | 342 | long shipNoCrew = 0; |
|---|
| | 343 | |
|---|
| | 344 | sw = (Long)db.createQuery("select count(*) " + |
|---|
| | 345 | "from Ship " + |
|---|
| | 346 | "where id>0 and owner= :user and (locate('mangel_nahrung',status)!=0 or locate('mangel_reaktor',status)!=0) and locate('nocrew',status)=0") |
|---|
| | 347 | .setEntity("user", user) |
|---|
| | 348 | .iterate().next(); |
|---|
| | 349 | |
|---|
| | 350 | shipNoCrew = (Long)db.createQuery("select count(*) from Ship " + |
|---|
| | 351 | "where id>0 and owner= :user and locate('nocrew',status)!=0" ) |
|---|
| | 352 | .setEntity("user", user) |
|---|
| | 353 | .iterate().next(); |
|---|
| 331 | 354 | |
|---|
| 332 | 355 | String nstat = "0"; |
|---|
| … | … | |
| 355 | 378 | SQLQuery battle = null; |
|---|
| 356 | 379 | if( user.getAlly() != null ) { |
|---|
| 357 | | battle = db.query("SELECT * FROM battles WHERE commander1=",user.getID()," OR commander2=",user.getID()," OR ally1=",user.getAlly().getId()," OR ally2=",user.getAlly().getId()); |
|---|
| | 380 | battle = database.query("SELECT * FROM battles WHERE commander1=",user.getID()," OR commander2=",user.getID()," OR ally1=",user.getAlly().getId()," OR ally2=",user.getAlly().getId()); |
|---|
| 358 | 381 | } |
|---|
| 359 | 382 | else { |
|---|
| 360 | | battle = db.query("SELECT * FROM battles WHERE commander1=",user.getID()," OR commander2=",user.getID()); |
|---|
| | 383 | battle = database.query("SELECT * FROM battles WHERE commander1=",user.getID()," OR commander2=",user.getID()); |
|---|
| 361 | 384 | } |
|---|
| 362 | 385 | |
|---|
| … | … | |
| 376 | 399 | ((user.getAlly() != null) && (battle.getInt("ally1") != user.getAlly().getId()) ) ) { |
|---|
| 377 | 400 | if( battle.getInt("ally1") == 0 ) { |
|---|
| 378 | | final User commander1 = (User)getContext().getDB().get(User.class, battle.getInt("commander1")); |
|---|
| | 401 | final User commander1 = (User)db.get(User.class, battle.getInt("commander1")); |
|---|
| 379 | 402 | eparty = Common._title(commander1.getName()); |
|---|
| 380 | 403 | } |
|---|
| 381 | 404 | else { |
|---|
| 382 | | eparty = Common._title( |
|---|
| 383 | | db.first("SELECT name FROM ally WHERE id=",battle.getInt("ally1")) |
|---|
| 384 | | .getString("name")); |
|---|
| | 405 | final Ally ally = (Ally)db.get(Ally.class, battle.getInt("ally1")); |
|---|
| | 406 | eparty = Common._title(ally.getName()); |
|---|
| 385 | 407 | } |
|---|
| 386 | 408 | |
|---|
| 387 | | final User commander2 = (User)getContext().getDB().get(User.class, battle.getInt("commander2")); |
|---|
| | 409 | final User commander2 = (User)db.get(User.class, battle.getInt("commander2")); |
|---|
| 388 | 410 | comm = Common._title(commander2.getName()); |
|---|
| 389 | 411 | } |
|---|
| 390 | 412 | else { |
|---|
| 391 | 413 | if( battle.getInt("ally2") == 0 ) { |
|---|
| 392 | | final User commander2 = (User)getContext().getDB().get(User.class, battle.getInt("commander2")); |
|---|
| | 414 | final User commander2 = (User)db.get(User.class, battle.getInt("commander2")); |
|---|
| 393 | 415 | eparty = Common._title(commander2.getName()); |
|---|
| 394 | 416 | } |
|---|
| 395 | 417 | else { |
|---|
| 396 | | eparty = Common._title( |
|---|
| 397 | | db.first("SELECT name FROM ally WHERE id=",battle.getInt("ally2")) |
|---|
| 398 | | .getString("name")); |
|---|
| | 418 | final Ally ally = (Ally)db.get(Ally.class, battle.getInt("ally2")); |
|---|
| | 419 | eparty = Common._title(ally.getName()); |
|---|
| 399 | 420 | } |
|---|
| 400 | 421 | |
|---|
| 401 | | final User commander1 = (User)getContext().getDB().get(User.class, battle.getInt("commander1")); |
|---|
| | 422 | final User commander1 = (User)db.get(User.class, battle.getInt("commander1")); |
|---|
| 402 | 423 | comm = Common._title(commander1.getName()); |
|---|
| 403 | 424 | } |
|---|
| … | … | |
| 417 | 438 | //Nun alle Schlachten auflisten, wo der Spieler Schiffe drin hat (die aber noch nicht aufgelistet wurden) - oder zeige alle Schlachten an, wenn es jemand mit entsprechenden Rechten ist |
|---|
| 418 | 439 | if( (user.getAccessLevel() < 20) && user.hasFlag(User.FLAG_QUEST_BATTLES) ) { |
|---|
| 419 | | battle = db.query("SELECT * FROM battles WHERE (quest IS NOT NULL AND (commander1<0 XOR commander2<0)) OR (commander1=",user.getID(),") OR (commander2=",user.getID(),")"); |
|---|
| | 440 | battle = database.query("SELECT * FROM battles WHERE (quest IS NOT NULL AND (commander1<0 XOR commander2<0)) OR (commander1=",user.getID(),") OR (commander2=",user.getID(),")"); |
|---|
| 420 | 441 | } |
|---|
| 421 | 442 | else if( (user.getAccessLevel() >= 20) || user.hasFlag(User.FLAG_VIEW_BATTLES) ) { |
|---|
| 422 | | battle = db.query("SELECT * FROM battles"); |
|---|
| | 443 | battle = database.query("SELECT * FROM battles"); |
|---|
| 423 | 444 | } |
|---|
| 424 | 445 | else { |
|---|
| 425 | 446 | battlelist.append("<br />\n"); |
|---|
| 426 | | battle = db.query("SELECT t1.* ", |
|---|
| | 447 | battle = database.query("SELECT t1.* ", |
|---|
| 427 | 448 | "FROM battles t1,ships t2 ", |
|---|
| 428 | 449 | "WHERE t2.id>0 AND t2.owner=",user.getID()," AND t2.battle=t1.id ",(!battleidlist.isEmpty() ? "AND !(t2.battle IN ("+Common.implode(",",battleidlist)+"))":"")," ", |
|---|
| … | … | |
| 437 | 458 | String eparty2 = ""; |
|---|
| 438 | 459 | if( battle.getInt("ally1") == 0 ) { |
|---|
| 439 | | final User commander1 = (User)getContext().getDB().get(User.class, battle.getInt("commander1")); |
|---|
| | 460 | final User commander1 = (User)db.get(User.class, battle.getInt("commander1")); |
|---|
| 440 | 461 | eparty = Common._title(commander1.getName()); |
|---|
| 441 | 462 | } |
|---|
| 442 | 463 | else { |
|---|
| 443 | | eparty = Common._title( |
|---|
| 444 | | db.first("SELECT name FROM ally WHERE id=",battle.getInt("ally1")) |
|---|
| 445 | | .getString("name")); |
|---|
| 446 | | } |
|---|
| 447 | | |
|---|
| 448 | | final User commander1 = (User)getContext().getDB().get(User.class, battle.getInt("commander1")); |
|---|
| | 464 | final Ally ally = (Ally)db.get(Ally.class, battle.getInt("ally1")); |
|---|
| | 465 | eparty = Common._title(ally.getName()); |
|---|
| | 466 | } |
|---|
| | 467 | |
|---|
| | 468 | final User commander1 = (User)db.get(User.class, battle.getInt("commander1")); |
|---|
| 449 | 469 | String comm1 = Common._title(commander1.getName()); |
|---|
| 450 | 470 | |
|---|
| 451 | 471 | if( battle.getInt("ally2") == 0 ) { |
|---|
| 452 | | final User commander2 = (User)getContext().getDB().get(User.class, battle.getInt("commander2")); |
|---|
| | 472 | final User commander2 = (User)db.get(User.class, battle.getInt("commander2")); |
|---|
| 453 | 473 | eparty2 = Common._title(commander2.getName()); |
|---|
| 454 | 474 | } |
|---|
| 455 | 475 | else { |
|---|
| 456 | | eparty2 = Common._title( |
|---|
| 457 | | db.first("SELECT name FROM ally WHERE id=",battle.getInt("ally2")) |
|---|
| 458 | | .getString("name")); |
|---|
| 459 | | } |
|---|
| 460 | | |
|---|
| 461 | | final User commander2 = (User)getContext().getDB().get(User.class, battle.getInt("commander2")); |
|---|
| | 476 | final Ally ally = (Ally)db.get(Ally.class, battle.getInt("ally2")); |
|---|
| | 477 | eparty2 = Common._title(ally.getName()); |
|---|
| | 478 | } |
|---|
| | 479 | |
|---|
| | 480 | final User commander2 = (User)db.get(User.class, battle.getInt("commander2")); |
|---|
| 462 | 481 | String comm2 = Common._title(commander2.getName()); |
|---|
| 463 | 482 | |
|---|
| … | … | |
| 466 | 485 | if( ( (user.getAccessLevel() >= 20) || user.hasFlag(User.FLAG_QUEST_BATTLES) ) |
|---|
| 467 | 486 | && (battle.getInt("quest") != 0) ) { |
|---|
| 468 | | String questname = db.first("SELECT t2.name FROM quests_running t1, quests t2 WHERE t1.id='",battle.getInt("quest"),"' AND t1.questid=t2.id").getString("name"); |
|---|
| 469 | | battlelist.append("* [Quest: "+questname+"]<br />\n"); |
|---|
| | 487 | RunningQuest quest = (RunningQuest)db.get(RunningQuest.class, battle.getInt("quest")); |
|---|
| | 488 | battlelist.append("* [Quest: "+quest.getQuest().getName()+"]<br />\n"); |
|---|
| 470 | 489 | } |
|---|
| 471 | 490 | |
|---|
| … | … | |
| 487 | 506 | //------------------------------ |
|---|
| 488 | 507 | |
|---|
| 489 | | int shipcount = db.first("SELECT count(*) `count` FROM ships WHERE id>0 AND owner='",user.getID(),"'").getInt("count"); |
|---|
| | 508 | long shipcount = (Long)db.createQuery("select count(*) from Ship " + |
|---|
| | 509 | "where id>0 and owner= :user") |
|---|
| | 510 | .setEntity("user", user) |
|---|
| | 511 | .iterate().next(); |
|---|
| | 512 | |
|---|
| 490 | 513 | int inttutorial = Integer.parseInt(user.getUserValue("TBLORDER/uebersicht/inttutorial")); |
|---|
| 491 | 514 | |
|---|
| … | … | |
| 516 | 539 | } |
|---|
| 517 | 540 | |
|---|
| 518 | | SQLResultRow sheet = db.first("SELECT id,headimg,text FROM inttutorial WHERE id='",inttutorial,"' AND reqname='",(reqname ? 1 : 0),"' AND reqbase='",(reqbase ? 1 : 0),"' AND reqship='",(reqship ? 1 : 0),"'"); |
|---|
| | 541 | IntTutorial sheet = (IntTutorial)db.createQuery("from IntTutorial where id= :id and reqName= :reqname and reqBase= :reqbase and reqShip= :reqship") |
|---|
| | 542 | .setInteger("id", inttutorial) |
|---|
| | 543 | .setInteger("reqname", reqname ? 1 : 0) |
|---|
| | 544 | .setInteger("reqbase", reqbase ? 1 : 0) |
|---|
| | 545 | .setInteger("reqship", reqship ? 1 : 0) |
|---|
| | 546 | .uniqueResult(); |
|---|
| 519 | 547 | |
|---|
| 520 | 548 | // Ist die aktuelle Tutorialseite veraltet? |
|---|
| 521 | | if( sheet.isEmpty() || (sheet.getInt("id") != inttutorial) ) { |
|---|
| 522 | | sheet = db.first("SELECT id,headimg,text FROM inttutorial WHERE reqname='",(reqname ? 1 : 0),"' AND reqbase='",(reqbase ? 1 : 0),"' AND reqship='",(reqship ? 1 : 0),"' ORDER BY id"); |
|---|
| 523 | | |
|---|
| | 549 | if( (sheet == null) || (sheet.getId() != inttutorial) ) { |
|---|
| | 550 | sheet = (IntTutorial)db.createQuery("from IntTutorial where reqName= :reqname and reqBase= :reqbase and reqShip= :reqship order by id") |
|---|
| | 551 | .setInteger("reqname", reqname ? 1 : 0) |
|---|
| | 552 | .setInteger("reqbase", reqbase ? 1 : 0) |
|---|
| | 553 | .setInteger("reqship", reqship ? 1 : 0) |
|---|
| | 554 | .setMaxResults(1) |
|---|
| | 555 | .uniqueResult(); |
|---|
| | 556 | |
|---|
| 524 | 557 | // Neue Tutorialseite speichern |
|---|
| 525 | | inttutorial = sheet.getInt("id"); |
|---|
| | 558 | inttutorial = sheet.getId(); |
|---|
| 526 | 559 | user.setUserValue("TBLORDER/uebersicht/inttutorial", Integer.toString(inttutorial)); |
|---|
| 527 | 560 | } |
|---|
| 528 | 561 | |
|---|
| 529 | 562 | // Existiert eine Nachfolgerseite? |
|---|
| 530 | | SQLResultRow nextsheet = db.first("SELECT id,headimg,text FROM inttutorial WHERE reqsheet='",inttutorial,"' AND reqname='",(reqname ? 1 : 0),"' AND reqbase='",(reqbase ? 1 : 0),"' AND reqship='",(reqship ? 1 : 0),"'"); |
|---|
| | 563 | IntTutorial nextsheet = (IntTutorial)db.createQuery("from IntTutorial where reqSheet= :reqsheet and reqName= :reqname and reqBase= :reqbase and reqShip= :reqship") |
|---|
| | 564 | .setInteger("reqsheet", sheet.getId()) |
|---|
| | 565 | .setInteger("reqname", reqname ? 1 : 0) |
|---|
| | 566 | .setInteger("reqbase", reqbase ? 1 : 0) |
|---|
| | 567 | .setInteger("reqship", reqship ? 1 : 0) |
|---|
| | 568 | .setMaxResults(1) |
|---|
| | 569 | .uniqueResult(); |
|---|
| 531 | 570 | |
|---|
| 532 | 571 | // Kann das Tutorial jetzt beendet werden? |
|---|
| 533 | | if( nextsheet.isEmpty() && reqname && reqship && reqbase ) { |
|---|
| | 572 | if( (nextsheet == null) && reqname && reqship && reqbase ) { |
|---|
| 534 | 573 | t.set_var("sheet.endtutorial",1); |
|---|
| 535 | 574 | } |
|---|
| 536 | | else if( !nextsheet.isEmpty() ) { |
|---|
| | 575 | else if( nextsheet != null ) { |
|---|
| 537 | 576 | t.set_var("sheet.nextsheet",1); |
|---|
| 538 | 577 | } |
|---|
| 539 | 578 | |
|---|
| 540 | 579 | t.set_var( "interactivetutorial.show", 1, |
|---|
| 541 | | "sheet.headpic", sheet.getString("headimg"), |
|---|
| 542 | | "sheet.text", Common._text(sheet.getString("text")) ); |
|---|
| | 580 | "sheet.headpic", sheet.getHeadImg(), |
|---|
| | 581 | "sheet.text", Common._text(sheet.getText()) ); |
|---|
| 543 | 582 | } |
|---|
| 544 | 583 | |
|---|
| … | … | |
| 555 | 594 | t.set_var("show.bookmarks",1); |
|---|
| 556 | 595 | |
|---|
| 557 | | List bookmarks = getDB().createQuery("from Ship where id>0 and bookmark=1 and owner=? order by id desc") |
|---|
| | 596 | List bookmarks = db.createQuery("from Ship where id>0 and bookmark=1 and owner=? order by id desc") |
|---|
| 558 | 597 | .setEntity(0, user) |
|---|
| 559 | 598 | .list(); |
|---|
| … | … | |
| 573 | 612 | boolean jdocked = false; |
|---|
| 574 | 613 | |
|---|
| 575 | | SQLQuery fleet = db.query("SELECT count(*) as shipcount,t1.x,t1.y,t1.system,t1.id,t1.docked,t2.name FROM ships t1,ship_fleets t2 WHERE t1.id>0 AND t1.owner=",user.getID()," AND t1.fleet=t2.id GROUP BY t2.id ORDER BY t1.docked,t1.system,t1.x,t1.y"); |
|---|
| 576 | | while( fleet.next() ) { |
|---|
| 577 | | if( !jdocked && (fleet.getString("docked").indexOf('l') == 0) ) { |
|---|
| | 614 | List fleets = db.createQuery("select count(*),s.fleet from Ship s " + |
|---|
| | 615 | "where s.id>0 and s.owner= :user and s.fleet!=0 " + |
|---|
| | 616 | "group by s.fleet " + |
|---|
| | 617 | "order by s.docked,s.system,s.x,s.y") |
|---|
| | 618 | .setEntity("user", user) |
|---|
| | 619 | .list(); |
|---|
| | 620 | for( Iterator iter=fleets.iterator(); iter.hasNext(); ) { |
|---|
| | 621 | Object[] data = (Object[])iter.next(); |
|---|
| | 622 | long count = (Long)data[0]; |
|---|
| | 623 | ShipFleet fleet = (ShipFleet)data[1]; |
|---|
| | 624 | |
|---|
| | 625 | Ship aship = (Ship)db.createQuery("from Ship where fleet=?") |
|---|
| | 626 | .setEntity(0, fleet) |
|---|
| | 627 | .iterate().next();; |
|---|
| | 628 | |
|---|
| | 629 | if( !jdocked && (aship.getDocked().indexOf('l') == 0) ) { |
|---|
| 578 | 630 | jdocked = true; |
|---|
| 579 | 631 | t.set_var( "fleet.jaegerfleet", 1 ); |
|---|
| … | … | |
| 583 | 635 | } |
|---|
| 584 | 636 | |
|---|
| 585 | | t.set_var( "fleet.shipid", fleet.getInt("id"), |
|---|
| 586 | | "fleet.name", fleet.getString("name"), |
|---|
| 587 | | "fleet.location", Ships.getLocationText(Location.fromResult(fleet.getRow()), false), |
|---|
| 588 | | "fleet.shipcount", fleet.getInt("shipcount") ); |
|---|
| | 637 | t.set_var( "fleet.shipid", fleet.getId(), |
|---|
| | 638 | "fleet.name", fleet.getName(), |
|---|
| | 639 | "fleet.location", Ships.getLocationText(aship.getLocation(), false), |
|---|
| | 640 | "fleet.shipcount", count ); |
|---|
| 589 | 641 | t.parse("fleets.list","fleets.listitem",true); |
|---|
| 590 | 642 | } |
|---|
| 591 | | fleet.free(); |
|---|
| 592 | 643 | } |
|---|
| 593 | 644 | |
|---|
| … | … | |
| 598 | 649 | t.set_var("quests.list",""); |
|---|
| 599 | 650 | |
|---|
| 600 | | SQLQuery quest = db.query("SELECT t1.statustext,t1.id,t2.name FROM quests_running t1,quests t2 WHERE t1.userid='",user.getID(),"' AND t1.publish='1' AND t1.questid=t2.id"); |
|---|
| 601 | | while( quest.next() ) { |
|---|
| 602 | | t.set_var( "quest.name", quest.getString("name"), |
|---|
| 603 | | "quest.statustext", quest.getString("statustext"), |
|---|
| 604 | | "quest.id", quest.getInt("id")); |
|---|
| | 651 | List quests = db.createQuery("from RunningQuest rq inner join fetch rq.quest " + |
|---|
| | 652 | "where rq.user= :user and rq.publish=1") |
|---|
| | 653 | .setEntity("user", user) |
|---|
| | 654 | .list(); |
|---|
| | 655 | for( Iterator iter=quests.iterator(); iter.hasNext(); ) { |
|---|
| | 656 | RunningQuest quest = (RunningQuest)iter.next(); |
|---|
| | 657 | |
|---|
| | 658 | t.set_var( "quest.name", quest.getQuest().getName(), |
|---|
| | 659 | "quest.statustext", quest.getStatusText(), |
|---|
| | 660 | "quest.id", quest.getId()); |
|---|
| 605 | 661 | |
|---|
| 606 | 662 | t.parse("quests.list", "quests.listitem", true); |
|---|
| 607 | 663 | } |
|---|
| 608 | | quest.free(); |
|---|
| 609 | 664 | } |
|---|
| 610 | 665 | |
|---|