Advanced Strategic Command
legacynetworkloaders.cpp
Go to the documentation of this file.
1 /*
2  This file is part of Advanced Strategic Command; http://www.asc-hq.de
3  Copyright (C) 1994-2010 Martin Bickel and Marc Schellenberger
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; see the file COPYING. If not, write to the
17  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18  Boston, MA 02111-1307 USA
19 */
20 
21 #include <SDL_stdinc.h>
22 #include "util/messaginghub.h"
23 
24 #pragma pack(1)
26 
27  typedef class tbasenetworkconnection* pbasenetworkconnection;
28  typedef class tnetwork* pnetwork;
29 
30 #define tnetworkdatasize 100
33 
35  public:
36  int name; // was: char*
37  struct {
39  int transfermethod; // was: pbasenetworkconnection
41  } send, receive;
42  int existent;
43 };
44 
45 class tnetwork {
46  public:
47  struct {
48  Uint8 compposition; // Nr. des Computers, an dem der SPieler spielt => network.computernames
50  } player[8];
51 
53 
55  int turn;
56  struct tglobalparams {
59  int dummy[48];
60  } globalparams;
61 };
62 
63 #pragma pack()
64 
65 #include "basestrm.h"
66 
68 {
69  tnetwork network;
70 
71 // #if SDL_BYTEORDER == SDL_LIL_ENDIAN
72 
73  // don't change anything for Big-Endian adaption,
74  // this part is really ugly and is rewrite for ASC2
75 
76  for ( int i = 0; i < 8; ++i ) {
77  network.player[i].compposition = stream.readUint8();
78  network.player[i].codewordcrc = stream.readInt();
79  }
80 
81  for ( int i = 0; i< 8; ++i ) {
82  network.computer[i].name = stream.readInt();
83  network.computer[i].send.transfermethodid = stream.readInt();
84  stream.readInt(); // network.computer[i].send.transfermethod = (pbasenetworkconnection)
85  stream.readdata2( network.computer[i].send.data );
86  network.computer[i].receive.transfermethodid = stream.readInt();
87  stream.readInt(); // network.computer[i].receive.transfermethod = (pbasenetworkconnection)
88  stream.readdata2( network.computer[i].receive.data );
89  network.computer[i].existent = stream.readInt();
90  }
91  network.computernum = stream.readInt();
92  network.turn = stream.readInt();
93  network.globalparams.enablesaveloadofgames = stream.readInt();
94  network.globalparams.reaskpasswords = stream.readInt();
95  for ( int i = 0; i< 48; ++i )
96  network.globalparams.dummy[i] = stream.readInt();
97 
98  for ( int i=0; i<8 ; i++ )
99  if (network.computer[i].name )
100  stream.readString();
101 // #else
102 // 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");
103 // throw tfileerror();
104 // #endif
105 }
106 
107 
Uint8 tnetworkconnectionparameters[tnetworkdatasize]
virtual int readInt(void)
Reads a 32 bit signed Integer. In the stream little-endian byte order is used and a translation is pe...
Definition: basestrm.cpp:284
#define tnetworkdatasize
struct tnetwork::tglobalparams globalparams
tnetworkconnectionparameters data
struct tnetworkcomputer::@12 receive
struct tnetwork::@13 player[8]
The interface for all kinds of IO stream.
virtual Uint8 readUint8(void)
Reads a 8 bit unsigned Integer.
Definition: basestrm.cpp:305
struct tnetworkcomputer::@12 send
tnetworkcomputer computer[8]
class tbasenetworkconnection * pbasenetworkconnection
The interface for the various streams that ASC offers, like file and memory streams.
virtual ASCString readString(bool includeCR=false)
Reads and returns a string.
Definition: basestrm.cpp:535
class tnetwork * pnetwork
void readLegacyNetworkData(tnstream &stream)
tnetworkconnectionparameters * pnetworkconnectionparameters