Changeset fc42460aa180429c80c001911fa4703883a998c1

Show
Ignore:
Timestamp:
09/23/07 18:28:27 (1 year ago)
Author:
Christopher Jung <bktheg@web.de>
git-committer:
Christopher Jung <bktheg@web.de> 1190564907 +0200
git-parent:

[450ab1a46131c90f4eee539ac127a9e6f984ac8d]

git-author:
Simon Dietsch <rhonabwy@arcor.de> 1190545302 +0000
Message:

Schlachten in der Uebersicht

Files:

Legend:

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

    r7375108 rfc42460  
    375375                ArrayList<Integer> battleidlist = new ArrayList<Integer>(); 
    376376 
    377                 // User darf nur die Eigenen oder Ally-Schlachten sehen 
    378                 if( (user.getAccessLevel() < 20) && !user.hasFlag(User.FLAG_VIEW_BATTLES) && !user.hasFlag(User.FLAG_QUEST_BATTLES) ) { 
    379                         SQLQuery battle = null; 
    380                         if( user.getAlly() != null ) { 
    381                                 battle = database.query("SELECT * FROM battles WHERE commander1=",user.getID()," OR commander2=",user.getID()," OR ally1=",user.getAlly().getId()," OR ally2=",user.getAlly().getId()); 
    382                         } 
    383                         else { 
    384                                 battle = database.query("SELECT * FROM battles WHERE commander1=",user.getID()," OR commander2=",user.getID()); 
    385                         } 
    386                          
    387                         while( battle.next() ) { 
    388                                 if( (user.getAlly() != null) && (battle.getString("visibility") != null) &&  
    389                                                 (battle.getString("visibility").length() > 0) ) { 
    390                                         Integer[] visibility = Common.explodeToInteger(",", battle.getString("visibility")); 
    391                                         if( !Common.inArray(user.getID(),visibility) ) { 
    392                                                 continue;        
    393                                         } 
    394                                 } 
    395                                 battleidlist.add(battle.getInt("id")); 
    396  
    397                                 String eparty = ""; 
    398                                 String comm = ""; 
    399                                 if( ((user.getAlly() == null) && (battle.getInt("commander1") != user.getID())) ||  
    400                                         ((user.getAlly() != null) && (battle.getInt("ally1") != user.getAlly().getId()) ) ) { 
    401                                         if( battle.getInt("ally1") == 0 ) { 
    402                                                 final User commander1 = (User)db.get(User.class, battle.getInt("commander1")); 
    403                                                 eparty = Common._title(commander1.getName()); 
    404                                         }  
    405                                         else { 
    406                                                 final Ally ally = (Ally)db.get(Ally.class, battle.getInt("ally1")); 
    407                                                 eparty = Common._title(ally.getName()); 
    408                                         } 
     377                // Ab hier beginnt das erste Bier 
     378                String query = ""; 
     379                // Auch hibernate sollte nicht doppelt abfragen, also schreib ich den kruscht mir mal hier auf 
     380                int userid = user.getID(); 
     381                int userally = 0;  
     382                int accesslevel = user.getAccessLevel(); 
     383                boolean questbattles = user.hasFlag(User.FLAG_QUEST_BATTLES); 
     384                try{ 
     385                        userally = user.getAlly().getId();       
     386                }catch(NullPointerException e){ 
     387                        // dann lassen wir die ally halt auf 0   
     388                } 
     389                if(accesslevel < 20 && !user.hasFlag(User.FLAG_VIEW_BATTLES)){ 
     390                        query = "SELECT * FROM battles, ships, users WHERE commander1="+ user.getID() +" OR commander2="+ user.getID() +" OR ((SELECT battle FROM ships where battle != 0 GROUP BY battle) = battles.id AND ships.owner = "; 
     391                        //hat die Sau ne ally, dann haeng das hier an 
     392                        if(userally != 0){ 
     393                                query += " (SELECT id from users WHERE ally=0))"; 
     394                                query += " OR t1.ally1 = t3.ally OR t1.ally2 = t3.ally"; 
     395                        }else{ //ansonsten haeng nur die user id an 
     396                                query += " "+userid+")"; 
     397                        }        
     398                        // ach haengen wir mal den quest kram dran 
     399                        if(questbattles){ 
     400                                query += " OR quest IS NOT NULL";        
     401                        } 
     402                }else{  // der arme tropf der hier ankommt muss echt alles sehen 
     403                        query = "select * from battles"; 
     404                } 
     405                //tjoa wer braucht schon doppelte battle-ids 
     406                query += " GROUP BY battles.id"; 
     407                SQLQuery battle = database.query(query); 
    409408                                         
    410                                         final User commander2 = (User)db.get(User.class, battle.getInt("commander2")); 
    411                                         comm = Common._title(commander2.getName()); 
    412                                 }  
    413                                 else { 
    414                                         if( battle.getInt("ally2") == 0 ) { 
    415                                                 final User commander2 = (User)db.get(User.class, battle.getInt("commander2")); 
    416                                                 eparty = Common._title(commander2.getName()); 
    417                                         }  
    418                                         else { 
    419                                                 final Ally ally = (Ally)db.get(Ally.class, battle.getInt("ally2")); 
    420                                                 eparty = Common._title(ally.getName()); 
    421                                         } 
    422  
    423                                         final User commander1 = (User)db.get(User.class, battle.getInt("commander1")); 
    424                                         comm = Common._title(commander1.getName()); 
    425                                 } 
    426                                  
    427                                 if( user.getAlly() != null ) { 
    428                                         battlelist.append("<a class=\"error\" href=\"ds?module=angriff&amp;sess="+getString("sess")+"&amp;battle="+battle.getInt("id")+"\">Schlacht mit "+eparty+" bei "+battle.getInt("system")+" : "+battle.getInt("x")+"/"+battle.getInt("y")+"</a> ["+comm+"]<br />\n"); 
    429                                 } 
    430                                 else { 
    431                                         battlelist.append("<a class=\"error\" href=\"ds?module=angriff&amp;sess="+getString("sess")+"&amp;battle="+battle.getInt("id")+"\">Es ist eine Schlacht mit "+eparty+" bei "+battle.getInt("system")+" : "+battle.getInt("x")+"/"+battle.getInt("y")+" im Gange</a><br />\n"); 
    432                                 } 
    433                         } 
    434                         battle.free(); 
    435                 } 
    436  
    437                 SQLQuery battle = null; 
    438                  
    439                 //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 
    440                 if( (user.getAccessLevel() < 20) && user.hasFlag(User.FLAG_QUEST_BATTLES) ) { 
    441                         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(),")"); 
    442                 } 
    443                 else if( (user.getAccessLevel() >= 20) || user.hasFlag(User.FLAG_VIEW_BATTLES) ) { 
    444                         battle = database.query("SELECT * FROM battles"); 
    445                 } 
    446                 else {                   
    447                         battlelist.append("<br />\n"); 
    448                         battle = database.query("SELECT t1.* ", 
    449                                                         "FROM battles t1,ships t2 ", 
    450                                                         "WHERE t2.id>0 AND t2.owner=",user.getID()," AND t2.battle=t1.id ",(!battleidlist.isEmpty() ? "AND !(t2.battle IN ("+Common.implode(",",battleidlist)+"))":"")," ", 
    451                                                         "GROUP BY t1.id" ); 
    452                 } 
     409                // Ab hier beginnt das zweite Bier 
    453410                 
    454411                while( battle.next() ) { 
    455                         if( !user.hasFlag(User.FLAG_QUEST_BATTLES) && (battle.getInt("quest") != 0) ) { 
    456                                 continue; 
    457                         } 
    458412                        String eparty = ""; 
    459413                        String eparty2 = ""; 
     
    467421                        } 
    468422                         
    469                         final User commander1 = (User)db.get(User.class, battle.getInt("commander1")); 
    470                         String comm1 = Common._title(commander1.getName()); 
    471  
    472423                        if( battle.getInt("ally2") == 0 ) { 
    473424                                final User commander2 = (User)db.get(User.class, battle.getInt("commander2")); 
     
    478429                                eparty2 = Common._title(ally.getName()); 
    479430                        } 
    480                          
    481                         final User commander2 = (User)db.get(User.class, battle.getInt("commander2")); 
    482                         String comm2 = Common._title(commander2.getName()); 
    483                  
    484                         battlelist.append("<a class=\"error\" href=\"ds?module=angriff&amp;sess="+getString("sess")+"&amp;battle="+battle.getInt("id")+"\">Schlacht "+eparty+" vs "+eparty2+" bei "+battle.getInt("system")+":"+battle.getInt("x")+"/"+battle.getInt("y")+"</a><br />*&nbsp;["+comm1+" vs "+comm2+"]<br />\n"); 
     431                                         
     432                        battlelist.append("<a class=\"error\" href=\"ds?module=angriff&amp;sess="+getString("sess")+"&amp;battle="+battle.getInt("id")+"\">Schlacht "+eparty+" vs "+eparty2+" bei "+battle.getInt("system")+":"+battle.getInt("x")+"/"+battle.getInt("y")+"</a><br />\n"); 
    485433                         
    486434                        if( ( (user.getAccessLevel() >= 20) || user.hasFlag(User.FLAG_QUEST_BATTLES) )