Post new topic    
Page 1, 2, 3  »
Slime Knight
Send private message
HamsterWrench 
 PostSun Jan 02, 2011 12:39 am
Send private message Reply with quote
OK, this may seem a little overambitious, but I am planning work on a set of Java-based tools to work with RPG files. I envision it being an alternative to CUSTOM when it's good enough.

Here's where it lies right now:
http://code.google.com/p/hamsterwrench/

(if it looks a little spartan, that's because I just started coding today)
Liquid Metal King Slime
Send private message
 
 PostSun Jan 02, 2011 1:37 am
Send private message Reply with quote
Cool beans. I fully endorse this.
Slime Knight
Send private message
 
 PostSun Jan 02, 2011 2:28 am
Send private message Reply with quote
If you have a Google account associated with your email. tell me if you want to be added to the list.
Liquid Metal King Slime
Send private message
 
 PostSun Jan 02, 2011 4:44 am
Send private message Reply with quote
Have you looked at the OHRRPGCE FMF project? It has been discontinued, but it is written in Java, and it might have some code that you could re-use.
Slime Knight
Send private message
 
 PostSun Jan 02, 2011 7:04 am
Send private message Reply with quote
I'll take a look at that, thank you
Liquid Metal Slime
Send private message
 
 PostSun Jan 02, 2011 11:02 am
Send private message Reply with quote
James Paige wrote:
Have you looked at the OHRRPGCE FMF project? It has been discontinued, but it is written in Java, and it might have some code that you could re-use.

Aww dang, I thought it was pretty cool when I first read about it.
Slime Knight
Send private message
 
 PostMon Jan 03, 2011 1:58 am
Send private message Reply with quote
I'm making a little bit of progress. I just wrote an addition to the lump class that now makes it possible to find out what the lump elements are and how much space they take up.
Slime Knight
Send private message
 
 PostTue Jan 04, 2011 4:04 am
Send private message Reply with quote
OK, something's going on with my lump reader methods. It reads fine until a certain point, then just starts producing If someone can look over my code and help me out, I'd appreciate it.
Slime Knight
Send private message
 
 PostSat Feb 12, 2011 2:36 am
Send private message Reply with quote
I could use some help with the loader routine.
Liquid Metal King Slime
Send private message
 
 PostSat Feb 12, 2011 5:53 pm
Send private message Reply with quote
Can you post the lump reading code here?
Slime Knight
Send private message
 
 PostSat Feb 12, 2011 8:26 pm
Send private message Reply with quote
Code:
package com.hamsterrepublic.hamsterwrench.data;

import java.io.*;

public final class Lump {
   private File lumpFile;
   private File dir;
   public Lump(String f) throws FileNotFoundException{
      lumpFile = new File(f);
      if(!lumpFile.isFile()){
         throw new FileNotFoundException();
      }else{
         System.out.println("file " + lumpFile.getAbsolutePath() + " loaded, length " + lumpFile.length() + " bytes.");
         dir = new File(lumpFile.getParent() + File.separatorChar + "RPGfiles");
         dir.mkdir();
      }
   }

   public void readLumpStructure(){
      LumpReader lr = new LumpReader();
      System.out.println("Reading elements of lump...");
      lr.getElementData();
      while (!lr.eof){
         System.out.println("Element " + lr.getName() + ", size " + lr.getSize());
         lr.hop();
         lr.getElementData();
      }
      System.out.println("done.");
      lr.destroy();
      lr = null;
   }

   public void unlumpAll(){
      LumpReader lr = new LumpReader();
      System.out.println("Reading elements of lump...");
      lr.getElementData();
      while (!lr.eof){
         System.out.print("Writing " + lr.getName() + ", size " + lr.getSize() + "...");
         lr.dumpToFile();
         System.out.println("OK!");
         lr.getElementData();
      }
      System.out.println("done.");
      lr.destroy();
      lr = null;
   }

   class LumpReader {
      private String name = null;
      private long size = 0L;
      private FileReader fr;
      private BufferedReader br;
      private boolean readyForReading = false;
      private boolean eof = false;
      public LumpReader(){
         //Initializes the readers.
         try {
            fr = new FileReader(lumpFile);
            br = new BufferedReader(fr);
         } catch (FileNotFoundException e) {
            //If all goes correctly, we'll never reach this due to the FNFE throw in the outer class
            e.printStackTrace();
         }
      }

      //getters

      public boolean readable(){
         return readyForReading;
      }
      public String getName(){
         return name;
      }
      public long getSize(){
         return size;
      }
      public boolean isEOF(){
         return eof;
      }

      public void getElementData(){
         if(!readyForReading){
            StringBuilder s = new StringBuilder();
            int n;
            int[] l;
            l = new int[4];

            try{
               do{
                  n = br.read();
                  if(n != 0 && n != -1){
                     s.append((char) n);
                  }
               }while(n != 0 && n != -1);
               if(n == -1){
                  eof = true;
               }else{
                  name = s.toString();

                  //PDP-endian to big-endian
                  l[1] = br.read();
                  l[0] = br.read();
                  l[3] = br.read();
                  l[2] = br.read();

                  for (int i = 0; i < l.length; i++)
                  {
                     size = (size << 8) + (l[i]);
                  }
                  readyForReading = true;
               }
            }catch(Exception ex){
               ex.printStackTrace();
            }

         }else{
            System.err.println("The reader is in read data mode.");
         }
      }

      public void dumpToFile(){
         if(readyForReading){
            try{
               FileWriter fw = new FileWriter(dir.getAbsolutePath() + File.separatorChar + name);
               for(int i=0; i < size; i++){
                  fw.write(br.read());
               }
               fw.close();
               fw = null;
               name = null;
               size = 0L;
               readyForReading = false;
            } catch (IOException e) {
               e.printStackTrace();
            }
         }else{
            System.err.println("The reader is currently in get element mode.");
         }

      }

      public void hop(){
         if (readyForReading){
            try {
               br.skip(size);
               name = null;
               size = 0L;
               readyForReading = false;
            } catch (IOException e) {
               e.printStackTrace();
            }
         }else{
            System.err.println("The reader is currently in get element mode.");
         }

      }

      public void destroy(){
         try {
            fr.close();
            br.close();
         } catch (IOException e) {
            e.printStackTrace();
         }
      }

   }


}
Slime Knight
Send private message
 
 PostMon Jun 13, 2011 2:04 am
Send private message Reply with quote
Hi.

Sorry to be a thread neck romancer, but I'm still working on this project and I've got the lump extractor working!

As always, you can see my work (and even help if you want) at: http://code.google.com/p/hamsterwrench/
Metal King Slime
Send private message
 
 PostMon Jun 13, 2011 8:59 am
Send private message Reply with quote
Great to hear you finally figured out the problem. I tried reading your lump extraction code, but aside from having written a decent poker bot in Java once (they made it so dang hard to use any other language!), I don't know the first thing about Java. I can't even figure how to properly compile anymore.

Best of luck!
Slime
Send private message
 
 PostMon Jun 20, 2011 11:26 am
Send private message Reply with quote
Good luck!
Buy Slap Chop
Slime Knight
Send private message
 
 PostSun Jun 26, 2011 10:40 pm
Send private message Reply with quote
So the hero class is less cluttered now and I updated the constants.
Display posts from previous:
Page 1, 2, 3  »