Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

legacynetworkloaders.cpp

Go to the documentation of this file.
00001 /*
00002     This file is part of Advanced Strategic Command; http://www.asc-hq.de
00003     Copyright (C) 1994-2005  Martin Bickel  and  Marc Schellenberger
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program; see the file COPYING. If not, write to the 
00017     Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
00018     Boston, MA  02111-1307  USA
00019 */
00020 
00021 #include "messaginghub.h"
00022 
00023 #pragma pack(1)
00024 enum tnetworkchannel { TN_RECEIVE, TN_SEND };
00025 
00026  typedef class tbasenetworkconnection* pbasenetworkconnection;
00027  typedef class tnetwork* pnetwork;
00028 
00029 #define tnetworkdatasize 100
00030 typedef char tnetworkconnectionparameters[ tnetworkdatasize ];
00031 typedef tnetworkconnectionparameters* pnetworkconnectionparameters;
00032 
00033 class tnetworkcomputer {
00034   public:
00035      int        name; // was: char*
00036     struct {
00037       int          transfermethodid;
00038       int transfermethod;  // was: pbasenetworkconnection
00039       tnetworkconnectionparameters         data;
00040     } send, receive;
00041     int          existent;
00042 };
00043 
00044 class  tnetwork {
00045   public:
00046     struct {
00047       char         compposition;   // Nr. des Computers, an dem der SPieler spielt    => network.computernames
00048       int          codewordcrc;
00049     } player[8];
00050 
00051     tnetworkcomputer computer[8];
00052 
00053     int computernum;
00054     int turn;
00055     struct tglobalparams {
00056       int enablesaveloadofgames;
00057       int reaskpasswords;
00058       int dummy[48];
00059     } globalparams;
00060 };
00061 
00062 #pragma pack()
00063 
00064 #include "basestrm.h"
00065 
00066 void        readLegacyNetworkData ( tnstream& stream )
00067 {
00068    tnetwork network;
00069 
00070 // #if SDL_BYTEORDER == SDL_LIL_ENDIAN
00071 
00072       // don't change anything for Big-Endian adaption,
00073       // this part is really ugly and is rewrite for ASC2
00074 
00075          for ( int i = 0; i < 8; ++i ) {
00076             network.player[i].compposition = stream.readChar();
00077             network.player[i].codewordcrc = stream.readInt();
00078          }
00079 
00080          for ( int i = 0; i< 8; ++i ) {
00081             network.computer[i].name = stream.readInt();
00082             network.computer[i].send.transfermethodid = stream.readInt();
00083             stream.readInt(); // network.computer[i].send.transfermethod = (pbasenetworkconnection) 
00084             stream.readdata2( network.computer[i].send.data );
00085             network.computer[i].receive.transfermethodid = stream.readInt();
00086             stream.readInt(); // network.computer[i].receive.transfermethod = (pbasenetworkconnection) 
00087             stream.readdata2( network.computer[i].receive.data );
00088             network.computer[i].existent = stream.readInt();
00089          }
00090          network.computernum = stream.readInt();
00091          network.turn = stream.readInt();
00092          network.globalparams.enablesaveloadofgames = stream.readInt();
00093          network.globalparams.reaskpasswords = stream.readInt();
00094          for ( int i = 0; i< 48; ++i )
00095             network.globalparams.dummy[i] = stream.readInt();
00096          
00097          for ( int i=0; i<8 ; i++ )
00098             if (network.computer[i].name  )
00099                stream.readString();
00100 // #else
00101 //         errorMessage("Unable to load map in old file format on this computer architecture\nPlease convert this file to the new file format on a 32 Bit little endian machine and try again");
00102 //         throw tfileerror();
00103 // #endif
00104 }
00105 
00106 

Generated on Tue Jun 24 01:27:44 2008 for Advanced Strategic Command by  doxygen 1.4.2