[Jcrossclient-cvs] jcrossclient CFObjectStore.java,1.1.1.1,1.2
Status: Alpha
Brought to you by:
cavesomething
From: <jcr...@li...> - 2006-01-27 03:00:40
|
Update of /cvsroot/jcrossclient/jcrossclient In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5044 Modified Files: CFObjectStore.java Log Message: whitespace cleanups Index: CFObjectStore.java =================================================================== RCS file: /cvsroot/jcrossclient/jcrossclient/CFObjectStore.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** CFObjectStore.java 9 Nov 2005 03:12:07 -0000 1.1.1.1 --- CFObjectStore.java 27 Jan 2006 03:00:26 -0000 1.2 *************** *** 22,25 **** --- 22,26 ---- import java.util.Enumeration; import java.lang.String; + /* * This class holds information about all objects we know about *************** *** 37,42 **** // What IS the different between public and defaulted classes anyways? ! public class CFObjectStore ! { Vector objs_on_floor; // cache Vector PlayerInv; // cache --- 38,42 ---- // What IS the different between public and defaulted classes anyways? ! public class CFObjectStore { Vector objs_on_floor; // cache Vector PlayerInv; // cache *************** *** 48,53 **** // reinit things if we connect to a new server suddenly ! public void reinit() ! { AllObjects.clear(); objs_on_floor=new Vector(); --- 48,52 ---- // reinit things if we connect to a new server suddenly ! public void reinit() { AllObjects.clear(); objs_on_floor=new Vector(); *************** *** 56,70 **** } ! public void setPlayerTag(int ptag) ! { PlayerTag = ptag; } ! public int getPlayerTag() ! { return PlayerTag; } ! CFObject getPlayerObject() ! { return getCFObject(PlayerTag); } --- 55,66 ---- } ! public void setPlayerTag(int ptag) { PlayerTag = ptag; } ! public int getPlayerTag() { return PlayerTag; } ! CFObject getPlayerObject() { return getCFObject(PlayerTag); } *************** *** 72,82 **** // Maybe we should cache THIS, as well as the floor thing. // dunno. sigh. ! public Vector getPlayerInv() ! { return PlayerInv; } ! public CFObject getCFObject(int tag) ! { Integer locator=new Integer(tag); CFObject obj; --- 68,76 ---- // Maybe we should cache THIS, as well as the floor thing. // dunno. sigh. ! public Vector getPlayerInv() { return PlayerInv; } ! public CFObject getCFObject(int tag) { Integer locator=new Integer(tag); CFObject obj; *************** *** 85,105 **** } ! public void delCFObject(int tag) ! { Integer locator=new Integer(tag); CFObject oldobj = (CFObject)AllObjects.remove(locator); ! if(oldobj==null) ! { System.out.println("Error: trying to delete null object"); return; } ! if(oldobj.onFloor()) ! { deleteObjOnFloor(oldobj); toplevel.updateFloor(); } ! else ! { // probably should recurse or something? maybe not. deleteObjInInv(oldobj); --- 79,95 ---- } ! public void delCFObject(int tag) { Integer locator=new Integer(tag); CFObject oldobj = (CFObject)AllObjects.remove(locator); ! if(oldobj==null) { System.out.println("Error: trying to delete null object"); return; } ! if(oldobj.onFloor()) { deleteObjOnFloor(oldobj); toplevel.updateFloor(); } ! else { // probably should recurse or something? maybe not. deleteObjInInv(oldobj); *************** *** 111,123 **** * or just add a new object, as appropriate */ ! public void addCFObject(CFObject newobj) ! { int newtag = newobj.Tag; 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; --- 101,110 ---- * or just add a new object, as appropriate */ ! public void addCFObject(CFObject newobj) { int newtag = newobj.Tag; 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; *************** *** 129,135 **** if(oldobj!=null) oldloc = oldobj.getLocation(); - - AllObjects.put(key, newobj); --- 116,120 ---- *************** *** 140,157 **** */ ! if(oldloc == newloc) ! { /* existing object, AND same placed object */ int oldindex; oldindex=objs_on_floor.indexOf(oldobj); ! if(oldindex != -1) ! { objs_on_floor.setElementAt(newobj, oldindex); } oldindex=PlayerInv.indexOf(oldobj); ! if(oldindex != -1) ! { PlayerInv.setElementAt(newobj, oldindex); } --- 125,139 ---- */ ! if(oldloc == newloc) { /* existing object, AND same placed object */ int oldindex; oldindex=objs_on_floor.indexOf(oldobj); ! if(oldindex != -1) { objs_on_floor.setElementAt(newobj, oldindex); } oldindex=PlayerInv.indexOf(oldobj); ! if(oldindex != -1) { PlayerInv.setElementAt(newobj, oldindex); } *************** *** 161,190 **** else toplevel.updateInventory(); - - return; } - // else... ! if(oldloc==0) ! { deleteObjOnFloor(oldobj); } ! else ! { ! if(oldloc >0) ! { deleteObjInInv(oldobj); } } ! ! if(newloc==0) ! { objs_on_floor.addElement(newobj); ! } else ! { PlayerInv.addElement(newobj); } - if(oldloc==0 || newloc ==0) toplevel.updateFloor(); --- 143,162 ---- else toplevel.updateInventory(); return; } // else... ! if(oldloc==0) { deleteObjOnFloor(oldobj); } ! else { ! if(oldloc >0) { deleteObjInInv(oldobj); } } ! if(newloc==0) { objs_on_floor.addElement(newobj); ! } else { PlayerInv.addElement(newobj); } if(oldloc==0 || newloc ==0) toplevel.updateFloor(); *************** *** 193,198 **** } ! void debug(String msg) ! { if(toplevel.debugflag) System.out.println(msg); --- 165,169 ---- } ! void debug(String msg) { if(toplevel.debugflag) System.out.println(msg); *************** *** 202,207 **** // note: there is no order to the array. some slots may be // 0, at any slot ! public Vector getObjsOnFloor() ! { return objs_on_floor; } --- 173,177 ---- // note: there is no order to the array. some slots may be // 0, at any slot ! public Vector getObjsOnFloor() { return objs_on_floor; } *************** *** 210,224 **** // note: this means DIRECTLY carried. // It does not recurse into bags, for example ! public Vector getCarriedBy(int objtag) ! { Vector carried=new Vector(); Enumeration objs = AllObjects.elements(); CFObject tmpobj; ! while(objs.hasMoreElements()) ! { tmpobj= (CFObject)objs.nextElement(); ! if(tmpobj.getLocation() == objtag) ! { carried.addElement(tmpobj); } --- 180,191 ---- // note: this means DIRECTLY carried. // It does not recurse into bags, for example ! public Vector getCarriedBy(int objtag) { Vector carried=new Vector(); Enumeration objs = AllObjects.elements(); CFObject tmpobj; ! while(objs.hasMoreElements()) { tmpobj= (CFObject)objs.nextElement(); ! if(tmpobj.getLocation() == objtag) { carried.addElement(tmpobj); } *************** *** 231,245 **** // It's more important to lock on DELETE, than it is on add // Only object deletion makes big problems, in ExamineWin ! public void deleteObjInInv(CFObject obj) ! { ! synchronized (PlayerInv) ! { PlayerInv.removeElement(obj); } } ! public void deleteObjOnFloor(CFObject obj) ! { ! synchronized (objs_on_floor) ! { objs_on_floor.removeElement(obj); } --- 198,208 ---- // It's more important to lock on DELETE, than it is on add // Only object deletion makes big problems, in ExamineWin ! public void deleteObjInInv(CFObject obj) { ! synchronized (PlayerInv) { PlayerInv.removeElement(obj); } } ! public void deleteObjOnFloor(CFObject obj) { ! synchronized (objs_on_floor) { objs_on_floor.removeElement(obj); } *************** *** 248,259 **** // Note that we do NOT trigger a floor update, because // the floor never remains empty ! public void deleteAllOnFloor() ! { CFObject floorobj; int floorcount=objs_on_floor.size(); ! synchronized (objs_on_floor) ! { ! for(int oc=0; oc<floorcount; oc++) ! { floorobj = (CFObject)objs_on_floor.elementAt(oc); AllObjects.remove(new Integer(floorobj.getTag())); --- 211,219 ---- // Note that we do NOT trigger a floor update, because // the floor never remains empty ! public void deleteAllOnFloor() { CFObject floorobj; int floorcount=objs_on_floor.size(); ! synchronized (objs_on_floor) { ! for(int oc=0; oc<floorcount; oc++) { floorobj = (CFObject)objs_on_floor.elementAt(oc); AllObjects.remove(new Integer(floorobj.getTag())); *************** *** 261,269 **** objs_on_floor.removeAllElements(); } - //toplevel.updateFloor(); } ! public void deleteCarriedBy(int carrytag) ! { debug("deleteCarriedBy("+carrytag+")"); Enumeration objs = AllObjects.elements(); --- 221,227 ---- objs_on_floor.removeAllElements(); } } ! public void deleteCarriedBy(int carrytag) { debug("deleteCarriedBy("+carrytag+")"); Enumeration objs = AllObjects.elements(); *************** *** 271,276 **** CFObject oldobj; ! while(objs.hasMoreElements()) ! { oldobj= (CFObject)objs.nextElement(); location=oldobj.getLocation(); --- 229,233 ---- CFObject oldobj; ! while(objs.hasMoreElements()) { oldobj= (CFObject)objs.nextElement(); location=oldobj.getLocation(); *************** *** 278,283 **** tag=oldobj.getTag(); ! if(location != carrytag) ! { debug("delete: skipping obj "+tag); continue; --- 235,239 ---- tag=oldobj.getTag(); ! if(location != carrytag) { debug("delete: skipping obj "+tag); continue; *************** *** 285,294 **** debug("delete: trying to delete obj "+tag); ! if(location==0) ! { deleteObjOnFloor(oldobj); } ! else ! { deleteObjInInv(oldobj); } --- 241,248 ---- debug("delete: trying to delete obj "+tag); ! if(location==0) { deleteObjOnFloor(oldobj); } ! else { deleteObjInInv(oldobj); } *************** *** 296,305 **** } toplevel.updateInventory(); - } - ! public CFObjectStore(CFclient top) ! { // hopefully, '100' is larger than the default, // otherwise, we are hurting ourselves... --- 250,256 ---- } toplevel.updateInventory(); } ! public CFObjectStore(CFclient top) { // hopefully, '100' is larger than the default, // otherwise, we are hurting ourselves... *************** *** 309,314 **** toplevel = top; } - - } - --- 260,262 ---- |