Changeset d2207995854b693fbec19a84cb845a97eb0ed841

Show
Ignore:
Timestamp:
11/25/07 13:09:34 (1 year ago)
Author:
Christopher Jung <bktheg@web.de>
git-committer:
Christopher Jung <bktheg@web.de> 1195992574 +0100
git-parent:

[d89987e8bbe8add4ede8d618af4536c1f933950a]

git-author:
Christopher Jung <bktheg@web.de> 1195992574 +0100
Message:

Uebersicht: NullPointerException? gefixt

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/net/driftingsouls/ds2/server/modules/UeberController.java

    rc27b1f3 rd220799  
    459459 
    460460                if( inttutorial != 0 ) { 
    461                         boolean reqname = false; 
    462                         boolean reqship = false; 
    463                         boolean reqbase = false; 
    464          
    465                         if( !user.getName().equals("Kolonist") ) { 
    466                                 reqname = true; 
    467                         } 
    468                  
    469                         if( shipcount > 0 ) { 
    470                                 reqship = true; 
    471                         } 
    472          
    473                         if( bases > 0 ) { 
    474                                 reqbase = true; 
    475                         } 
    476                          
    477                         if( !reqship ) { 
    478                                 reqbase = true; 
    479                         } 
    480                          
    481                         if( !reqname ) { 
    482                                 reqship = true; 
    483                                 reqbase = true; 
    484                         } 
    485  
    486                         IntTutorial sheet = (IntTutorial)db.createQuery("from IntTutorial where id= :id and reqName= :reqname and reqBase= :reqbase and reqShip= :reqship") 
    487                                 .setInteger("id", inttutorial) 
    488                                 .setInteger("reqname", reqname ? 1 : 0) 
    489                                 .setInteger("reqbase", reqbase ? 1 : 0) 
    490                                 .setInteger("reqship", reqship ? 1 : 0) 
    491                                 .uniqueResult(); 
    492          
    493                         // Ist die aktuelle Tutorialseite veraltet? 
    494                         if( (sheet == null) || (sheet.getId() != inttutorial) ) { 
    495                                 sheet = (IntTutorial)db.createQuery("from IntTutorial where reqName= :reqname and reqBase= :reqbase and reqShip= :reqship order by id") 
    496                                         .setInteger("reqname", reqname ? 1 : 0) 
    497                                         .setInteger("reqbase", reqbase ? 1 : 0) 
    498                                         .setInteger("reqship", reqship ? 1 : 0) 
    499                                         .setMaxResults(1) 
    500                                         .uniqueResult(); 
    501                                  
    502                                 // Neue Tutorialseite speichern 
    503                                 inttutorial = sheet.getId(); 
    504                                 user.setUserValue("TBLORDER/uebersicht/inttutorial", Integer.toString(inttutorial)); 
    505                         } 
    506          
    507                         // Existiert eine Nachfolgerseite? 
    508                         IntTutorial nextsheet = (IntTutorial)db.createQuery("from IntTutorial where reqSheet= :reqsheet and reqName= :reqname and reqBase= :reqbase and reqShip= :reqship") 
    509                                 .setInteger("reqsheet", sheet.getId()) 
    510                                 .setInteger("reqname", reqname ? 1 : 0) 
    511                                 .setInteger("reqbase", reqbase ? 1 : 0) 
    512                                 .setInteger("reqship", reqship ? 1 : 0) 
    513                                 .setMaxResults(1) 
    514                                 .uniqueResult(); 
    515          
    516                         // Kann das Tutorial jetzt beendet werden? 
    517                         if( (nextsheet == null) && reqname && reqship && reqbase ) { 
    518                                 t.setVar("sheet.endtutorial",1); 
    519                         } 
    520                         else if( nextsheet != null ) { 
    521                                 t.setVar("sheet.nextsheet",1); 
    522                         } 
    523          
    524                         t.setVar(       "interactivetutorial.show",     1, 
    525                                                 "sheet.headpic",                        sheet.getHeadImg(), 
    526                                                 "sheet.text",                           Common._text(sheet.getText()) ); 
     461                        showTutorialPages(bases, shipcount, inttutorial); 
    527462                } 
    528463 
     
    609544        } 
    610545 
     546        private void showTutorialPages(int bases, long shipcount, int inttutorial) { 
     547                org.hibernate.Session db = getDB(); 
     548                User user = (User)getUser(); 
     549                TemplateEngine t = getTemplateEngine(); 
     550                 
     551                boolean reqname = false; 
     552                boolean reqship = false; 
     553                boolean reqbase = false; 
     554 
     555                if( !user.getName().equals("Kolonist") ) { 
     556                        reqname = true; 
     557                } 
     558 
     559                if( shipcount > 0 ) { 
     560                        reqship = true; 
     561                } 
     562 
     563                if( bases > 0 ) { 
     564                        reqbase = true; 
     565                } 
     566                 
     567                if( !reqship ) { 
     568                        reqbase = true; 
     569                } 
     570                 
     571                if( !reqname ) { 
     572                        reqship = true; 
     573                        reqbase = true; 
     574                } 
     575 
     576                IntTutorial sheet = (IntTutorial)db.createQuery("from IntTutorial where id= :id and reqName= :reqname and reqBase= :reqbase and reqShip= :reqship") 
     577                        .setInteger("id", inttutorial) 
     578                        .setInteger("reqname", reqname ? 1 : 0) 
     579                        .setInteger("reqbase", reqbase ? 1 : 0) 
     580                        .setInteger("reqship", reqship ? 1 : 0) 
     581                        .uniqueResult(); 
     582 
     583                // Ist die aktuelle Tutorialseite veraltet? 
     584                if( (sheet == null) || (sheet.getId() != inttutorial) ) { 
     585                        sheet = (IntTutorial)db.createQuery("from IntTutorial where reqName= :reqname and reqBase= :reqbase and reqShip= :reqship order by id") 
     586                                .setInteger("reqname", reqname ? 1 : 0) 
     587                                .setInteger("reqbase", reqbase ? 1 : 0) 
     588                                .setInteger("reqship", reqship ? 1 : 0) 
     589                                .setMaxResults(1) 
     590                                .uniqueResult(); 
     591                         
     592                        if( sheet == null ) { 
     593                                user.setUserValue("TBLORDER/uebersicht/inttutorial", "0"); 
     594                                return; 
     595                        } 
     596                         
     597                        // Neue Tutorialseite speichern 
     598                        inttutorial = sheet.getId(); 
     599                        user.setUserValue("TBLORDER/uebersicht/inttutorial", Integer.toString(inttutorial)); 
     600                } 
     601 
     602                // Existiert eine Nachfolgerseite? 
     603                IntTutorial nextsheet = (IntTutorial)db.createQuery("from IntTutorial where reqSheet= :reqsheet and reqName= :reqname and reqBase= :reqbase and reqShip= :reqship") 
     604                        .setInteger("reqsheet", sheet.getId()) 
     605                        .setInteger("reqname", reqname ? 1 : 0) 
     606                        .setInteger("reqbase", reqbase ? 1 : 0) 
     607                        .setInteger("reqship", reqship ? 1 : 0) 
     608                        .setMaxResults(1) 
     609                        .uniqueResult(); 
     610 
     611                // Kann das Tutorial jetzt beendet werden? 
     612                if( (nextsheet == null) && reqname && reqship && reqbase ) { 
     613                        t.setVar("sheet.endtutorial",1); 
     614                } 
     615                else if( nextsheet != null ) { 
     616                        t.setVar("sheet.nextsheet",1); 
     617                } 
     618 
     619                t.setVar(       "interactivetutorial.show",     1, 
     620                                        "sheet.headpic",                        sheet.getHeadImg(), 
     621                                        "sheet.text",                           Common._text(sheet.getText()) ); 
     622        } 
     623 
    611624}