Advanced Strategic Command
mappolygons.cpp
Go to the documentation of this file.
1 
5 /*
6  This file is part of Advanced Strategic Command; http://www.asc-hq.de
7  Copyright (C) 1994-2010 Martin Bickel and Marc Schellenberger
8 
9  This program is free software; you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation; either version 2 of the License, or
12  (at your option) any later version.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; see the file COPYING. If not, write to the
21  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
22  Boston, MA 02111-1307 USA
23 */
24 
25 #include <stdio.h>
26 #include "typen.h"
27 #include "misc.h"
28 #include "loaders.h"
29 #include "spfst.h"
30 #include "mappolygons.h"
31 #include "dlg_box.h"
32 #include "itemrepository.h"
33 
34 
35 
37 {
38  if ( (x & 1) == (y & 1) )
39  setpointabs ( x / 2, y);
40 }
41 
43 {
44  Poly_gon poly1;
45  for ( int i=0; i< poly.vertex.size() ; i++ )
46  poly1.vertex.push_back ( MapCoordinate( poly.vertex[i].x * 2 + (poly.vertex[i].y & 1), poly.vertex[i].y ));
47 
49 }
50 
51 
52 
53 void Poly_gon::read ( tnstream& stream )
54 {
55  int version = stream.readInt();
56  if ( version != 100 )
57  throw tinvalidversion( stream.getLocation(), 100, version );
58  readClassContainer ( vertex, stream );
59 }
60 
61 
62 void Poly_gon::write ( tnstream& stream ) const
63 {
64  stream.writeInt( 100 );
65  writeClassContainer ( vertex, stream );
66 }
67 
68 
69 
70 
vector< Point > vertex
Definition: mappolygons.h:39
virtual void writeInt(int i)
Writes a 32 bit signed Integer. In the stream little-endian byte order is used and a translation is p...
Definition: basestrm.cpp:363
map accessing and usage routines used by ASC and the mapeditor
miscellaneous functions which are used by ASC and all its tools
virtual ASCString getLocation()
returns the location of the stream.
Definition: basestrm.cpp:274
void write(tnstream &stream) const
Definition: mappolygons.cpp:62
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
virtual void setpoint(int x, int y)
Definition: mappolygons.cpp:36
operating with polygons on tje map
Interface for some basic classes from which all of ASC's dialogs are derived.
The interface for all kinds of IO stream.
Coordinate on the twodimensional map.
Definition: typen.h:202
bool paintPolygon(const Poly_gon &poly)
Definition: mappolygons.cpp:42
void readClassContainer(C &c, tnstream &stream)
Definition: basestrm.h:752
virtual void setpointabs(int x, int y)=0
procedure for loading and writing savegames, maps etc.
bool paintPolygon(const Poly &poly)
void read(tnstream &stream)
Definition: mappolygons.cpp:53
void writeClassContainer(const C &c, tnstream &stream)
Definition: basestrm.h:742