[Jcrossclient-cvs] jcrossclient CFObject.java,1.6,1.7 CFObjectStore.java,1.2,1.3 CFclient.java,1.28,
Status: Alpha
Brought to you by:
cavesomething
From: <jcr...@li...> - 2006-01-27 17:16:23
|
Update of /cvsroot/jcrossclient/jcrossclient In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13648 Modified Files: CFObject.java CFObjectStore.java CFclient.java Changelog Log Message: item2 support and inventory sorting Index: CFObject.java =================================================================== RCS file: /cvsroot/jcrossclient/jcrossclient/CFObject.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CFObject.java 15 Jan 2006 00:16:18 -0000 1.6 --- CFObject.java 27 Jan 2006 17:16:05 -0000 1.7 *************** *** 28,34 **** import java.lang.String; ! ! public class CFObject ! { int Location; /* 0 for on ground, non-zero for object it is inside of*/ int Tag; /* unique identifier of object (?) */ --- 28,32 ---- import java.lang.String; ! public class CFObject { int Location; /* 0 for on ground, non-zero for object it is inside of*/ int Tag; /* unique identifier of object (?) */ *************** *** 37,41 **** int Face; /* aka graphics image identifier */ String Name, Name_pl; ! int NumObjs; int AnimId; --- 35,39 ---- int Face; /* aka graphics image identifier */ String Name, Name_pl; ! int type; int NumObjs; int AnimId; *************** *** 64,67 **** --- 62,68 ---- } + public void setType(int newtype) { + type=newtype; + } public void setNumObjs(int nof) { NumObjs=nof; *************** *** 133,136 **** --- 134,140 ---- return Tag; } + public int getType() { + return type; + } /* since we don't actually care about the current locked state of an Index: CFObjectStore.java =================================================================== RCS file: /cvsroot/jcrossclient/jcrossclient/CFObjectStore.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CFObjectStore.java 27 Jan 2006 03:00:26 -0000 1.2 --- CFObjectStore.java 27 Jan 2006 17:16:05 -0000 1.3 *************** *** 22,25 **** --- 22,36 ---- import java.util.Enumeration; import java.lang.String; + import java.util.*; + + + /* small class to allow CFObjects to be sorted by type */ + class CFObjcompare implements java.util.Comparator { + public int compare(Object o1, Object o2) { + CFObject ob1 = (CFObject)o1; + CFObject ob2 = (CFObject)o2; + return ob1.getType() - ob2.getType(); + } + } /* *************** *** 137,140 **** --- 148,152 ---- if(oldindex != -1) { PlayerInv.setElementAt(newobj, oldindex); + Collections.sort(PlayerInv, new CFObjcompare()); } *************** *** 158,161 **** --- 170,174 ---- } else { PlayerInv.addElement(newobj); + Collections.sort(PlayerInv, new CFObjcompare()); } if(oldloc==0 || newloc ==0) Index: CFclient.java =================================================================== RCS file: /cvsroot/jcrossclient/jcrossclient/CFclient.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** CFclient.java 27 Jan 2006 00:01:39 -0000 1.28 --- CFclient.java 27 Jan 2006 17:16:05 -0000 1.29 *************** *** 647,701 **** // add possibly multiple objects, to a single "location" // "location" can be either the floor, the player, or some object. ! void ItemCmd(DataInputStream itemdata) throws IOException { ! CFObject newobj; ! int strpos = 0; ! int loc, tag, flags, weight,face; ! String name, name_pl; ! String[] names = new String[2]; ! int namelen, len = itemdata.available(); ! byte buf[]; ! ! loc = itemdata.readInt(); ! strpos += 4; ! ! while ( strpos < len ) { ! tag = itemdata.readInt(); ! strpos += 4; ! flags = itemdata.readInt(); ! strpos += 4; ! weight = itemdata.readInt(); ! strpos += 4; ! face = itemdata.readInt(); ! strpos += 4; ! ! namelen = itemdata.readUnsignedByte(); ! strpos += 1; ! buf = new byte[namelen]; ! itemdata.readFully(buf); ! name = new String(buf); ! strpos += namelen; ! /* this bit sends us the length of both the singular ! * and plural names, we want to seperate them.*/ ! names = name.split("\0", 2); ! name=names[0]; ! name_pl=names[1]; ! ! newobj = new CFObject(loc, tag, flags, weight, face, name, name_pl); ! allobjects.addCFObject(newobj); ! debug("added object "+tag+", location "+loc+", name "+name+" flags "+flags); ! ! // need to udpate, even if location is BAG that ! // player is holding. I suppose. sigh. ! // loc==0, means on floor ! } ! ! } ! ! // add possibly multiple objects, to a single "location" ! // "location" can be either the floor, the player, or some object. ! void Item1Cmd(DataInputStream itemdata) throws IOException { CFObject newobj; int strpos = 0; ! int len, loc, tag, flags, weight,face; String name, name_pl; String[] names = new String[2]; --- 647,654 ---- // add possibly multiple objects, to a single "location" // "location" can be either the floor, the player, or some object. ! void ItemCmd(DataInputStream itemdata, int version) throws IOException { CFObject newobj; int strpos = 0; ! int len, loc, tag, flags, weight, face, type; String name, name_pl; String[] names = new String[2]; *************** *** 746,753 **** newobj.setNumObjs(numitem); newobj.setAnimId(anim_id); allobjects.addCFObject(newobj); ! debug("Item1cmd: added object "+tag+", location "+loc+", name "+name+" flags "+flags); // need to update, even if location is BAG that --- 699,711 ---- newobj.setNumObjs(numitem); newobj.setAnimId(anim_id); + if (version == 2) { + type = itemdata.readShort(); + strpos += 2; + newobj.setType(type); + } allobjects.addCFObject(newobj); ! debug("ItemCmd: added object "+tag+", location "+loc+", name "+name+" flags "+flags); // need to update, even if location is BAG that *************** *** 1154,1163 **** return; } ! if(cmd.startsWith("item1")) { ! Item1Cmd(data); return; } ! if(cmd.startsWith("item")) { ! ItemCmd(data); return; } --- 1112,1121 ---- return; } ! if(cmd.startsWith("item2")) { ! ItemCmd(data, 2); return; } ! if(cmd.startsWith("item1")) { ! ItemCmd(data, 1); return; } *************** *** 1540,1544 **** mConnection.writeBytes("version "+protocol_version + " 1027 JCrossclient 1.0 alpha-3CVS"); /* make the server use the new map style commands */ ! mConnection.writeBytes("setup map1cmd 1 exp64 1 spellmon 1 newmapcmd 1 mapsize " + mapwin.XMAX + "x" + mapwin.YMAX); mConnection.writeBytes("requestinfo skill_info"); mConnection.writeBytes("requestinfo spell_paths"); --- 1498,1502 ---- mConnection.writeBytes("version "+protocol_version + " 1027 JCrossclient 1.0 alpha-3CVS"); /* make the server use the new map style commands */ ! mConnection.writeBytes("setup map1cmd 1 itemcmd 2 exp64 1 spellmon 1 newmapcmd 1 mapsize " + mapwin.XMAX + "x" + mapwin.YMAX); mConnection.writeBytes("requestinfo skill_info"); mConnection.writeBytes("requestinfo spell_paths"); Index: Changelog =================================================================== RCS file: /cvsroot/jcrossclient/jcrossclient/Changelog,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** Changelog 27 Jan 2006 00:01:39 -0000 1.32 --- Changelog 27 Jan 2006 17:16:05 -0000 1.33 *************** *** 250,251 **** --- 250,261 ---- - Show map again when a key or button is pressed. - Fix some colour definitions + + CFObject - add type, get type and set type + + CFObjectStore - add comparator class to sort items by type, + - resort inventory whenever new items are added to it + + CFclient - send itemcmd 2 in setup flags + - Remove support for 'item' command (horribly outdated) + - add support for 'item2' command + - merge item handling commands into one function. |