Package fm.ak.server.fragment

Examples of fm.ak.server.fragment.Player


      //SelfRow.beforeFirst();
      SelfRow.beforeFirst();
      SelfRow.next();
     
      pid = SelfRow.getInt("pid");
      p = new Player(SelfRow.getInt("pid"), SelfRow.getString("pname"), SelfRow.getInt("px"), SelfRow.getInt("py") );
      Bus.put(pid, this);
      System.out.println(sid+":pid: "+pid);
      Lever = ( Lever == 1 ) ? 0 : 1;
        }
        else r = "Kill Yourself";


    }
    else if ( Apart[0].equals("region") )
    {
        //Statement SelfRowsttmnt = server.sql.createStatement();
        //SelfRow = SelfSttmnt.executeQuery("SELECT * FROM player WHERE pip = '" + client.getRemoteSocketAddress() + "' ");
        //SelfRow.refreshRow();

        Statement TileStatement = Main.sql.createStatement();
        ResultSet TileRows;

        Statement PlayerStatement = Main.sql.createStatement();
        ResultSet PlayerRows;

        Statement RegionStatement = Main.sql.createStatement();
        ResultSet RegionRows;

        SelfRow.beforeFirst();
        SelfRow.next();


        String TileQuery = "SELECT * FROM tile "
        + "LEFT JOIN entity ON tile.tid = entity.eid "
        + "WHERE "
        + "tx >= " + ( SelfRow.getInt("px")-1 - ((w / 40) / 2) ) + " AND "
        + "tx <= " + ( SelfRow.getInt("px")+1 + ((w / 40) / 2) ) + " AND "
        + "ty >= " + ( SelfRow.getInt("py")-1 - ((h / 40) / 2) ) + " AND "
        + "ty <= " + ( SelfRow.getInt("py")+1 + ((h / 40) / 2) );

        String RegionQuery = "SELECT * FROM region WHERE "
        + "rsx >= " + ( SelfRow.getInt("px")-1 - ((w / 40) / 2) ) + " AND "
        + "rsy <= " + ( SelfRow.getInt("px")+1 + ((w / 40) / 2) ) + " AND "
        + "rex >= " + ( SelfRow.getInt("py")-1 - ((h / 40) / 2) ) + " AND "
        + "rey <= " + ( SelfRow.getInt("py")+1 + ((h / 40) / 2) );

        String PlayerQuery = "SELECT * FROM player WHERE "
        + " px >= " + ( SelfRow.getInt("px")-1 - ((w / 40) / 2) ) + " AND"
        + " px <= " + ( SelfRow.getInt("px")+1 + ((w / 40) / 2) ) + " AND"
        + " py >= " + ( SelfRow.getInt("py")-1 - ((h / 40) / 2) ) + " AND"
        + " py <= " + ( SelfRow.getInt("py")+1 + ((h / 40) / 2) ) + " AND pid != " + pid;

        PlayerRows = PlayerStatement.executeQuery(PlayerQuery);
        TileRows = TileStatement.executeQuery(TileQuery);
        RegionRows = RegionStatement.executeQuery(RegionQuery);

        while( TileRows.next() )
        {
      r=(r!=null)?r+",":"";
      r = r + "t:" +
        TileRows.getInt(1) + "/" +
        TileRows.getString("timage") + "/" +
        TileRows.getString("tdecal") + "/" +
        TileRows.getInt("tx") + "/" +
        TileRows.getInt("ty") + "/" +
        TileRows.getInt("trid");

      if( TileRows.getInt("eid") != 0 )
          r = r + ",e:" +
            TileRows.getInt(1) + "/" +
            TileRows.getString("etype") + "/" +
            TileRows.getInt("eparama") + "/" +
            TileRows.getInt("eparamb") + "/" +
            TileRows.getInt("eparamc") + "/";
        }

        while( RegionRows.next() )
      r = r + ",r:" +
        RegionRows.getInt(1) + "/" +
        RegionRows.getString("rtype") + "/" +
        RegionRows.getString("rname") + "/" +
        RegionRows.getString("rsx") + "/" +
        RegionRows.getString("rsy") + "/" +
        RegionRows.getString("rex") + "/" +
        RegionRows.getString("rey");

        r = r + "," + p.Write();

        /*while( PlayerRows.next() )
      r = r + ",p:" + PlayerRows.getInt("pid") + "/" + PlayerRows.getString("pname") + "/" + PlayerRows.getInt("px") + "/" + PlayerRows.getInt("py");*/

        //System.out.print(r);
        //System.out.print("Sent players and tiles. ");


    }
    else if ( Apart[0].equals("move") )
    {
        Statement TileSttmnt = Main.sql.createStatement();
        ResultSet TileRow;

        SelfRow.beforeFirst();
        SelfRow.next();
       
        int d = Integer.parseInt( Values[0] );
        if ( d <= &&  d >= 0 )
        {
      while( true ) // so we may break
      {
          int[] dS = sutil.Direction( SelfRow.getInt("px"), SelfRow.getInt("py"), d );

          SelfRow.beforeFirst();
          SelfRow.next();

          String TileQuery = "SELECT tile.*, entity.*, region.rtype FROM tile "
            + "LEFT JOIN entity ON tile.tid = entity.eid "
            + "LEFT JOIN region ON tile.trid = region.rid "
            + "WHERE tile.tx = " + dS[0] + " AND tile.ty = " + dS[1] + " ";
          //System.out.print(TileQuery);
          TileRow = TileSttmnt.executeQuery(TileQuery);

          if( TileRow.next() )
          {
        boolean Same = TileRow.getInt("trid") == SelfRow.getInt("prid");
        boolean Inside = SelfRow.getInt("rtype") == 1;

        if (! Same )
        {
            if( TileRow.getInt("rtype") == ||  SelfRow.getInt("rtype") == 1 )
            {
          if( ! Inside )
          {
              if( TileRow.getString("etype") != null &&  TileRow.getString("etype").equals("door") )
              {
            if( Opposite[ TileRow.getInt("eparama") ] != d ) break;
              } else break;
          }
          else
          {
              if( SelfRow.getString("etype") != null &&  SelfRow.getString("etype").equals("door") )
              {
            if( SelfRow.getInt("eparama") != d ) break;
              } else break;
          }
            }

        }

        Statement PlayerStatement = Main.sql.createStatement();
        String PlayerQuery = "UPDATE player SET px = " + dS[0] + ", py = " + dS[1] + ", ptid = " + TileRow.getInt("tid") + ", prid = " + TileRow.getInt("trid") + " WHERE pid = " + pid;
        PlayerStatement.execute( PlayerQuery );
        SelfRow = SelfSttmnt.executeQuery(SelfQuery);
        SelfRow.next();
        Frags.Patch( p = new Player( SelfRow.getInt("pid"), SelfRow.getString("pname"), dS[0], dS[1] ) );

        for( Seat s : Bus.values() )
        {
            Seat Scapegoat, Sin;
            Scapegoat = ( this.sid > s.sid ) ? s : this;
            Sin = ( Scapegoat == this ) ? s : this;
           
            if ( s == this ) continue;
            if ( Scapegoat.See(Sin) )
            {
          if ( !Scapegoat.Seen(Sin) )
          {
              Scapegoat.Seen.add(Sin);
              Frags.Patch( s.p );
          }
         
          s.Frags.Patch( p );
         
            }
            else if ( Scapegoat.Seen(Sin) )
            {
          Scapegoat.Seen.remove(Sin);
          s.Frags.Patch( new Player( pid ) );
            }
        }
       
        r = "";

View Full Code Here

TOP

Related Classes of fm.ak.server.fragment.Player

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.