[Megameknet-cvs] MegaMekNET/src/client MMClient.java,1.47,1.48
Status: Inactive
Brought to you by:
mcwizard
From: Immanuel S. <im...@us...> - 2005-02-22 22:39:25
|
Update of /cvsroot/megameknet/MegaMekNET/src/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11231/src/client Modified Files: MMClient.java Log Message: reordered data init to fix the problem of "could not load serverconfig" if only the lastTimestamp is missing. Index: MMClient.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/client/MMClient.java,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** MMClient.java 20 Feb 2005 18:59:05 -0000 1.47 --- MMClient.java 22 Feb 2005 22:39:15 -0000 1.48 *************** *** 316,323 **** private void initData() { MMNetXStream xml = new MMNetXStream(); ! // initialize last timestamp and serverconfig try { - Date lastTS = (Date)xml.fromFile(getServerCacheDir()+"dataLastUpdated.xml"); - dataFetcher.setLastTimestamp(lastTS); serverConfigs = dataFetcher.getServerConfigData(); System.out.println("serverConfig fetched from server."); --- 316,321 ---- private void initData() { MMNetXStream xml = new MMNetXStream(); ! // initialize serverconfig try { serverConfigs = dataFetcher.getServerConfigData(); System.out.println("serverConfig fetched from server."); *************** *** 337,340 **** --- 335,344 ---- JWindow splash = GraphicGimmicks.pleaseWaitSplash(); try { + // if lastTimestamp can not be read, the cache is worthless, since + // we don't know how up-to-date it is. So handle this in the same + // try block as data loading. + Date lastTS = (Date)xml.fromFile(getServerCacheDir()+"dataLastUpdated.xml"); + dataFetcher.setLastTimestamp(lastTS); + // try to load the data cache. data = (CampaignData)xml.fromFile(getServerCacheDir()+"data.xml"); System.out.println("successfull loaded cached data: " *************** *** 342,346 **** +data.getAllHouses().size()+" houses, " +data.getAllTerrains().size()+" planet environments."); - refreshData(false); } catch (Exception t) { t.printStackTrace(); --- 346,349 ---- *************** *** 348,351 **** --- 351,355 ---- Date now = new Date(); try { + // this will also set the lastTimestamp of datafetcher. data = dataFetcher.getAllData(); } catch (CommunicationException e) { *************** *** 358,361 **** --- 362,375 ---- storeData(now); } + try { + refreshData(false); + } catch (Exception e) { + e.printStackTrace(); + // no problem, except that the client has outdated information. + // refresh, however, will be called shortly again (from the + // background thread) and this will report any error, so do nothing + // here (to not terrify the user with too many error messages in + // case of server problems ;). + } splash.dispose(); } |