00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef typenH
00022 #define typenH
00023
00024 #include <time.h>
00025 #include <list>
00026 #include <bitset>
00027 #include <map>
00028 #include <SDL_types.h>
00029
00030 #include "global.h"
00031
00032
00033 #ifdef HAVE_LIMITS
00034 #include <limits>
00035 #else
00036 #include <limits.h>
00037 #endif
00038
00039 #include "basictypes.h"
00040
00041 #include "basestrm.h"
00042 #include "messaginghub.h"
00043
00044
00046 const int gamemapPixelSize = 4;
00047
00049 const int playerNum = 9;
00050
00051
00053 const int waffenanzahl = 8;
00054
00056 const int cwettertypennum = 6;
00057
00059 const int cmovemalitypenum = 18;
00060
00062 const int cmm_building = 11;
00063 const int cmm_trooper = 7;
00064
00066 const int choehenstufennum = 8;
00067
00069 const int maxbuildingpicnum = 8;
00070
00072 const int maxunitexperience = 23;
00073
00074
00076 const int resourceTypeNum = 3;
00078 const int resourceNum = resourceTypeNum;
00079
00080 class PropertyContainer;
00081
00083 class Resources {
00084 public:
00085 int energy;
00086 int material;
00087 int fuel;
00088
00089 int& resource ( int type ) {
00090 switch ( type ) {
00091 case 0: return energy;
00092 case 1: return material;
00093 case 2: return fuel;
00094 default: throw OutOfRange();
00095 }
00096 };
00097
00098 const int& resource ( int type ) const {
00099 switch ( type ) {
00100 case 0: return energy;
00101 case 1: return material;
00102 case 2: return fuel;
00103 default: throw OutOfRange();
00104 }
00105 };
00106
00107 Resources ( void ) : energy ( 0 ), material ( 0 ), fuel ( 0 ) {};
00108 Resources ( int e, int m, int f ) : energy ( e ), material ( m ), fuel ( f ) {};
00109 Resources& operator-= ( const Resources& res ) { energy-=res.energy; material-=res.material; fuel-=res.fuel; return *this;};
00110 bool operator>= ( const Resources& res ) { return energy >= res.energy && material>=res.material && fuel>=res.fuel; };
00111 bool operator< ( const Resources& res ) { return !(*this >= res); };
00112
00113 bool operator== ( const Resources& res ) { return energy==res.energy && material==res.material && fuel==res.fuel; };
00114 bool operator!= ( const Resources& res ) { return energy!=res.energy || material!=res.material || fuel!=res.fuel; };
00115 Resources& operator+= ( const Resources& res ) { energy+=res.energy; material+=res.material; fuel+=res.fuel; return *this;};
00116 enum { Energy, Material, Fuel };
00117 void read ( tnstream& stream );
00118 void write ( tnstream& stream ) const;
00119 void runTextIO ( PropertyContainer& pc );
00120 void runTextIO ( PropertyContainer& pc, const Resources& defaultValue );
00121 static const char* name( int r );
00122 ASCString toString();
00123
00124 static const int materialColor = 0xff0000;
00125 static const int fuelColor = 0x00ff00;
00126 static const int energyColor = 0x3b2dd7;
00127 };
00128
00129 extern Resources operator- ( const Resources& res1, const Resources& res2 );
00130 extern Resources operator+ ( const Resources& res1, const Resources& res2 );
00131 extern Resources operator* ( const Resources& res1, float a );
00132 extern Resources operator/ ( const Resources& res1, float a );
00133
00134
00137 class ResourceMatrix {
00138 float e[resourceTypeNum][resourceTypeNum];
00139 public:
00140 ResourceMatrix ( );
00141 ResourceMatrix ( const float* f );
00142 Resources operator* ( const Resources& r ) const;
00143
00144 void read ( tnstream& stream );
00145 void write ( tnstream& stream ) const;
00146 void runTextIO ( const ASCString& name, PropertyContainer& pc );
00147 void runTextIO ( const ASCString& name, PropertyContainer& pc, const ResourceMatrix& defaultValue );
00148
00149 };
00150
00151
00152
00153
00154
00155
00157 struct GameTime {
00158 GameTime() { abstime = 0; };
00159 int move() const { return abstime % 0x10000; };
00160 int turn() const { return abstime / 0x10000; };
00161 static bool comp ( const GameTime& a, const GameTime& b ) { return a.abstime > b.abstime; };
00162 void set ( int turn, int move ) { abstime = (turn * 0x10000) + move ; };
00163 int abstime;
00164 };
00165
00166
00168 class MapCoordinate {
00169 public:
00170 int x;
00171 int y;
00172 MapCoordinate ( ) : x(-1), y(-1 ) {};
00173 MapCoordinate ( int _x, int _y) : x(_x), y(_y) {};
00174 bool operator< ( const MapCoordinate& mc ) const { return y < mc.y || ( y == mc.y && x < mc.x );};
00175 bool operator== ( const MapCoordinate& mc ) const { return y == mc.y && x == mc.x;};
00176 bool operator!= ( const MapCoordinate& mc ) const { return y != mc.y || x != mc.x;};
00177 void write( tnstream& stream ) const { stream.writeInt ( 3000 ); stream.writeInt ( x ); stream.writeInt ( y); };
00178 void read( tnstream& stream ) {
00179 int vers = stream.readInt ( );
00180 if ( vers == 3500 )
00181 fatalError ( " MapCoordinate::read - data was written by MapCoordinate3D ");
00182
00183 x = stream.readInt ( );
00184 y = stream.readInt ( );
00185 };
00186 bool valid() const { return x >= 0 && y >= 0 ; } ;
00187 void move(int width, int height);
00188 ASCString toString() const;
00189 };
00190
00191 inline MapCoordinate operator-( const MapCoordinate& a, const MapCoordinate& b )
00192 {
00193 return MapCoordinate(a.x - b.x, a.y - b.y );
00194 }
00195
00196 inline MapCoordinate operator+( const MapCoordinate& a, const MapCoordinate& b )
00197 {
00198 return MapCoordinate(a.x + b.x, a.y + b.y );
00199 }
00200
00201
00203 class MapCoordinate3D : public MapCoordinate {
00204 int z;
00205 public:
00206 int getBitmappedHeight ( ) const { if ( z >= 0 ) return 1<<z; else return 0;};
00207 int getNumericalHeight ( ) const { return z; };
00208 void setNumericalHeight ( int nh ) { z = nh; };
00209
00210 MapCoordinate3D ( ) : MapCoordinate(), z(-1) {};
00211 MapCoordinate3D ( int _x, int _y, int bitmappedz) : MapCoordinate ( _x, _y ), z ( log2(bitmappedz) ) {};
00212
00213 MapCoordinate3D ( const MapCoordinate& mc, int bitmappedHeight ) : MapCoordinate ( mc ), z ( log2(bitmappedHeight) ) {};
00214 void setnum ( int _x, int _y, int numericalz ) { x = _x; y = _y; z = numericalz; };
00215 bool operator== ( const MapCoordinate3D& mc ) const { return y == mc.y && x == mc.x && (z == mc.z || z == -2 || mc.z == -2);};
00216 bool operator!= ( const MapCoordinate3D& mc ) const { return (mc.x != x) || (mc.y != y) || (mc.z != z); };
00217 void write( tnstream& stream ) const { stream.writeInt ( 3500 ); stream.writeInt ( z ); MapCoordinate::write( stream ); };
00218 void read( tnstream& stream ) {
00219 stream.readInt ( );
00220 z = stream.readInt ( );
00221 MapCoordinate::read ( stream );
00222 };
00223 };
00224
00225
00226
00228 class LoadableItemType {
00229 public:
00231 ASCString filename;
00232
00234 ASCString location;
00235
00236 virtual void read ( tnstream& stream ) = 0;
00237 virtual void write ( tnstream& stream ) const = 0;
00238 virtual void runTextIO ( PropertyContainer& pc ) = 0;
00239 virtual ~LoadableItemType() {};
00240 };
00241
00242
00243 template< typename T>
00244 class deallocating_vector : public vector<T> {
00245 public:
00246 ~deallocating_vector() {
00247 for ( typename vector<T>::iterator i = vector<T>::begin(); i != vector<T>::end(); ++i )
00248 delete *i;
00249 };
00250 };
00251
00252 template< typename T, typename U>
00253 class deallocating_map : public std::map<T,U> {
00254 public:
00255 ~deallocating_map() {
00256 for ( typename std::map<T,U>::iterator i = std::map<T,U>::begin(); i != std::map<T,U>::end(); ++i )
00257 delete i->second;
00258 };
00259 };
00260
00261
00262 class IntRange {
00263 public:
00264 int from;
00265 int to;
00266 IntRange(): from(-1), to(-1) {};
00267 IntRange( int oneValue ): from(oneValue), to(oneValue) {};
00268 IntRange( int from_, int to_ ): from(from_), to(to_) {};
00269 void read ( tnstream& stream );
00270 void write ( tnstream& stream ) const;
00271 };
00272
00273 extern vector<IntRange> String2IntRangeVector( const ASCString& t );
00274
00275
00276
00277
00278 class MoveMalusType {
00279 public:
00280 enum { deflt,
00281 light_tracked_vehicle,
00282 medium_tracked_vehicle,
00283 heavy_tracked_vehicle,
00284 light_wheeled_vehicle,
00285 medium_wheeled_vehicle,
00286 heavy_wheeled_vehicle,
00287 trooper,
00288 rail_vehicle,
00289 medium_aircraft,
00290 medium_ship,
00291 structure,
00292 light_aircraft,
00293 heavy_aircraft,
00294 light_ship,
00295 heavy_ship,
00296 helicopter,
00297 hoovercraft };
00298 };
00299
00300
00301
00302
00308
00309
00310
00311 enum { capeace, cawar, cawarannounce, capeaceproposal, canewsetwar1, canewsetwar2, canewpeaceproposal, capeace_with_shareview };
00312 enum VisibilityStates { visible_not, visible_ago, visible_now, visible_all };
00313
00314
00315 extern const char* cwettertypen[];
00316
00317
00318
00319
00320 extern const char* choehenstufen[8] ;
00321 #define chtiefgetaucht 1
00322 #define chgetaucht 2
00323 #define chschwimmend 4
00324 #define chfahrend 8
00325 #define chtieffliegend 16
00326 #define chfliegend 32
00327 #define chhochfliegend 64
00328 #define chsatellit 128
00329
00330
00331
00332
00333
00334
00335
00336
00337 extern const char* resourceNames[3];
00338
00339
00340 extern const char* cmovemalitypes[cmovemalitypenum];
00341 extern const char* moveMaliTypeIcons[cmovemalitypenum];
00342
00343 const int experienceDecreaseDamageBoundaryNum = 4;
00344 extern const int experienceDecreaseDamageBoundaries[experienceDecreaseDamageBoundaryNum];
00345
00346
00352
00353
00354 #define maxmalq 10
00355 #define minmalq 10
00356 #define fieldxsize 48
00357 #define fieldysize 48
00358 #define fielddistx 64
00359 #define fielddisty 24
00360 #define fielddisthalfx 32
00361
00363 const int sidenum = 6;
00364
00365 #define fieldsizex fieldxsize
00366 #define fieldsizey fieldysize
00367
00368 extern const int directionangle [ sidenum ];
00369
00370
00371 #define fieldsize (fieldxsize * fieldysize + 4 )
00372 #define unitsizex 30
00373 #define unitsizey 30
00374 #define tanksize (( unitsizex+1 ) * ( unitsizey+1 ) + 4 )
00375 #define unitsize tanksize
00376
00377
00378 #ifdef HAVE_LIMITS
00379
00380 #ifdef max
00381 #undef max
00382 #endif
00383 #ifdef min
00384 #undef min
00385 #endif
00386
00387 #define maxint numeric_limits<int>::max()
00388 #define minint numeric_limits<int>::min()
00389
00390 #define maxfloat numeric_limits<float>::max()
00391 #define minfloat numeric_limits<float>::min()
00392 #else
00393
00394 #define maxint INT_MAX
00395 #define minint INT_MIN
00396
00397 #define maxfloat FLT_MAX
00398 #define minfloat FLT_MIN
00399 #endif
00400
00401
00402
00403
00409
00411 const int attackmovecost = 0;
00412
00414 const int submarineMovement = 11;
00415
00416 #define movement_cost_for_repaired_unit 24
00417 #define movement_cost_for_repairing_unit 12
00418 #define attack_after_repair 1 // Can the unit that is beeing repaired attack afterwards?
00419
00420 #define mineputmovedecrease 10
00421 #define mineremovemovedecrease 10
00422
00423 #define fusstruppenplattfahrgewichtsfaktor 2
00424 #define mingebaeudeeroberungsbeschaedigung 80
00425
00426 #define lookintoenemytransports false
00427 #define lookintoenemybuildings false
00428
00429 #define recyclingoutput 2
00430 #define destructoutput 5
00431 #define nowindplanefuelusage 1 // herrscht kein Wind, braucht ein Flugzeug pro Runde soviel Sprit wie das fliegend dieser Anzahl fielder
00432
00433 const int maxwindspeed = 60;
00434
00435
00436 #define generatortruckefficiency 2 // fuer jede vehicle Power wird soviel Sprit gebraucht !
00437
00438 #define mine_movemalus_increase 50 // percent
00439
00440 #define cnet_storeenergy 0x001 // es wird garantiert, dass material immer das 2 und fuel das 4 fache von energy ist
00441 #define cnet_storematerial 0x002
00442 #define cnet_storefuel 0x004
00443
00444 #define cnet_moveenergyout 0x008
00445 #define cnet_movematerialout 0x010
00446 #define cnet_movefuelout 0x020
00447
00448 #define cnet_stopenergyinput 0x040
00449 #define cnet_stopmaterialinput 0x080
00450 #define cnet_stopfuelinput 0x100
00451
00452 #define cnet_stopenergyoutput 0x200
00453 #define cnet_stopmaterialoutput 0x400
00454 #define cnet_stopfueloutput 0x800
00455
00456
00457 #define resource_fuel_factor 80 // die im boden liegenden Bodenschtzen ergeben effektiv soviel mal mehr ( bei Bergwerkseffizienz 1024 )
00458 #define resource_material_factor 80 // "
00459
00460 #define destruct_building_material_get 2 // beim Abreissen erhlt man 1/2 des eingesetzten Materials zur?ck
00461 #define destruct_building_fuel_usage 10 // beim Abreissen wird 10 * fuelconsumption Fuel fuelconsumptiont
00462
00463
00464 #define dissectunitresearchpointsplus 2 // Beim dissectn einer vehicle wird der sovielte Teil der Researchpoints jeder unbekannten Technologie gutgeschrieben
00465
00466 #define dissectunitresearchpointsplus2 3 // Beim dissectn einer vehicle wird der sovielte Teil der Researchpoints jeder unbekannten Technologie gutgeschrieben.
00467
00468
00470 const int maxminingrange = 10;
00471
00472 const double productionLineConstructionCostFactor = 0.5;
00473 const double productionLineRemovalCostFactor = 0.2;
00474
00475
00476
00477 extern const int csolarkraftwerkleistung[];
00478
00480 const int cnetcontrolnum = 12;
00481
00483 extern const char* cnetcontrol[cnetcontrolnum];
00484
00485 extern const char* cgeneralnetcontrol[];
00486
00487 const int maxViewRange = 255;
00488
00489 #endif