[Jcrossclient-cvs] jcrossclient CFObject.java,1.8,1.9 CFObjectStore.java,1.3,1.4 CFclient.java,1.30,
Status: Alpha
Brought to you by:
cavesomething
From: <jcr...@li...> - 2006-02-01 19:14:38
|
Update of /cvsroot/jcrossclient/jcrossclient In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3735 Modified Files: CFObject.java CFObjectStore.java CFclient.java Changelog ExamineWin.java InvWin.java MapWin.java PlayerStats.java ServerCon.java Settings.java Spell.java SpellWin.java StatbarWin.java TalkWin.java Log Message: ran pmd on code and fixed many minor things as a result Index: ServerCon.java =================================================================== RCS file: /cvsroot/jcrossclient/jcrossclient/ServerCon.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ServerCon.java 30 Nov 2005 17:13:26 -0000 1.3 --- ServerCon.java 1 Feb 2006 19:14:29 -0000 1.4 *************** *** 25,40 **** ! class ServerCon ! { ! CFclient mParent = null; ! Socket myconn; ! DataInputStream mInStream; ! DataOutputStream mOutStream; ! DataOutputStream mDOS; ByteArrayOutputStream mBAOS; ! byte last_command_sent; ! byte last_command_recieved; ! int response_time; ! boolean bad = false; byte[] tmpbuf; // timesaver --- 25,39 ---- ! class ServerCon { ! CFclient mParent = null; ! Socket myconn; ! DataInputStream mInStream; ! DataOutputStream mOutStream; ! DataOutputStream mDOS; ByteArrayOutputStream mBAOS; ! byte last_command_sent; ! byte last_command_recieved; ! int response_time; ! boolean bad = false; byte[] tmpbuf; // timesaver *************** *** 45,50 **** static boolean debugflag=false; ! static void debug(String str) ! { if(debugflag) System.out.println(str); --- 44,48 ---- static boolean debugflag=false; ! static void debug(String str) { if(debugflag) System.out.println(str); *************** *** 54,59 **** // connection "with extreme prejudice", // instead of just deleting the class ! public void disconnect() ! { try { mOutStream.close(); --- 52,56 ---- // connection "with extreme prejudice", // instead of just deleting the class ! public void disconnect() { try { mOutStream.close(); *************** *** 64,69 **** } ! public synchronized boolean dataWaiting() throws IOException ! { return (mInStream.available() > 0) ? true : false; } --- 61,65 ---- } ! public synchronized boolean dataWaiting() throws IOException { return (mInStream.available() > 0) ? true : false; } *************** *** 71,93 **** public boolean isBroke(){ return bad;} - // nasty experimental throwaway read - public synchronized byte[] rawread(int count) throws IOException - { - debug("HACK: raw-reading "+count+" bytes"); - byte tmpbuf[] = new byte[count]; - int bytesread = 0, offset=0; - - //mInStream.readFully(tmpbuf, offset, count); - - return tmpbuf; - } - // This isn't actually a LINE, but a logical unit in // the datastream. A crossfire 'packet' if you will. ! public synchronized void readLine() throws IOException ! { ! int data_read=0, offset=0; int i, j, datalen; - int available = mInStream.available(); String cmdstr = ""; --- 67,74 ---- public boolean isBroke(){ return bad;} // This isn't actually a LINE, but a logical unit in // the datastream. A crossfire 'packet' if you will. ! public synchronized void readLine() throws IOException { int i, j, datalen; String cmdstr = ""; *************** *** 128,133 **** // Also assume simple ASCII, so 'UTF' should be fine. I hope. // The server does NOT actually expect UTF encoding ! public synchronized void writeLine(String str) throws IOException ! { //toserver.writeUTF(str); //toserver.flush(); --- 109,113 ---- // Also assume simple ASCII, so 'UTF' should be fine. I hope. // The server does NOT actually expect UTF encoding ! public synchronized void writeLine(String str) throws IOException { //toserver.writeUTF(str); //toserver.flush(); *************** *** 141,168 **** // Also, only looks at lower-eight-bit value of string chars. // Should be identical for OUR purposes ! public synchronized void writeBytes(String data) throws IOException ! { debug("Writing data: "+data); int arraylen=data.length(); - - /*byte len_def[] = new byte[2]; - len_def[0] = (byte)((arraylen>>8) &0xFF); - len_def[1] = (byte)((arraylen) &0xFF);*/ - mDOS.writeShort((short) arraylen); mDOS.writeBytes(data); mBAOS.writeTo(mOutStream); - - //mOutStream.writeShort((short) arraylen); - //mOutStream.writeBytes(data); mOutStream.flush(); mBAOS.reset(); - - /*toserver.write(len_def, 0, 2); - toserver.writeBytes(data); - toserver.flush();*/ } --- 121,135 ---- // Also, only looks at lower-eight-bit value of string chars. // Should be identical for OUR purposes ! public synchronized void writeBytes(String data) throws IOException { debug("Writing data: "+data); int arraylen=data.length(); mDOS.writeShort((short) arraylen); mDOS.writeBytes(data); mBAOS.writeTo(mOutStream); mOutStream.flush(); mBAOS.reset(); } *************** *** 251,288 **** response_time = 0; ! } catch(UnknownHostException e) ! { debug("cant find host "+hostname); // should really exit here or something bad=true; return; ! } catch (IOException e) ! { debug("socket i/o error:"+e.getMessage()); bad=true; return; } - debug("GOT CONNECTION(I hope)"); - } - - /*public static int TwoByteConv(String str, int start) - { - int val; - val=(int)str.charAt(start) <<8; - val+=(int)str.charAt(start+1); - - return val; - } - public static int FourByteConv(String str, int start) - { - int val; - val =(int)str.charAt(start) <<24; - val+=(int)str.charAt(start+1) <<16; - val+=(int)str.charAt(start+2) <<8; - val+=(int)str.charAt(start+3); - - return val; - }*/ } --- 218,232 ---- response_time = 0; ! } catch(UnknownHostException e) { debug("cant find host "+hostname); // should really exit here or something bad=true; return; ! } catch (IOException e) { debug("socket i/o error:"+e.getMessage()); bad=true; return; } debug("GOT CONNECTION(I hope)"); } } Index: Spell.java =================================================================== RCS file: /cvsroot/jcrossclient/jcrossclient/Spell.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Spell.java 24 Jan 2006 18:56:31 -0000 1.3 --- Spell.java 1 Feb 2006 19:14:29 -0000 1.4 *************** *** 18,24 **** */ - - import java.lang.String; - public class Spell { int tag, level, time, mana, grace, damage, path, face; --- 18,21 ---- Index: Settings.java =================================================================== RCS file: /cvsroot/jcrossclient/jcrossclient/Settings.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Settings.java 25 Jan 2006 01:35:40 -0000 1.5 --- Settings.java 1 Feb 2006 19:14:29 -0000 1.6 *************** *** 187,191 **** public void reload (String buf) { - StringReader input = new StringReader(buf); StringBufferInputStream bais = new StringBufferInputStream(buf); try { val.load(bais); } catch(IOException err) { } --- 187,190 ---- Index: Changelog =================================================================== RCS file: /cvsroot/jcrossclient/jcrossclient/Changelog,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** Changelog 31 Jan 2006 00:28:49 -0000 1.34 --- Changelog 1 Feb 2006 19:14:29 -0000 1.35 *************** *** 267,268 **** --- 267,269 ---- InvWin - tidy up item locking, and make it actually work. + 01/02/2006 - everything - ran pmd on the code, fixed most of what it found, also some misc cleanups. \ No newline at end of file Index: InvWin.java =================================================================== RCS file: /cvsroot/jcrossclient/jcrossclient/InvWin.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** InvWin.java 31 Jan 2006 00:28:49 -0000 1.11 --- InvWin.java 1 Feb 2006 19:14:29 -0000 1.12 *************** *** 19,25 **** import java.awt.*; - import java.util.Hashtable; import java.util.Vector; - import java.util.Enumeration; import java.awt.event.*; --- 19,23 ---- *************** *** 246,250 **** public void mouseEntered(MouseEvent evt) { - return; } public void mouseExited(MouseEvent evt) { --- 244,247 ---- Index: StatbarWin.java =================================================================== RCS file: /cvsroot/jcrossclient/jcrossclient/StatbarWin.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** StatbarWin.java 25 Jan 2006 01:35:40 -0000 1.3 --- StatbarWin.java 1 Feb 2006 19:14:29 -0000 1.4 *************** *** 23,28 **** import java.awt.event.*; ! class StatbarWin extends Canvas implements ComponentListener ! { PlayerStats playerstats; --- 23,27 ---- import java.awt.event.*; ! class StatbarWin extends Canvas implements ComponentListener { PlayerStats playerstats; *************** *** 59,70 **** } ! public void componentMoved(ComponentEvent evt) { ! } ! public void componentHidden(ComponentEvent evt) { ! } public void componentShown(ComponentEvent evt) { // cheat... ! if(barheight==0) ! { debug("cheating to init statbar"); componentResized(evt); --- 58,66 ---- } ! public void componentMoved(ComponentEvent evt) {} ! public void componentHidden(ComponentEvent evt) {} public void componentShown(ComponentEvent evt) { // cheat... ! if(barheight==0) { debug("cheating to init statbar"); componentResized(evt); *************** *** 85,106 **** void errmsg(String str) { System.out.println(str); } ! public void setFireFlag(boolean flag) ! { fire_on=flag; drawFlagInfo(getGraphics()); } ! public void setRunFlag(boolean flag) ! { run_on=flag; drawFlagInfo(getGraphics()); } ! public void setLoadingFlag(boolean flag) ! { loading_pixmaps=flag; drawFlagInfo(getGraphics()); } // draw special status things that are either "on" or "off" ! void drawFlagInfo(Graphics gc) ! { // This would probably be better done by using "Label" // classes, and using Label.setText() --- 81,98 ---- void errmsg(String str) { System.out.println(str); } ! public void setFireFlag(boolean flag) { fire_on=flag; drawFlagInfo(getGraphics()); } ! public void setRunFlag(boolean flag) { run_on=flag; drawFlagInfo(getGraphics()); } ! public void setLoadingFlag(boolean flag) { loading_pixmaps=flag; drawFlagInfo(getGraphics()); } // draw special status things that are either "on" or "off" ! void drawFlagInfo(Graphics gc) { // This would probably be better done by using "Label" // classes, and using Label.setText() *************** *** 127,132 **** } ! void setStats () ! { hp = playerstats.hp; maxhp = playerstats.maxhp; --- 119,123 ---- } ! void setStats () { hp = playerstats.hp; maxhp = playerstats.maxhp; *************** *** 141,152 **** CFclient Parent; ! public StatbarWin(CFclient parent) ! { Parent = parent; addComponentListener(this); - int fontsize = parent.params.iget("fontsize"); - // note: this is INITIAL sizing. we'll dynamically // scale if we are resized. I hope. --- 132,140 ---- CFclient Parent; ! public StatbarWin(CFclient parent) { Parent = parent; addComponentListener(this); // note: this is INITIAL sizing. we'll dynamically // scale if we are resized. I hope. *************** *** 155,177 **** barxspace = parent.params.iget("StatbarWin.barSpace"); - // Now, adjust bar parameters based on our font (we've - // normalized everything to a 14pt font). - // - // Nah. This translation isnt too good, lets just let - // the user do it if they really want to change fonts - // barheight *= (fontsize/14.0); - // barwidth *= (fontsize/14.0); - // barxspace *= (fontsize/14.0); - setForeground(Color.black); - playerstats=parent.playerstats; setStats(); - } // called by CFclient, when stats are updated by server ! public void updateStats() ! { setStats(); fillBars(getGraphics()); --- 143,153 ---- barxspace = parent.params.iget("StatbarWin.barSpace"); setForeground(Color.black); playerstats=parent.playerstats; setStats(); } // called by CFclient, when stats are updated by server ! public void updateStats() { setStats(); fillBars(getGraphics()); *************** *** 182,190 **** // starting x,y pos are for the upper lefthand corner of BAR. // We, however, will draw AROUND that bar. ! void drawBarBox(Graphics gc, int minx, int miny) ! { ! int maxx = minx+barwidth; ! int maxy = miny+barheight; ! Color defcolor = gc.getColor(); --- 158,162 ---- // starting x,y pos are for the upper lefthand corner of BAR. // We, however, will draw AROUND that bar. ! void drawBarBox(Graphics gc, int minx, int miny) { Color defcolor = gc.getColor(); *************** *** 196,206 **** gc.drawRect(minx-2, miny-2, barwidth+2, barheight+2); - // return to default color, whatever that might be - /* - // Brian, this is an alternative. See if you like it - gc.setColor(Color.lightGray); - gc.draw3DRect(minx-1, miny-1, barwidth+2, barheight+2,false); - */ - gc.setColor(defcolor); --- 168,171 ---- *************** *** 209,214 **** // "full"-ness // This needs to mesh with drawStatBars() ! void fillBars(Graphics gc) ! { int xpos; --- 174,178 ---- // "full"-ness // This needs to mesh with drawStatBars() ! void fillBars(Graphics gc) { int xpos; *************** *** 236,251 **** void fillBar(Graphics gc, int x, int val, int maxval) { - int minx = x; int miny = ybaroffset; int maxy = barheight+ybaroffset; - - int yheight; - if(maxval==0) - yheight=0; - else - yheight= (val *barheight)/maxval; gc.clearRect(minx,miny,barwidth,barheight-yheight); --- 200,210 ---- void fillBar(Graphics gc, int x, int val, int maxval) { int minx = x; int miny = ybaroffset; int maxy = barheight+ybaroffset; int yheight; + if(maxval==0) yheight=0; + else yheight= (val *barheight)/maxval; gc.clearRect(minx,miny,barwidth,barheight-yheight); *************** *** 259,278 **** gc.setColor(Color.red); } ! ! gc.fillRect(minx,maxy-yheight,barwidth, ! yheight); ! // return to def color gc.setColor(defcolor); } - else - { - //debug("SKIPPING a statbar: maxval="+maxval+",val="+val); - } } // draw Centered String ! void drawCString(Graphics gc, String str, int xcenter, int yval){ FontMetrics fm =gc.getFontMetrics(); int stringwidth=fm.stringWidth(str); --- 218,230 ---- gc.setColor(Color.red); } ! gc.fillRect(minx, maxy-yheight, barwidth, yheight); // return to def color gc.setColor(defcolor); } } // draw Centered String ! void drawCString(Graphics gc, String str, int xcenter, int yval) { FontMetrics fm =gc.getFontMetrics(); int stringwidth=fm.stringWidth(str); *************** *** 281,286 **** } ! void drawStatBars(Graphics gc) ! { int xpos; int halfwidth=(barwidth/2); --- 233,237 ---- } ! void drawStatBars(Graphics gc) { int xpos; int halfwidth=(barwidth/2); *************** *** 308,319 **** } ! ! ! public void paint(Graphics gc) ! { drawStatBars(gc); fillBars(gc); drawFlagInfo(gc); } - } --- 259,266 ---- } ! public void paint(Graphics gc) { drawStatBars(gc); fillBars(gc); drawFlagInfo(gc); } } Index: MapWin.java =================================================================== RCS file: /cvsroot/jcrossclient/jcrossclient/MapWin.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** MapWin.java 25 Jan 2006 01:35:40 -0000 1.7 --- MapWin.java 1 Feb 2006 19:14:29 -0000 1.8 *************** *** 75,79 **** Thread.sleep(sleepms); //Thread.yield(); - } catch (Exception err) { --- 75,78 ---- *************** *** 81,87 **** err.getMessage()); } - } - } --- 80,84 ---- *************** *** 95,100 **** class MapSquare { - - // ugly and hardcoded public final static int NUMBER_OF_LAYERS = 3; --- 92,95 ---- *************** *** 102,106 **** private int xSize[] = new int[NUMBER_OF_LAYERS]; private int ySize[] = new int[NUMBER_OF_LAYERS]; - private boolean offmap[] = new boolean[NUMBER_OF_LAYERS]; private int darkness; --- 97,100 ---- *************** *** 111,120 **** public synchronized void setFace(int face, int layer) { ! if (layer > NUMBER_OF_LAYERS || layer < 1) { ! return; ! } ! if (face == -1) { ! return; ! } faces[layer - 1] = face; xSize[layer - 1] = 1; --- 105,109 ---- public synchronized void setFace(int face, int layer) { ! if (layer > NUMBER_OF_LAYERS || layer < 1 || face == -1) return; faces[layer - 1] = face; xSize[layer - 1] = 1; *************** *** 123,137 **** public synchronized void setFace(int face, int layer, ! int x, int y, boolean off_map) { ! if (layer > NUMBER_OF_LAYERS || layer < 1) { ! return; ! } ! if (face == -1) { ! return; ! } faces[layer - 1] = face; xSize[layer - 1] = x; ySize[layer - 1] = y; - offmap[layer - 1] = off_map; } --- 112,120 ---- public synchronized void setFace(int face, int layer, ! int x, int y) { ! if (layer > NUMBER_OF_LAYERS || layer < 1 || face == -1) return; faces[layer - 1] = face; xSize[layer - 1] = x; ySize[layer - 1] = y; } *************** *** 158,162 **** // return true iff this square contains any layer bigger than 1x1 - public synchronized boolean isBig() { for (int i = 0; i < NUMBER_OF_LAYERS; i++) { --- 141,144 ---- *************** *** 170,174 **** // return the largest x dimension of all the layers in the square - public synchronized int biggestX() { int maxX = 0; --- 152,155 ---- *************** *** 183,187 **** // return the largest Y dimension of all the layers in the square - public synchronized int biggestY() { int maxY = 0; --- 164,167 ---- *************** *** 194,211 **** } ! ! /* ! clones the square from this to target ! */ ! public synchronized void copyTo(MapSquare target) { for (int i = 0; i < NUMBER_OF_LAYERS; i++) { target.setFace(this.faces[i], i + 1, ! xSize[i], ySize[i], false); } target.setDarkness(this.darkness); ! /* ! FIXME ! */ } --- 174,185 ---- } ! /** clones the square from this to target */ public synchronized void copyTo(MapSquare target) { for (int i = 0; i < NUMBER_OF_LAYERS; i++) { target.setFace(this.faces[i], i + 1, ! xSize[i], ySize[i]); } target.setDarkness(this.darkness); ! /* FIXME */ } *************** *** 214,221 **** * if this square contains this face, we need to redraw it * ! * @param dirty_face Description of the Parameter */ public synchronized boolean containsFace(int face) { - for (int i = 0; i < NUMBER_OF_LAYERS; i++) { if (faces[i] == face) { --- 188,194 ---- * if this square contains this face, we need to redraw it * ! * @param dirty_face The face to redraw */ public synchronized boolean containsFace(int face) { for (int i = 0; i < NUMBER_OF_LAYERS; i++) { if (faces[i] == face) { *************** *** 226,230 **** } - public synchronized void clear() { for (int i = 0; i < NUMBER_OF_LAYERS; i++) { --- 199,202 ---- *************** *** 236,250 **** } - public static int getLayerCount() { return NUMBER_OF_LAYERS; } - public synchronized int getDarkness() { return this.darkness; } - public synchronized boolean setDarkness(int newvalue) { if (newvalue >= 0 && newvalue < 256) { --- 208,219 ---- *************** *** 629,651 **** // Cells[x][y].clear(); continue; ! /* ! if empty mask, none of the checks will be true. ! */ } if ((mask & DARKNESS_MASK) != 0) { ! /* ! darkness bit ! */ darkness = mapdata.readUnsignedByte(); pos += 1; - // System.out.println("darkness value is set, it is " + darkness); } else { darkness = -1; } ! /* correct? maybe we ought to leave ! darkness alone ! */ /* Reduce redundancy by putting the get image --- 598,613 ---- // Cells[x][y].clear(); continue; ! /* if empty mask, none of the checks will be true. */ } if ((mask & DARKNESS_MASK) != 0) { ! /* darkness bit */ darkness = mapdata.readUnsignedByte(); pos += 1; } else { darkness = -1; } ! /* correct? maybe we ought to leave darkness alone */ /* Reduce redundancy by putting the get image *************** *** 679,683 **** int width = next_face.getWidth(null); int height = next_face.getHeight(null); - boolean is_off_map = (x > XMAX + MAX_FACE_SIZE || y > YMAX + MAX_FACE_SIZE); x_size = (width % pixwidth == 0 ? 0 : 1) + width / pixwidth; y_size = (height % pixheight == 0 ? 0 : 1) + height / pixheight; --- 641,644 ---- *************** *** 697,701 **** Math.max(y, top + Cells[left][top].biggestY() - 1) ) ); Cells[left][top].setFace(faces[layer], layer + 1, x_size, ! y_size, is_off_map); } else if ((x < XMAX) && (y < YMAX)) { addDirtyRectangle(clippedRectangle(x + MAX_FACE_SIZE, --- 658,662 ---- Math.max(y, top + Cells[left][top].biggestY() - 1) ) ); Cells[left][top].setFace(faces[layer], layer + 1, x_size, ! y_size); } else if ((x < XMAX) && (y < YMAX)) { addDirtyRectangle(clippedRectangle(x + MAX_FACE_SIZE, *************** *** 709,717 **** } - - /* - It sucks that we have to register for ALL THESE - just to listen for mouse clicks. Sigh. - */ public void mouseClicked(MouseEvent evt) { int dx = (evt.getX() / pixwidth) - XMAX / 2; --- 670,673 ---- *************** *** 725,738 **** } - public void mouseEntered(MouseEvent evt) {} - - public void mouseExited(MouseEvent evt) {} - - public void mousePressed(MouseEvent evt) {} - - public void mouseReleased(MouseEvent evt) {} --- 681,687 ---- *************** *** 740,746 **** // given the cell coords, clear the cell on the // back-buffer - - - public void clearCell(int cellx, int celly) { --- 689,692 ---- Index: SpellWin.java =================================================================== RCS file: /cvsroot/jcrossclient/jcrossclient/SpellWin.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SpellWin.java 10 Jan 2006 16:22:45 -0000 1.3 --- SpellWin.java 1 Feb 2006 19:14:29 -0000 1.4 *************** *** 19,25 **** import java.awt.*; - import java.util.Hashtable; import java.util.LinkedList; - import java.util.Enumeration; import java.awt.event.*; --- 19,23 ---- *************** *** 174,186 **** } ! public void mouseEntered(MouseEvent evt) { ! return; ! } ! public void mouseExited(MouseEvent evt) { ! } ! public void mousePressed(MouseEvent evt) { ! } ! public void mouseReleased(MouseEvent evt) { ! } String create_status_string(Spell spell) { --- 172,179 ---- } ! public void mouseEntered(MouseEvent evt) {} ! public void mouseExited(MouseEvent evt) {} ! public void mousePressed(MouseEvent evt) {} ! public void mouseReleased(MouseEvent evt) {} String create_status_string(Spell spell) { Index: CFObject.java =================================================================== RCS file: /cvsroot/jcrossclient/jcrossclient/CFObject.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** CFObject.java 31 Jan 2006 00:28:49 -0000 1.8 --- CFObject.java 1 Feb 2006 19:14:29 -0000 1.9 *************** *** 26,31 **** */ - import java.lang.String; - public class CFObject { int Location; /* 0 for on ground, non-zero for object it is inside of*/ --- 26,29 ---- Index: TalkWin.java =================================================================== RCS file: /cvsroot/jcrossclient/jcrossclient/TalkWin.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TalkWin.java 12 Jan 2006 02:03:20 -0000 1.5 --- TalkWin.java 1 Feb 2006 19:14:29 -0000 1.6 *************** *** 23,35 **** import java.awt.*; - import java.awt.event.TextListener; import java.awt.event.ActionListener; import java.awt.event.KeyListener; - import java.awt.event.TextEvent; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; ! class TalkWin extends Panel implements ActionListener,KeyListener ! { CFclient Parent; --- 23,32 ---- import java.awt.*; import java.awt.event.ActionListener; import java.awt.event.KeyListener; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; ! class TalkWin extends Panel implements ActionListener,KeyListener { CFclient Parent; *************** *** 69,77 **** * "wait-for-single-char" input mode. */ ! public boolean waitingForSingleKey(){ if((querymode&QUERYSINGLECHAR)==0) return false; return true; } ! public boolean waitingForQuery(){ return ((querymode>0)); } --- 66,74 ---- * "wait-for-single-char" input mode. */ ! public boolean waitingForSingleKey() { if((querymode&QUERYSINGLECHAR)==0) return false; return true; } ! public boolean waitingForQuery() { return ((querymode>0)); } *************** *** 79,83 **** // When in query mode, need to call this, to set the focus // to the text input box ! public void setInputFocus(){ input.requestFocus(); } --- 76,80 ---- // When in query mode, need to call this, to set the focus // to the text input box ! public void setInputFocus() { input.requestFocus(); } *************** *** 88,93 **** * AND sets Parent to handle single-key entry for TextInput */ ! public void query(String querystring) ! { querymode=querystring.charAt(0); --- 85,89 ---- * AND sets Parent to handle single-key entry for TextInput */ ! public void query(String querystring) { querymode=querystring.charAt(0); *************** *** 99,112 **** if((querymode & QUERYSINGLECHAR) >0){ input.setBackground(Color.red); - // Yeah, kinda ugly. But since it has to - // listen to keys anyway, use it for us too. - // Turn off once we get the key. } if((querymode & QUERYPRIVATE)>0){ input.setBackground(input.getForeground()); - - //Well, I wouldd LIKE to use setEchoChar, but theres - // no way of UNsetting it... ??? - //input.setEchoChar('*'); } --- 95,101 ---- *************** *** 118,124 **** addDisplayLine(querystring.substring(startmsg)); } - - return; - } --- 107,110 ---- *************** *** 128,132 **** * important, because it does stuff after this is called. */ ! public void replytoserver(String reply){ debug("entered text in query mode"); input.setBackground(Color.white); --- 114,118 ---- * important, because it does stuff after this is called. */ ! public void replytoserver(String reply) { debug("entered text in query mode"); input.setBackground(Color.white); *************** *** 147,152 **** * than the originally generating component */ ! public void keyPressed(KeyEvent evt){ ! } public void keyReleased(KeyEvent evt){ --- 133,137 ---- * than the originally generating component */ ! public void keyPressed(KeyEvent evt){} public void keyReleased(KeyEvent evt){ *************** *** 167,172 **** } ! public void keyTyped(KeyEvent evt){ ! } /* This can only be called as a result of RETURN --- 152,156 ---- } ! public void keyTyped(KeyEvent evt){} /* This can only be called as a result of RETURN *************** *** 183,192 **** * tweaking to get it all working properly again. */ ! public void actionPerformed(ActionEvent evt) ! { String newtext = input.getText(); ! if(querymode>0) ! { //Any and all input is redirected to the server, // because it has asked a question. --- 167,174 ---- * tweaking to get it all working properly again. */ ! public void actionPerformed(ActionEvent evt) { String newtext = input.getText(); ! if(querymode>0) { //Any and all input is redirected to the server, // because it has asked a question. *************** *** 266,277 **** } ! void debug(String str) ! { if(Parent.debugflag) System.out.println(str); } ! public TalkWin(CFclient parent) ! { Parent = parent; setLayout(new BorderLayout()); --- 248,257 ---- } ! void debug(String str) { if(Parent.debugflag) System.out.println(str); } ! public TalkWin(CFclient parent) { Parent = parent; setLayout(new BorderLayout()); *************** *** 303,308 **** } ! public void paint(Graphics gc) ! { gc.drawString("Talk win", 10,10); } --- 283,287 ---- } ! public void paint(Graphics gc) { gc.drawString("Talk win", 10,10); } Index: CFObjectStore.java =================================================================== RCS file: /cvsroot/jcrossclient/jcrossclient/CFObjectStore.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CFObjectStore.java 27 Jan 2006 17:16:05 -0000 1.3 --- CFObjectStore.java 1 Feb 2006 19:14:29 -0000 1.4 *************** *** 18,25 **** */ - import java.util.Hashtable; - import java.util.Vector; - import java.util.Enumeration; - import java.lang.String; import java.util.*; --- 18,21 ---- *************** *** 116,124 **** int newloc = newobj.getLocation(); Integer key=new Integer(newtag); ! if(AllObjects.size()==0) { ! if(newtag != PlayerTag) { ! debug("ERROR: trying to add object "+newtag+"before player object!"); ! return; ! } } --- 112,118 ---- int newloc = newobj.getLocation(); Integer key=new Integer(newtag); ! if(AllObjects.size()==0 && newtag != PlayerTag) { ! debug("ERROR: trying to add object "+newtag+"before player object!"); ! return; } Index: PlayerStats.java =================================================================== RCS file: /cvsroot/jcrossclient/jcrossclient/PlayerStats.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PlayerStats.java 25 Jan 2006 02:57:58 -0000 1.7 --- PlayerStats.java 1 Feb 2006 19:14:29 -0000 1.8 *************** *** 277,284 **** public void modifyspell(DataInputStream spelldata) throws IOException { ! int i,type = spelldata.readByte(); int num = spelldata.readInt(); ! Spell tmp; ! tmp = find_spell(type); if (tmp != null) { if ((type & 1) > 0) tmp.setmana(spelldata.readShort()); --- 277,283 ---- public void modifyspell(DataInputStream spelldata) throws IOException { ! int type = spelldata.readByte(); int num = spelldata.readInt(); ! Spell tmp = find_spell(num); if (tmp != null) { if ((type & 1) > 0) tmp.setmana(spelldata.readShort()); *************** *** 289,293 **** public void removespell(DataInputStream spelldata) throws IOException { - int i; Spell tmp; int spellnum = spelldata.readInt(); --- 288,291 ---- Index: ExamineWin.java =================================================================== RCS file: /cvsroot/jcrossclient/jcrossclient/ExamineWin.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ExamineWin.java 15 Jan 2006 00:16:18 -0000 1.7 --- ExamineWin.java 1 Feb 2006 19:14:29 -0000 1.8 *************** *** 162,166 **** public void mouseEntered(MouseEvent evt) { - return; } public void mouseExited(MouseEvent evt) { --- 162,165 ---- Index: CFclient.java =================================================================== RCS file: /cvsroot/jcrossclient/jcrossclient/CFclient.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** CFclient.java 31 Jan 2006 00:28:49 -0000 1.30 --- CFclient.java 1 Feb 2006 19:14:29 -0000 1.31 *************** *** 278,294 **** case KeyEvent.VK_CONTROL: case KeyEvent.VK_SHIFT: ! if(run_on) { ! if(keycode==params.getRunKey()) { ! releasecmd="run_stop"; ! run_on=false; ! miscwin.setRunFlag(false); ! } } ! if(fire_on) { ! if(keycode==params.getFireKey()) { ! releasecmd="fire_stop"; ! fire_on=false; ! miscwin.setFireFlag(false); ! } } break; --- 278,290 ---- case KeyEvent.VK_CONTROL: case KeyEvent.VK_SHIFT: ! if(run_on && keycode==params.getRunKey()) { ! releasecmd="run_stop"; ! run_on=false; ! miscwin.setRunFlag(false); } ! if(fire_on && keycode==params.getFireKey()) { ! releasecmd="fire_stop"; ! fire_on=false; ! miscwin.setFireFlag(false); } break; *************** *** 783,787 **** name_pl=names[1]; thisobj.setname(name); ! thisobj.setname_pl(name); should_update = true; } --- 779,783 ---- name_pl=names[1]; thisobj.setname(name); ! thisobj.setname_pl(name_pl); should_update = true; } *************** *** 809,823 **** int strpos = 0; int tag = 0, len = itemdata.available(); - boolean examineflag = false, invflag = false; while ( strpos < len ) { - //tag=FourByteToInt(cmd, strpos); tag = itemdata.readInt(); ! strpos += 4; debug("DelItem " + tag); - CFObject oldobj = allobjects.getCFObject(tag); allobjects.delCFObject(tag); } - } --- 805,815 ---- int strpos = 0; int tag = 0, len = itemdata.available(); while ( strpos < len ) { tag = itemdata.readInt(); ! strpos += 4; debug("DelItem " + tag); allobjects.delCFObject(tag); } } *************** *** 1007,1011 **** File faceFile = new File(facePath); ImageIO.write(image, "png", faceFile); - FileOutputStream fos = new FileOutputStream(faceFile); mHTAskedPixMaps.remove(faceInt); --- 999,1002 ---- *************** *** 1076,1083 **** // interpret commands sent from server. ! void evalSrvCmd(String cmd, DataInputStream data) throws IOException ! { ! //debug("server cmd is " + cmd + " [" + cmd.length() + "]."); ! if(cmd.startsWith("image")) { if(lastcommand==0) { --- 1067,1071 ---- // interpret commands sent from server. ! void evalSrvCmd(String cmd, DataInputStream data) throws IOException { if(cmd.startsWith("image")) { if(lastcommand==0) { *************** *** 1104,1244 **** debug("Got server cmd \"" + cmd + "\""); } ! if(cmd.startsWith("delitem")) { DelItemCmd(data); ! return; ! } ! if(cmd.startsWith("face")) { FaceCmd(data); return; ! } ! if(cmd.startsWith("item2")) { ItemCmd(data, 2); ! return; ! } ! if(cmd.startsWith("item1")) { ItemCmd(data, 1); ! return; ! } ! if(cmd.startsWith("addspell")) { playerstats.addspell(data); spellwin.updateSpells(); ! return; ! } ! if(cmd.startsWith("updspell")) { playerstats.modifyspell(data); ! return; ! } ! if(cmd.startsWith("delspell")) { playerstats.removespell(data); spellwin.updateSpells(); ! return; ! } ! if(cmd.startsWith("map1")) { /* this includes map1a */ mapwin.map1aRead(data); ! return; ! } ! if(cmd.startsWith("newmap")) { if (mapwin !=null) mapwin.clearmap(); ! return; ! } ! if(cmd.startsWith("player")) { PlayerCmd(data); ! return; ! } ! if(cmd.startsWith("stats")) { ! // statwin.updateStats(datastr); playerstats.update(data); - statwin.updateStats(); miscwin.updateStats(); skillwin.update_skills(); ! ! return; ! } ! if (cmd.startsWith("comc")) { mConnection.command_completed(data); ! return; ! } ! if(cmd.startsWith("upditem")) { UpdItemCmd(data); ! return; ! } ! if (cmd.startsWith("replyinfo")) { parse_info_reply(data); ! return; ! } ! ! int size = data.available(); ! byte[] databa = new byte[size]; ! data.readFully(databa); ! String datastr = new String(databa); ! if (cmd.startsWith("map_scroll")) { ! MapScrollCmd(datastr); ! return; ! } ! if(cmd.startsWith("delinv")) { ! DelInvCmd(datastr); ! return; ! } ! if(cmd.startsWith("drawinfo")) { ! talkwin.addDisplayLine(datastr.substring(2) + "\n", (byte)datastr.charAt(0)); ! debug(" (drawinfo cmd)"); ! return; ! } ! if(cmd.startsWith("magicmap")) { ! magicmap.parse(datastr); ! return; ! } ! if(cmd.startsWith("anim")) { ! debug("IGNORING anim cmd"); ! return; ! } ! if(cmd.startsWith("version")) { ! // we are actually supposed to read two separate strings ! // here. oh well. ! String verstring = datastr; ! System.out.println("Vers : " + verstring); ! if(verstring.length() > 4) ! verstring=verstring.substring(0,4); ! server_version = Integer.parseInt(verstring); ! talkwin.addDisplayLine("server uses protocol version " ! +server_version+"\n"); ! debug(" (version cmd)"); ! if(server_version>protocol_version) ! { ! talkwin.addDisplayLine("WARNING: server version higher than we expect\n"); } - - writePVersion(); - return; - } - if(cmd.startsWith("addme_failed")) { - debug("Addme FAILED?!!"); - return; - } - if(cmd.startsWith("setup")) { - System.out.println("response to setup command: " + datastr); - return; - } - if(cmd.startsWith("addme_success")) { - debug("Successful addme"); - return; - } - if(cmd.startsWith("query")) { - debug("QUERY asked"); - in_query=true; - talkwin.query(datastr); - - // remember to call sendReply() - return; } - errmsg("UNRECOGNISED COMMAND FROM SERVER: "+cmd); - errmsg("\nEither corrupted datastream, or out-of-date client"); - errmsg(" QUITTING"); - System.exit(0); } --- 1092,1182 ---- debug("Got server cmd \"" + cmd + "\""); } ! if (cmd.startsWith("delitem")) { DelItemCmd(data); ! } else if (cmd.startsWith("face")) { FaceCmd(data); return; ! } else if (cmd.startsWith("item2")) { ItemCmd(data, 2); ! } else if (cmd.startsWith("item1")) { ItemCmd(data, 1); ! } else if (cmd.startsWith("addspell")) { playerstats.addspell(data); spellwin.updateSpells(); ! } else if (cmd.startsWith("updspell")) { playerstats.modifyspell(data); ! } else if (cmd.startsWith("delspell")) { playerstats.removespell(data); spellwin.updateSpells(); ! } else if (cmd.startsWith("map1")) { /* this includes map1a */ mapwin.map1aRead(data); ! } else if (cmd.startsWith("newmap")) { if (mapwin !=null) mapwin.clearmap(); ! } else if (cmd.startsWith("player")) { PlayerCmd(data); ! } else if (cmd.startsWith("stats")) { playerstats.update(data); statwin.updateStats(); miscwin.updateStats(); skillwin.update_skills(); ! } else if (cmd.startsWith("comc")) { mConnection.command_completed(data); ! } else if (cmd.startsWith("upditem")) { UpdItemCmd(data); ! } else if (cmd.startsWith("replyinfo")) { parse_info_reply(data); ! } else { ! int size = data.available(); ! byte[] databa = new byte[size]; ! data.readFully(databa); ! String datastr = new String(databa); ! if (cmd.startsWith("map_scroll")) { ! MapScrollCmd(datastr); ! } else if (cmd.startsWith("delinv")) { ! DelInvCmd(datastr); ! } else if (cmd.startsWith("drawinfo")) { ! talkwin.addDisplayLine(datastr.substring(2) + "\n", (byte)datastr.charAt(0)); ! debug(" (drawinfo cmd)"); ! } else if (cmd.startsWith("magicmap")) { ! magicmap.parse(datastr); ! } else if (cmd.startsWith("anim")) { ! debug("IGNORING anim cmd"); ! } else if (cmd.startsWith("version")) { ! // we are actually supposed to read two separate strings ! // here. oh well. ! String verstring = datastr; ! System.out.println("Vers : " + verstring); ! if(verstring.length() > 4) ! verstring=verstring.substring(0,4); ! server_version = Integer.parseInt(verstring); ! talkwin.addDisplayLine("server uses protocol version " ! +server_version+"\n"); ! debug(" (version cmd)"); ! if(server_version>protocol_version) { ! talkwin.addDisplayLine("WARNING: server version higher than we expect\n"); ! } ! writePVersion(); ! } else if (cmd.startsWith("addme_failed")) { ! debug("Addme FAILED?!!"); ! } else if (cmd.startsWith("setup")) { ! System.out.println("response to setup command: " + datastr); ! } else if (cmd.startsWith("addme_success")) { ! debug("Successful addme"); ! } else if (cmd.startsWith("query")) { ! debug("QUERY asked"); ! in_query=true; ! talkwin.query(datastr); ! // remember to call sendReply() ! } else { ! errmsg("UNRECOGNISED COMMAND FROM SERVER: "+cmd); ! errmsg("\nEither corrupted datastream, or out-of-date client"); ! errmsg(" QUITTING"); ! System.exit(0); } } } *************** *** 1495,1499 **** void writePVersion() { try { - String inmsg; mConnection.writeBytes("version "+protocol_version + " 1027 JCrossclient 1.0 alpha-3CVS"); /* make the server use the new map style commands */ --- 1433,1436 ---- *************** *** 1502,1507 **** mConnection.writeBytes("requestinfo spell_paths"); mConnection.writeBytes("addme"); - - }catch (java.io.IOException e) { debug("sigh. initial handshake from server failed"); --- 1439,1442 ---- |