starting some java programming can anyone help me menu

User Tag List

Results 1 to 6 of 6
  1. #1
    danielrhodea's Avatar Master Sergeant
    Reputation
    11
    Join Date
    Apr 2010
    Posts
    107
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    starting some java programming can anyone help me

    Hi all

    I'm starting programming with java and have been converting wowmapviewer code to java (really havent converted any yet lol @ me but trying, can smeone help me out please)

    lol @ me, java is soooo easy to use once I get over my dependency on pointers and addresses lol

    Code:
    import java.io.*;
    import java.lang.String;
    import java.lang.Integer;
    
    public class DBCFile
    {
    	public DBCFile(String _filename)
    	{
    		File f = new File(_filename);
    		if(f.canRead())
    			filename = _filename;
    		else
    			error = true;
    	}
    
    	// Open database. It must be openened before it can be used.
    	public void open()
    	{
    		try
    		{
    			FileReader f = new FileReader(filename);
    			char[] hdr = new char[4];
    			
    			char[] na = new char[4];
    			char[] nb = new char[4];
    			char[] es = new char[4];
    			char[] ss = new char[4];
    
    			f.read(hdr); // Number of records
    			
    			assert(String.copyValueOf(hdr) == "WDBC");
    			header = String.copyValueOf(hdr);
    			f.read(na); // Number of record
    			recordCount = (na[0]) | (na[1]) | (na[2]) | (na[3]);
    			f.read(nb); // Number of fields
    			fieldCount = (nb[0]) | (nb[1]) | (nb[2]) | (nb[3]);
    			f.read(es); // Size of a record
    			recordSize = (es[0]) | (es[1]) | (es[2]) | (es[3]);
    			f.read(ss); // String size
    			stringSize = (ss[0]) | (ss[1]) | (ss[2]) | (ss[3]);
    			       
    			assert(fieldCount *4 == recordSize);
    			
    			
    			data = new char[recordSize * recordCount + stringSize];
    			
    			stringTable = new char[(data.length) + recordSize * recordCount];
           		
    			f.read(data);
           		/*
    			String tmp = "";
    			for(int i=1*recordSize+stringSize;i<stringSize;i++)
    				tmp += String.valueOf(data[i]);
    			System.out.println(tmp);
    			*/
    			f.close();
    		}
    		catch(IOException exc)
    		{
    			System.out.println("IOException"+exc.getMessage());
    		}
    		trace();// uncomment to hide debug info
    	}
    	private Boolean error = false;
    	public Boolean hasError(){
    		return error;
    	}
    	public void trace()
    	{
    		System.out.println("Traced output... header:"+header+" record count:"+recordCount+" field count:"+fieldCount+" record size:"+recordSize+" string size:"+stringSize+" error:"+hasError());
    	}
    	private String header;
    	private String filename;
    	private int recordSize;
    	private int recordCount;
    	private int fieldCount;
    	private int stringSize;
        private char[] data;
        private char stringTable[];
    }
    anyone with noggit, wowmapview, dbc loading etc should understand this code it's my attempt at re-writing from c++ to java the loading of a dbc file,
    I do not wish to simply be spoon-fed so if anyone can help me work through the code, I understand the C++ but cannot convert it to java as I'm a java n00b and know nothing about it's namespaces etc, I am quite well versed in C# and flex though which im aware are java-esque syntax

    thanks so much, hopefully soon I'll have something to share back with

    btw I think the data segment is wrong as well as the string table but other info correllates to wowdev records
    Last edited by danielrhodea; 04-22-2010 at 05:36 AM.

    starting some java programming can anyone help me
  2. #2
    Krillere's Avatar Contributor
    Reputation
    112
    Join Date
    Nov 2007
    Posts
    668
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow.. Lol @ getting more posts..

  3. #3
    danielrhodea's Avatar Master Sergeant
    Reputation
    11
    Join Date
    Apr 2010
    Posts
    107
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thank you, if you can delete please do, I concatenated the posts into one, do you know java at all???

  4. #4
    Krillere's Avatar Contributor
    Reputation
    112
    Join Date
    Nov 2007
    Posts
    668
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry no, I know C#. I just felt like telling you that triple-posting is not OK at all. :-)
    ( If I'm not completely wrong, it's actually against the rules! Correct me if I'm wrong. )

  5. #5
    danielrhodea's Avatar Master Sergeant
    Reputation
    11
    Join Date
    Apr 2010
    Posts
    107
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    wdt class, traces output of .wdt ATM (it will allow toggling of them by using
    (eightbytes | 1) & automatically generating a blank .adt file if one does not exist in the future)

    A problem exists for me creating a wdt file atm, i'm sure ill crack it soon!!!

    Code:
    import java.io.*;
    import java.lang.String;
    public class WDT
    {
    	private boolean[] fileperms = {false,false};
    	private String filename = "";
    	private boolean debug = true;
    	
    	private boolean[] data = new boolean[4096];//because there are 64*64 possibilities 
    	
    	public WDT(String _filename, boolean autoOpen)
    	{
    		filename = _filename;
    		File fil = new File(_filename);
    		if(fil.canRead())//check read capability
    			fileperms[0] = true;
    		
    		if(fil.canWrite())//check write capability
    			fileperms[1] = true;
    
    		if(autoOpen)
    			read();
    	}
    	private char[] flip(char[] target)
    	{
    		char[] tmp = new char[target.length];
    		for(int i=0;i<target.length;i++)
    		{
    			tmp[(tmp.length-i)-1] = target[i];	
    		}
    		return tmp;
    	}
    	
    	private void trace()
    	{
    		for(int row = 1; row<=64 ;row++)
    		{
    			for(int col = 1;col<=64;col++)
    			{
    				System.out.print( ((data[((row-1)*64)+(col-1)]) ? ("x") : ("0")) + ((col == 64)?("\n"):("")) );// = ( ( (fourcc[0]|fourcc[1]|fourcc[2]|fourcc[3]) & 1 ) == 1) ? (true) : (false);
    			}
    		}
    	}
    	
    	public boolean read()
    	{
    		if(!fileperms[0])
    			return false;
    		
    		try
    		{
    			FileReader f = new FileReader(filename);
    			char[] fourcc = new char[4];
    
    			boolean eof = false;			
    			while (!eof)
    			{
    				int tmp = f.read(fourcc);
    				if(tmp == -1)
    					eof = true;
    				fourcc = flip(fourcc);
    
    				if((fourcc[0] == 'M') && (fourcc[1] == 'A') && (fourcc[2] == 'I') && (fourcc[3] == 'N'))
    				{
    					f.read(fourcc);
    					f.read(fourcc);
    					for(int row = 1; row<=64 ;row++)
    					{
    						for(int col = 1;col<=64;col++)
    						{
    							f.read(fourcc);
    							f.read(fourcc);
    
    							data[((row-1)*64)+(col-1)] = ( ( (fourcc[0]|fourcc[1]|fourcc[2]|fourcc[3]) & 1 ) == 1) ? (true) : (false);
    						}
    					}
    				}
    			}
    			if(debug)
    				trace();
    		}
    		catch(IOException ioexc)
    		{
    
    		}
    		return true;
    	}
    	
    	public void debugMode()
    	{
    		debug = !debug;
    	}
    	
    	public void setActive(int row, int col)
    	{
    		(data[((row-1)*64)+(col-1)]) = true;
    	}
    	
    	public void setInactive(int row, int col)
    	{
    		(data[((row-1)*64)+(col-1)]) = false;
    	}
    }
    Last edited by danielrhodea; 04-22-2010 at 06:59 PM.

  6. #6
    danielrhodea's Avatar Master Sergeant
    Reputation
    11
    Join Date
    Apr 2010
    Posts
    107
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lol for anyone reading this don't bother going down the java route, I never did get .wmo files working at all lol

Similar Threads

  1. Can anyone help?
    By Solera in forum World of Warcraft General
    Replies: 3
    Last Post: 12-15-2007, 07:08 AM
  2. can anyone help?
    By Viter in forum World of Warcraft Emulator Servers
    Replies: 8
    Last Post: 11-04-2007, 10:51 PM
  3. Can Anyone Help Me?
    By HellAzagoth in forum WoW ME Questions and Requests
    Replies: 5
    Last Post: 05-13-2007, 03:30 PM
  4. Need a new virus scan program for free can anyone help?
    By matswurld in forum Community Chat
    Replies: 1
    Last Post: 12-14-2006, 09:39 AM
All times are GMT -5. The time now is 03:54 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search