コード例 #1
0
ファイル: MCache.java プロジェクト: scypheroth/bdsalem2
  public void mapdata(Message msg) {
    long now = System.currentTimeMillis();
    int pktid = msg.int32();
    int off = msg.uint16();
    int len = msg.uint16();
    Defrag fragbuf;
    synchronized (fragbufs) {
      if ((fragbuf = fragbufs.get(pktid)) == null) {
        fragbuf = new Defrag(len);
        fragbufs.put(pktid, fragbuf);
      }
      fragbuf.add(msg.blob, 8, msg.blob.length - 8, off);
      fragbuf.last = now;
      if (fragbuf.done()) {
        mapdata2(fragbuf.msg());
        fragbufs.remove(pktid);
      }

      /* Clean up old buffers */
      for (Iterator<Map.Entry<Integer, Defrag>> i = fragbufs.entrySet().iterator(); i.hasNext(); ) {
        Map.Entry<Integer, Defrag> e = i.next();
        Defrag old = e.getValue();
        if (now - old.last > 10000) i.remove();
      }
    }
  }
コード例 #2
0
ファイル: MCache.java プロジェクト: scypheroth/bdsalem2
 public void tilemap(Message msg) {
   while (!msg.eom()) {
     int id = msg.uint8();
     String resnm = msg.string();
     int resver = msg.uint16();
     nsets[id] = new Resource.Spec(resnm, resver);
   }
 }
コード例 #3
0
ファイル: Material.java プロジェクト: puruscor/Purus-Pasta
 public Res cons(Resource res, Message buf) {
   int id = buf.uint16();
   Res ret = new Res(res, id);
   while (!buf.eom()) {
     String nm = buf.string();
     Object[] args = buf.list();
     if (nm.equals("linear")) {
       /* XXX: These should very much be removed and
        * specified directly in the texture layer
        * instead. */
       ret.linear = true;
     } else if (nm.equals("mipmap")) {
       ret.mipmap = true;
     } else {
       ResCons2 cons = rnames.get(nm);
       if (cons == null)
         throw (new Resource.LoadException("Unknown material part name: " + nm, res));
       ret.left.add(cons.cons(res, args));
     }
   }
   return (ret);
 }
コード例 #4
0
ファイル: Material.java プロジェクト: puruscor/Purus-Pasta
 public Res cons(final Resource res, Message buf) {
   int id = buf.uint16();
   Res ret = new Res(res, id);
   GLState light = Light.deflight;
   while (!buf.eom()) {
     String thing = buf.string().intern();
     if (thing == "col") {
       Color amb = col(buf);
       Color dif = col(buf);
       Color spc = col(buf);
       double shine = buf.cpfloat();
       Color emi = col(buf);
       ret.states.add(new Colors(amb, dif, spc, emi, (float) shine));
     } else if (thing == "linear") {
       ret.linear = true;
     } else if (thing == "mipmap") {
       ret.mipmap = true;
     } else if (thing == "nofacecull") {
       ret.states.add(nofacecull);
     } else if (thing == "tex") {
       final int tid = buf.uint16();
       ret.left.add(
           new Res.Resolver() {
             public void resolve(Collection<GLState> buf) {
               for (Resource.Image img : res.layers(Resource.imgc)) {
                 if (img.id == tid) {
                   buf.add(img.tex().draw());
                   buf.add(img.tex().clip());
                   return;
                 }
               }
               throw (new RuntimeException(
                   String.format("Specified texture %d not found in %s", tid, res)));
             }
           });
     } else if (thing == "texlink") {
       final String nm = buf.string();
       final int ver = buf.uint16();
       final int tid = buf.uint16();
       ret.left.add(
           new Res.Resolver() {
             public void resolve(Collection<GLState> buf) {
               Indir<Resource> tres = res.pool.load(nm, ver);
               for (Resource.Image img : tres.get().layers(Resource.imgc)) {
                 if (img.id == tid) {
                   buf.add(img.tex().draw());
                   buf.add(img.tex().clip());
                   return;
                 }
               }
               throw (new RuntimeException(
                   String.format(
                       "Specified texture %d for %s not found in %s", tid, res, tres)));
             }
           });
     } else if (thing == "light") {
       String l = buf.string();
       if (l.equals("pv")) {
         light = Light.vlights;
       } else if (l.equals("pp")) {
         light = Light.plights;
       } else if (l.equals("n")) {
         light = null;
       } else {
         throw (new Resource.LoadException("Unknown lighting type: " + thing, res));
       }
     } else {
       throw (new Resource.LoadException("Unknown material part: " + thing, res));
     }
   }
   if (light != null) ret.states.add(light);
   return (ret);
 }
コード例 #5
0
ファイル: SpriteLink.java プロジェクト: puruscor/Purus-Pasta
 private ByRes(Resource res, Message buf, Map<Integer, Factory> refs) {
   String resnm = buf.string();
   int resver = buf.uint16();
   this.res = res.pool.load(resnm, resver);
 }