[Megameknet-cvs] MegaMekNET/src/server/campaign TickThread.java,1.5,1.6 CampaignMain.java,1.125,1.12
Status: Inactive
Brought to you by:
mcwizard
From: Immanuel S. <im...@us...> - 2005-04-11 20:02:10
|
Update of /cvsroot/megameknet/MegaMekNET/src/server/campaign In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15726/src/server/campaign Modified Files: TickThread.java CampaignMain.java Log Message: fixed xml saving, now featuring asynchron saves. Index: TickThread.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/TickThread.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TickThread.java 27 Mar 2005 08:36:36 -0000 1.5 --- TickThread.java 11 Apr 2005 20:01:29 -0000 1.6 *************** *** 73,77 **** try { myCampaign.toFile(); ! myCampaign.saveData(); myCampaign.toAllUsers("AutoSave succeeded!"); } --- 73,77 ---- try { myCampaign.toFile(); ! myCampaign.saveData(null); myCampaign.toAllUsers("AutoSave succeeded!"); } Index: CampaignMain.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/CampaignMain.java,v retrieving revision 1.125 retrieving revision 1.126 diff -C2 -d -r1.125 -r1.126 *** CampaignMain.java 11 Apr 2005 19:13:19 -0000 1.125 --- CampaignMain.java 11 Apr 2005 20:01:30 -0000 1.126 *************** *** 78,82 **** import common.BlackBoardMessage; import common.CampaignData; - import common.House; import common.Influences; import common.PlanetEnvironment; --- 78,81 ---- *************** *** 86,91 **** import common.constants.PlayerStatus; import common.util.MMNetXStream; - import common.visitor.Visitor; - import common.visitor.Visitorable; public class CampaignMain implements Serializable, StatusChangeListener { --- 85,88 ---- *************** *** 234,269 **** * Save the whole campaign state to xml */ ! public void saveData() { ! SXMLSaveVisitor saver = new SXMLSaveVisitor(); ! // Units updateUnitList(); ! saver.toXml("campaign/unit.xml", "units", units.values()); ! // Houses (one file for each house because memory concerns) ! for (Iterator it = data.getAllHouses().iterator(); it.hasNext();) { ! SHouse house = (SHouse)it.next(); ! saver.toXml("campaign/"+house.getName()+".xml", house); ! } ! // Write all house names (on the fly). ! saver.toXml("campaign/houses.xml", new Visitorable(){ ! public Object visit(Visitor visitor) { ! Element e = new Element("houses"); ! for (Iterator it = data.getAllHouses().iterator(); it.hasNext();) { ! House house = (House)it.next(); ! Element h = new Element("house"); ! h.setAttribute("class", house.getClass().getName()); ! h.setAttribute("file", "campaign/"+house.getName()+".xml"); ! e.addContent(h); ! } ! return e; ! } ! }); ! // Blackboard ! saver.toXml("campaign/blackboard.xml", getBlackBoard()); ! // Market ! saver.toXml("campaign/blackmarket.xml", getMarket()); ! // Planet environment ! saver.toXml("campaign/planetEnvironment.xml", "planetEnvironments", data.getAllTerrains()); ! // Planets ! saver.toXml("campaign/planet.xml", "planets", data.getAllPlanets()); } --- 231,237 ---- * Save the whole campaign state to xml */ ! public void saveData(String userToInform) { updateUnitList(); ! new SXMLSaveVisitor(units.values(), data, blackBoard, market, userToInform); } *************** *** 412,416 **** // saving in fresh xml format for the next run to make it better :) ! saveData(); } // end loading old .dat file format --- 380,384 ---- // saving in fresh xml format for the next run to make it better :) ! saveData(null); } // end loading old .dat file format *************** *** 626,630 **** out = new FileOutputStream("./campaign/blackboard.dat"); print = new PrintStream(out); ! for (Iterator it = blackBoard.iterator(); it.hasNext();) { BlackBoardMessage bbm = (BlackBoardMessage) it.next(); print.println(bbm.encode()); --- 594,598 ---- out = new FileOutputStream("./campaign/blackboard.dat"); print = new PrintStream(out); ! for (Iterator it = blackBoard.allMessages().iterator(); it.hasNext();) { BlackBoardMessage bbm = (BlackBoardMessage) it.next(); print.println(bbm.encode()); *************** *** 1731,1735 **** // BlackBoard ! for (Iterator it = blackBoard.iterator(); it.hasNext();) { BlackBoardMessage bbm = (BlackBoardMessage) it.next(); if (bbm.decreaseTick()) --- 1699,1703 ---- // BlackBoard ! for (Iterator it = blackBoard.allMessages().iterator(); it.hasNext();) { BlackBoardMessage bbm = (BlackBoardMessage) it.next(); if (bbm.decreaseTick()) *************** *** 1747,1752 **** // serverDescriptions.save(getConfig("ServerDescription")); - saveData(); - System.gc(); } --- 1715,1718 ---- |