Advanced Strategic Command
buildingtype.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  buildingtype.cpp - description
3  -------------------
4  begin : Fri Sep 29 2000
5  copyright : (C) 1994-2010 by Martin Bickel
6  email : bickel@asc-hq.org
7  ***************************************************************************/
8 
13 /***************************************************************************
14  * *
15  * This program is free software; you can redistribute it and/or modify *
16  * it under the terms of the GNU General Public License as published by *
17  * the Free Software Foundation; either version 2 of the License, or *
18  * (at your option) any later version. *
19  * *
20  ***************************************************************************/
21 
22 #include <algorithm>
23 
24 #include "vehicletype.h"
25 #include "buildingtype.h"
26 #include "graphicset.h"
27 #include "gameoptions.h"
28 #include "textfiletags.h"
29 #include "stringtokenizer.h"
30 #include "textfile_evaluation.h"
31 #include "graphics/surface.h"
32 
33 #include "errors.h"
34 #include "sgstream.h"
35 #include "graphics/blitter.h"
37 
38 
39 /*
40 const char* cbuildingfunctions[cbuildingfunctionnum+1] =
41  { "HQ",
42  "training",
43  "unused (was: refinery)",
44  "vehicle production",
45  "ammunition production",
46  "unused (was: energy prod)",
47  "unused (was: material prod)",
48  "unused (was: fuel prod)",
49  "repair facility",
50  "recycling",
51  "research",
52  "sonar",
53  "wind power plant",
54  "solar power plant",
55  "matter converter (was: power plant)",
56  "mining station",
57  "external resource transfer",
58  "construct units that cannot move out",
59  "resource sink",
60  "external resource transfer",
61  "external ammo transfer",
62  "no object chaining",
63  "self destruct on conquer",
64  "view satellites",
65  NULL };
66 */
67 
69 {
70  for ( int x = 0; x < 4; x++ )
71  for ( int y = 0; y < 6; y++ ) {
72  field_Exists[x][y] = false;
73  for ( int w = 0; w < cwettertypennum; ++w )
74  for ( int c = 0; c < maxbuildingpicnum; ++c )
75  bi_picture[w][c][x][y] = -1;
76  }
77 
78  buildingNotRemovable = false;
79 
80  static const float matrix[] = { 1, 0, 0,
81  0, 1, 0,
82  0, 0, 1 };
83 
85 
86 }
87 
88 
90 {
91  int size = sizeof(*this);
92 
93  for ( int i = 0; i < cwettertypennum; ++i )
94  for ( int j = 0; j < maxbuildingpicnum; ++j )
95  for ( int k = 0; k < 4; ++k )
96  for ( int l = 0; l < 6; ++l )
97  size += w_picture[i][j][k][l].getMemoryFootprint() - sizeof( Surface );
98  return size;
99 }
100 
101 
102 int BuildingType :: getBIPicture( const LocalCoordinate& localCoordinate, int weather , int constructionStep ) const
103 {
104  return bi_picture [weather][constructionStep][localCoordinate.x][localCoordinate.y];
105 }
106 
107 
108 const Surface& BuildingType :: getPicture ( const LocalCoordinate& localCoordinate, int weather, int constructionStep ) const
109 {
110  if( constructionStep >= construction_steps )
111  constructionStep = construction_steps-1;
112 
113  if ( !weatherBits.test(weather))
114  weather = 0;
115 
116  if ( bi_picture [weather][constructionStep][localCoordinate.x][localCoordinate.y] <= 0 )
117  return w_picture[weather][constructionStep][localCoordinate.x][localCoordinate.y];
118  else
119  return GraphicSetManager::Instance().getPic(bi_picture [weather][constructionStep][localCoordinate.x][localCoordinate.y]);
120 
121 }
122 
123 void BuildingType::paint ( Surface& s, SPoint pos, const PlayerColor& player, int weather, int constructionStep ) const
124 {
125  for ( int x = 0; x < 4; x++ )
126  for ( int y = 0; y < 6; y++ )
127  if ( fieldExists(LocalCoordinate(x,y) ))
128  paintSingleField(s,pos,LocalCoordinate(x,y),player,weather,constructionStep);
129 
130 }
131 
132 void BuildingType::paint ( Surface& s, SPoint pos ) const
133 {
134  for ( int x = 0; x < 4; x++ )
135  for ( int y = 0; y < 6; y++ )
136  if ( fieldExists(LocalCoordinate(x,y) ))
137  paintSingleField(s,pos,LocalCoordinate(x,y));
138 
139 }
140 
141 
142 void BuildingType:: paintSingleField ( Surface& s, SPoint pos, const LocalCoordinate& localCoordinate, const PlayerColor& player, int weather, int constructionStep ) const
143 {
148  ( getPicture(localCoordinate,weather,constructionStep),
149  s,
150  SPoint( pos.x + localCoordinate.x * fielddistx + ( localCoordinate.y & 1 ) * fielddisthalfx, pos.y + localCoordinate.y * fielddisty),
151  player,
153 
154  // s.Blit( getPicture(localCoordinate,weather,constructionStep),SPoint( pos.x + localCoordinate.x * fielddistx + ( localCoordinate.y & 1 ) * fielddisthalfx, pos.y + localCoordinate.y * fielddisty));
155 }
156 
157 void BuildingType:: paintSingleField ( Surface& s, SPoint pos, const LocalCoordinate& localCoordinate, int weather, int constructionStep ) const
158 {
163  ( getPicture(localCoordinate,weather,constructionStep),
164  s,
165  SPoint( pos.x + localCoordinate.x * fielddistx + ( localCoordinate.y & 1 ) * fielddisthalfx, pos.y + localCoordinate.y * fielddisty),
167 
168  // s.Blit( getPicture(localCoordinate,weather,constructionStep),SPoint( pos.x + localCoordinate.x * fielddistx + ( localCoordinate.y & 1 ) * fielddisthalfx, pos.y + localCoordinate.y * fielddisty));
169 }
170 
171 
172 
173 MapCoordinate BuildingType :: getFieldCoordinate ( const MapCoordinate& entryOnMap, const LocalCoordinate& localCoordinates ) const
174 {
175  int orgx = entryOnMap.x - entry.x - (entry.y & ~entryOnMap.y & 1 );
176  int orgy = entryOnMap.y - entry.y;
177 
178  int dx = orgy & 1;
179 
180  int yy = orgy + localCoordinates.y;
181  int xx = orgx + localCoordinates.x + (dx & ~yy);
182  MapCoordinate mc ( xx, yy );
183  return mc;
184 }
185 
187 {
188  int homex = entryOnMap.x - entry.x;
189  int homey = entryOnMap.y - entry.y;
190 
191  if ( (entry.y & 1) && !(entryOnMap.y & 1))
192  homex -= 1;
193 
194 
195  int ly = field.y - homey;
196  int lx = field.x - homex;
197  if ( (ly & 1) && (homey & 1 ))
198  lx -= 1;
199 
200  if ( lx >= 0 && lx < 4 && ly >= 0 && ly < 6 && fieldExists(LocalCoordinate(lx,ly)))
201  return LocalCoordinate(lx,ly);
202  else
203  return LocalCoordinate();
204 }
205 
206 
207 
208 const int building_version = 15;
209 const int guardInt = 0xA5C0A5C0;
210 
212 {
213  int version = stream.readInt();
214  if ( version <= building_version && version >= 1) {
215 
216  bool picsAvail[ cwettertypennum ][ maxbuildingpicnum ][4][6];
217 
218  for ( int v = 0; v < cwettertypennum; v++ )
219  for ( int w = 0; w < maxbuildingpicnum; w++ )
220  for ( int x = 0; x < 4; x++ )
221  for ( int y = 0; y < 6 ; y++ ) {
222  picsAvail[v][w][x][y] = stream.readInt( );
223  if ( picsAvail[v][w][x][y] ) {
224  field_Exists[x][y] = true;
225  weatherBits.set(v);
226  }
227  }
228 
229 
230  for ( int v = 0; v < cwettertypennum; v++ )
231  for ( int w = 0; w < maxbuildingpicnum; w++ )
232  for ( int x = 0; x < 4; x++ )
233  for ( int y = 0; y < 6 ; y++ ) {
234  int i = stream.readInt( );
235  bi_picture[v][w][x][y] = i;
236  if ( i > 0 ) {
237  field_Exists[x][y] = true;
238  weatherBits.set(v);
239  }
240  }
241 
242 
243  entry.x = stream.readInt( );
244  entry.y = stream.readInt( );
245 
246  stream.readInt( ); // was: powerlineconnect.x
247  stream.readInt( ); // was: powerlineconnect.y
248  stream.readInt( ); // was: pipelineconnect.x
249  stream.readInt( ); // was: pipelineconnect.y
250 
251  id = stream.readInt( );
252  bool __loadName = stream.readInt( );
253  _armor = stream.readInt( );
254  jamming = stream.readInt( );
255  view = stream.readInt( );
256  stream.readInt( ); // was: loadcapacity
257  stream.readUint8( ); // was: loadcapability =
258  stream.readUint8( ); // was: unitheightreq =
259  productionCost.material = stream.readInt( );
260  productionCost.fuel = stream.readInt( );
261  if ( version <= 9 ) {
262  int special = stream.readInt( );
263  convertOldFunctions( special, stream.getLocation() );
264  }
265 
266  technologylevel = stream.readUint8( );
267  stream.readUint8( ); // was: researchid
268 
269  terrainaccess.read ( stream );
270 
271  construction_steps = stream.readInt( );
272  maxresearchpoints = stream.readInt( );
273  asc_mode_tank.energy = stream.readInt( );
274  asc_mode_tank.material = stream.readInt( );
275  asc_mode_tank.fuel = stream.readInt( );
276  maxplus.energy = stream.readInt( );
277  maxplus.material = stream.readInt( );
278  maxplus.fuel = stream.readInt( );
279  efficiencyfuel = stream.readInt( );
280  efficiencymaterial = stream.readInt( );
281  stream.readInt( ); // guibuildicon
282  stream.readInt( ); // terrain_access = (TerrainAccess*)
283 
284  bi_mode_tank.energy = stream.readInt( );
285  bi_mode_tank.material = stream.readInt( );
286  bi_mode_tank.fuel = stream.readInt( );
287 
288  if ( version >= 5 ) {
289  defaultProduction.energy = stream.readInt( );
290  defaultProduction.material = stream.readInt( );
291  defaultProduction.fuel = stream.readInt( );
292  }
293 
294 
295  height = 1 << getFirstBit ( stream.readInt() );
296  stream.readInt( ); // was: unitheight_forbidden =
297  externalloadheight = stream.readInt( );
298 
299  if ( version >= 15 )
300  if ( stream.readInt() != guardInt )
301  throw tinvalidversion ( stream.getLocation(), 1000, 0 );
302 
303  if ( version >= 3)
304  stream.readInt(); // was: vehicleCategoriesLoadable =
305 
306 
307  if ( version >= 2 ) {
308  if ( version <= 11 ) {
309  for ( int x = 0; x < 4; x++ )
310  for ( int y = 0; y < 6; y++ ) {
311  int id = stream.readInt();
312  if ( id > 0 )
313  destructionObjects.insert( make_pair(LocalCoordinate(x,y), id));
314  }
315  }
316  } else {
317  for ( int w = 0; w < 9; w++ )
318  stream.readInt( );
319  destructionObjects.clear();
320  }
321 
322  if ( __loadName )
323  name = stream.readString();
324 
325  for ( int k = 0; k < maxbuildingpicnum ; k++)
326  for ( int j = 0; j <= 5; j++)
327  for ( int i = 0; i <= 3; i++)
328  for ( int w = 0; w < cwettertypennum; w++ )
329  if ( picsAvail[w][k][i][j] )
330  if ( bi_picture[w][k][i][j] == -1 )
331  w_picture[w][k][i][j].read(stream );
332 
333  if ( version >= 15 )
334  if ( stream.readInt() != guardInt+1 )
335  throw tinvalidversion ( stream.getLocation(), 1001, 0 );
336 
337 
338  if ( version >= 4 )
339  ContainerBaseType::read ( stream );
340 
341  if ( version >= 6 )
342  nominalresearchpoints = stream.readInt();
343 
344  if ( version >= 15 )
345  if ( stream.readInt() != guardInt+2 )
346  throw tinvalidversion ( stream.getLocation(), 1002, 0 );
347 
348  if ( version >= 7 ) {
349  techDependency.read( stream );
351  }
352 
353  if ( version >= 8 )
354  infotext = stream.readString(true);
355 
356  if ( version >= 11 )
357  buildingNotRemovable = stream.readInt();
358 
359  if ( version >= 15 )
360  if ( stream.readInt() != guardInt+3 )
361  throw tinvalidversion ( stream.getLocation(), 1003, 0 );
362 
363  if ( version >= 12 ) {
364  int num = stream.readInt();
365  for ( int i = 0; i < num; ++i ) {
366  int x = stream.readInt();
367  int y = stream.readInt();
368  int id = stream.readInt();
369  destructionObjects.insert( make_pair( LocalCoordinate(x,y),id));
370  }
371  }
372 
373  if ( version >= 13 )
374  for ( int w = 0; w < cwettertypennum; ++w )
375  originalImageFilename[w] = stream.readString();
376 
377  if ( version >= 14 )
378  description = stream.readString();
379 
380  if ( version >= 15 )
381  if ( stream.readInt() != guardInt+4 )
382  throw tinvalidversion ( stream.getLocation(), 1004, 0 );
383 
384  } else
385  throw tinvalidversion ( stream.getLocation(), building_version, version );
386 }
387 
388 void BuildingType :: write ( tnstream& stream ) const
389 {
390  stream.writeInt ( building_version );
391 
392  for ( int v = 0; v < cwettertypennum; v++ )
393  for ( int w = 0; w < maxbuildingpicnum; w++ )
394  for ( int x = 0; x < 4; x++ )
395  for ( int y = 0; y < 6 ; y++ ) {
396  stream.writeInt ( w_picture[v][w][x][y].valid() );
397  }
398 
399  for ( int v = 0; v < cwettertypennum; v++ )
400  for ( int w = 0; w < maxbuildingpicnum; w++ )
401  for ( int x = 0; x < 4; x++ )
402  for ( int y = 0; y < 6 ; y++ )
403  stream.writeInt ( bi_picture[v][w][x][y] );
404 
405  /*
406  for ( int x = 0; x < 4; x++ )
407  for ( int y = 0; y < 6 ; y++ )
408  stream.writeInt( field_Exists[x][y] );
409  */
410 
411 
412  stream.writeInt ( entry.x );
413  stream.writeInt ( entry.y );
414  stream.writeInt ( -1 ); // was powerlineconnect.x
415  stream.writeInt ( -1 ); // was powerlineconnect.y
416  stream.writeInt ( -1 ); // was pipelineconnect.x
417  stream.writeInt ( -1 ); // was pipelineconnect.y
418 
419  stream.writeInt ( id );
420  stream.writeInt ( !name.empty() );
421  stream.writeInt ( _armor );
422  stream.writeInt ( jamming );
423  stream.writeInt ( view );
424  stream.writeInt ( 0 );
425  stream.writeUint8 ( 0);
426  stream.writeUint8 ( 0 );
427  stream.writeInt ( productionCost.material );
428  stream.writeInt ( productionCost.fuel );
429  stream.writeUint8 ( technologylevel );
430  stream.writeUint8 ( 0 );
431 
432  terrainaccess.write ( stream );
433 
434  stream.writeInt ( construction_steps );
435  stream.writeInt ( maxresearchpoints );
436  stream.writeInt ( asc_mode_tank.energy );
437  stream.writeInt ( asc_mode_tank.material );
438  stream.writeInt ( asc_mode_tank.fuel );
439 
440  stream.writeInt ( maxplus.energy );
441  stream.writeInt ( maxplus.material );
442  stream.writeInt ( maxplus.fuel );
443  stream.writeInt ( efficiencyfuel );
444  stream.writeInt ( efficiencymaterial );
445  stream.writeInt ( 1 ); // guibuildicon
446  stream.writeInt ( 1 );
447 
448  stream.writeInt ( bi_mode_tank.energy );
449  stream.writeInt ( bi_mode_tank.material );
450  stream.writeInt ( bi_mode_tank.fuel );
451 
452  stream.writeInt ( defaultProduction.energy );
454  stream.writeInt ( defaultProduction.fuel );
455 
456  stream.writeInt ( height );
457  stream.writeInt ( 0 );
458  stream.writeInt ( externalloadheight );
459 
460  stream.writeInt( guardInt );
461 
462  stream.writeInt ( 0 );
463 
464  if ( !name.empty() )
465  stream.writeString ( name );
466 
467  for (int k = 0; k < maxbuildingpicnum; k++)
468  for (int j = 0; j <= 5; j++)
469  for (int i = 0; i <= 3; i++)
470  for ( int w = 0; w < cwettertypennum; w++ )
471  if ( w_picture[w][k][i][j].valid() )
472  if ( bi_picture[w][k][i][j] == -1 )
473  w_picture[w][k][i][j].write(stream);
474 
475  stream.writeInt( guardInt +1 );
476  ContainerBaseType::write ( stream );
477 
479 
480  stream.writeInt( guardInt +2 );
481 
482  techDependency.write ( stream );
484 
485  stream.writeString ( infotext );
486  stream.writeInt( buildingNotRemovable );
487 
488  stream.writeInt( guardInt +3 );
489 
490  stream.writeInt( destructionObjects.size());
491  for ( DestructionObjects::const_iterator i = destructionObjects.begin(); i != destructionObjects.end(); ++i) {
492  stream.writeInt( i->first.x);
493  stream.writeInt( i->first.y);
494  stream.writeInt( i->second);
495  }
496 
497  for ( int w = 0; w < cwettertypennum; ++w )
498  stream.writeString( originalImageFilename[w] );
499 
500  stream.writeString( description );
501  stream.writeInt( guardInt +4 );
502 }
503 
504 
506 {
507  ASCString s;
508  s += 'A'+x;
509  s += '1'+y;
510  return s;
511 }
512 
513 class InvalidString : public ASCexception {};
514 
516 {
517  ASCString s2 = s;
518  s2.toUpper();
519  if ( s2.length() < 2 ) {
520  x = -1;
521  y = -1;
522  throw InvalidString();
523  } else {
524  x = s2[0] - 'A';
525  y = s2[1] - '1';
526  if ( x < 0 || x > 5 || y < 0 || y > 7 )
527  throw InvalidString();
528  }
529 }
530 
531 
533 {
534  try {
535 
536  pc.addBreakpoint();
537 
539 
540  pc.addInteger ( "ConstructionStages", construction_steps );
541 
542  for ( int i = 0; i < cwettertypennum; i++ )
543  for ( int x = 0; x < 4; x++ )
544  for ( int y = 0; y < 6; y++ )
545  if ( w_picture[i][0][x][y].valid() )
546  weatherBits.set(i);
547 
548  pc.addTagArray( "Weather", weatherBits, cwettertypennum, weatherTags );
549 
550 
551  ASCString fieldNames;
552  for ( int a = 0; a < 4; a++ )
553  for ( int b = 0; b < 6; b++ )
554  if ( w_picture[0][0][a][b].valid() || bi_picture[0][0][a][b] > 0 ) {
555  fieldNames += LocalCoordinate( a, b).toString();
556  fieldNames += " ";
557  }
558 
559  pc.addString( "Fields", fieldNames );
560 
561  typedef vector<LocalCoordinate> Fields;
562  Fields fields;
563  StringTokenizer st ( fieldNames );
564  ASCString t = st.getNextToken();
565  while ( !t.empty() ) {
566  LocalCoordinate lc ( t );
567  fields.push_back ( lc );
568  t = st.getNextToken();
569  field_Exists[lc.x][lc.y] = true;
570  }
571 
572 
573 
574 
575  bool bi3pics = false;
576 
577  for ( int i = 0; i < 4; i++ )
578  for ( int j = 0; j < 6; j++ )
579  if ( bi_picture[0][0][i][j] >= 0 )
580  bi3pics = true;
581 
582  pc.addBool ( "UseGFXpics", bi3pics );
583 
584  if ( bi3pics ) {
585  pc.openBracket ( "GFXpictures");
586  for ( int w = 0; w < cwettertypennum; w++ )
587  if ( weatherBits.test(w) ) {
588  pc.openBracket (weatherTags[w] );
589 
590  for ( int c = 0; c < construction_steps; c++ ) {
591  pc.openBracket ( ASCString("Stage")+strrr(c+1) );
592 
593  for ( Fields::iterator i = fields.begin(); i != fields.end(); i++ )
594  pc.addInteger ( i->toString(), bi_picture[w][c][i->x][i->y] );
595 
596 
597  pc.closeBracket();
598  }
599  pc.closeBracket();
600 
601  }
602  pc.closeBracket();
603  } else {
604  pc.openBracket ( "Pictures");
605  if ( !pc.isReading() ) {
606  for ( int w = 0; w < cwettertypennum; w++ )
607  if ( weatherBits.test(w) ) {
608  Surface s = Surface::createSurface( construction_steps*500, 250, 32, 0 );
609  for ( int c = 0; c < construction_steps; c++ )
610  for ( int x = 0; x < 4; x++ )
611  for ( int y = 0; y < 6; y++ )
612  if ( w_picture[w][c][x][y].valid() )
617  ( w_picture[w][c][x][y],
618  s,
619  SPoint( 500*c + x * fielddistx + (y&1)*fielddisthalfx, y * fielddisty),
622  pc.addImage ( weatherTags[w], s, file, false );
623  pc.addString( ASCString(weatherTags[w]) + "_OriginalImageFilename", originalImageFilename[w] );
624  }
625  } else {
626  for ( int w = 0; w < cwettertypennum; w++ )
627  if ( weatherBits.test(w) ) {
629  Surface s;
630  pc.addImage ( weatherTags[w], s, fileName, false );
631  originalImageFilename[w] = fileName;
632 
633 // if ( s.GetPixelFormat().BitsPerPixel() != 8 )
634  //fatalError("Building image " + filename + " does not have 8 Bit color depth!");
635 
636  int depth = s.GetPixelFormat().BitsPerPixel();
637  for ( int c = 0; c < construction_steps; c++ )
638  for ( Fields::iterator i = fields.begin(); i != fields.end(); i++ ) {
639  Surface& img = w_picture[w][c][i->x][i->y];
641  int xx = 500*c + i->x * fielddistx + (i->y&1)*fielddisthalfx;
642  int yy = i->y * fielddisty;
643  if ( depth == 8 ) {
644  img.Blit( s, SDLmm::SRect(SPoint(xx,yy),fieldsizex,fieldsizey), SPoint(0,0));
645  applyFieldMask(img);
646  } else {
648  blitter.setSrcRectangle( SDLmm::SRect(SPoint(xx,yy),fieldsizex,fieldsizey) );
649  blitter.blit( s, img, SPoint(0,0) );
650  applyFieldMask(img,0,0,false);
651  }
652  }
653 
654  }
655 
656  }
657  pc.closeBracket();
658  }
659 
660  bool rubble = destructionObjects.size() > 0;
661  pc.addBool ( "RubbleObjects", rubble );
662  if ( rubble ) {
663  if ( pc.isReading() )
664  destructionObjects.clear();
665 
666  pc.openBracket ( "Rubble");
667  for ( Fields::iterator i = fields.begin(); i != fields.end(); i++ ) {
668  vector<int> ids;
669  typedef DestructionObjects::const_iterator J;
670  pair<J,J> b = destructionObjects.equal_range(*i);
671  for ( J j = b.first; j != b.second; ++j)
672  ids.push_back(j->second);
673  pc.addIntegerArray ( i->toString(), ids );
674 
675  if ( pc.isReading() ) {
676  for ( vector<int>::iterator j = ids.begin(); j != ids.end(); ++j )
677  destructionObjects.insert(make_pair(*i, *j));
678  }
679  }
680  pc.closeBracket();
681  }
682 
683 
684  ASCString entryString = entry.toString();
685  pc.addString ( "Entry", entryString );
686  if ( pc.isReading() ) {
687  StringTokenizer st ( entryString );
689  }
690  if ( !fieldExists( entry ))
691  pc.error( "Building " + name + " has invalid entrance position!" );
692 
693  pc.addInteger( "Armor", _armor );
694 
695  if ( pc.find( "Features" ) || !pc.isReading())
697  else {
698  int special = 0;
699  pc.addTagInteger ( "Functions", special, cbuildingfunctionnum, buildingFunctionTags );
700  convertOldFunctions( special, pc.getFileName() );
701  }
702  pc.addInteger ( "Techlevel", technologylevel );
703 
704  pc.openBracket("TerrainAccess" );
705  terrainaccess.runTextIO ( pc );
706  pc.closeBracket();
707 
708 
709  pc.openBracket ( "ConstructionCost" );
710  productionCost.runTextIO ( pc );
711  pc.closeBracket ();
712 
714 
715  pc.addTagInteger( "ExternalLoading", externalloadheight, choehenstufennum, heightTags );
716 
717  pc.addBool ( "NotRemovable", buildingNotRemovable, false );
718 
719  techDependency.runTextIO( pc, ASCString("b")+strrr(id) );
720 
721  }
722  catch ( InvalidString ) {
723  pc.error ( "Could not parse building field coordinate");
724  }
725 }
726 
728 {
729  features.reset();
730  if ( abilities & 1 ) warningMessage ( location + ": The HQ function for buildings is not supported any more");
731  if ( abilities & 2 ) features.set( TrainingCenter );
732  if ( abilities & (1 << 3) ) features.set( InternalVehicleProduction );
733  if ( abilities & (1 << 4) ) features.set( AmmoProduction );
734  if ( abilities & (1 << 8) ) features.set( InternalUnitRepair );
735  if ( abilities & (1 << 9) ) features.set( RecycleUnits );
736  if ( abilities & (1 << 10) ) features.set( Research );
737  if ( abilities & (1 << 11) ) features.set( Sonar );
738  if ( abilities & (1 << 12) ) features.set( WindPowerPlant );
739  if ( abilities & (1 << 13) ) features.set( SolarPowerPlant );
740  if ( abilities & (1 << 14) ) features.set( MatterConverter );
741  if ( abilities & (1 << 15) ) features.set( MiningStation );
742  if ( abilities & (1 << 16) ) {
746  }
747  if ( abilities & (1 << 17) ) features.set( ProduceNonLeavableUnits );
748  if ( abilities & (1 << 18) ) features.set( ResourceSink );
749  if ( abilities & (1 << 19) ) {
752  }
753  if ( abilities & (1 << 20) ) features.set( ExternalAmmoTransfer );
754  if ( abilities & (1 << 21) ) features.set( NoObjectChaining );
755  if ( abilities & (1 << 22) ) features.set( SelfDestructOnConquer );
756  if ( abilities & (1 << 23) ) features.set( SatelliteView );
757 }
758 
int fuel
Definition: typen.h:101
A mathematical matrix for transforming Resources instance (which is mathematically a vector) into a d...
Definition: typen.h:158
ASCString filename
The name of the file from which the item was loaded.
Definition: typen.h:290
void read(tnstream &stream)
read the binary representation of this item from the given stream
The (base-) classes which are thrown as exceptions.
void paintSingleField(Surface &s, SPoint pos, const LocalCoordinate &localCoordinate, const PlayerColor &player, int weather=0, int constructionStep=0) const
int defaultMaxResearchpoints
when a building of this type is placed on a map, its maxResearch property will be set to this value ...
void addBool(const ASCString &name, bool &property)
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
MapCoordinate getFieldCoordinate(const MapCoordinate &entryOnMap, const LocalCoordinate &localCoordinate) const
returns the Mapcoordinate of a buildings field
int getBIPicture(const LocalCoordinate &localCoordinate, int weather=0, int constructionStep=0) const
const int choehenstufennum
The number of levels of height.
Definition: typen.h:67
int energy
Definition: typen.h:99
ASCString & toUpper()
Definition: ascstring.cpp:55
virtual ASCString getLocation()
returns the location of the stream.
Definition: basestrm.cpp:274
void blit(const Surface &src, Surface &dst, SPoint dstPos)
Definition: blitter.h:349
int externalloadheight
bitmapped: units on these levels of height may be refuelled when standing next to the buildings entry...
Definition: buildingtype.h:93
Surface w_picture[cwettertypennum][maxbuildingpicnum][4][6]
Definition: buildingtype.h:42
TechAdapterDependency techDependency
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
NullParamType nullParam
Definition: blitter.cpp:30
int getFirstBit(int zahl)
Count the number of zero bits on the LSB side of "zahl".
Definition: misc.cpp:45
ResourceMatrix productionEfficiency
void addImage(const ASCString &name, Surface &property, ASCString &fileName, bool applyFieldMask)
void runTextIO(PropertyContainer &pc)
registers the properties of this item for loading/writing into asctxt files
void write(tnstream &stream) const
write the binary representation of this item to the given stream
void addIntegerArray(const ASCString &name, vector< int > &property, bool required=true)
Functions to evaluate the parsed *.asctxt files.
A local coordinate referencing a single field that a building covers.
Definition: buildingtype.h:57
void runTextIO(PropertyContainer &pc)
Definition: typen.cpp:254
void addTagInteger(const ASCString &name, int &property, int tagNum, const char **tags, bool inverted=false)
bool buildingNotRemovable
if true, this building can not be removed by the player with his construction vehicles ...
Definition: buildingtype.h:126
void warningMessage(const ASCString &str)
int technologylevel
not used at the moment
Definition: buildingtype.h:83
static Surface createSurface(int width, int height, SDLmm::Color color=255)
Definition: surface.cpp:387
const char * weatherAbbrev[cwettertypennum]
static const int cbuildingfunctionnum
the number of legacy abilities that a building could be equipped with
Definition: buildingtype.h:54
A system that provides a set of images for vehicles, buildings, etc.
static const int functionNum
The interface for all kinds of IO stream.
const int building_version
virtual Uint8 readUint8(void)
Reads a 8 bit unsigned Integer.
Definition: basestrm.cpp:305
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
ASCString description
short description of the units role, for example "strategic bomber"
void runTextIO(PropertyContainer &pc, const ASCString &defaultTechAdapter="")
Definition: research.cpp:454
int view
the visibility range
ASCString extractFileName_withoutSuffix(const ASCString &filename)
Definition: basestrm.cpp:2585
virtual void writeString(const string &pc, bool binary=true)
writes the C++ String pc to the stream.
Definition: basestrm.cpp:545
void read(tnstream &stream)
Definition: surface.cpp:265
void runTextIO(PropertyContainer &pc)
Definition: terraintype.cpp:96
#define fieldsizey
Definition: typen.h:441
virtual ASCString getFileName()=0
void write(tnstream &stream) const
Definition: surface.cpp:218
#define fielddisthalfx
Definition: typen.h:435
bool fieldExists(const LocalCoordinate &localCoordinate) const
returns whether this building covers the given field
Definition: buildingtype.h:108
const int maxbuildingpicnum
The maximum number of number of different images for a building and a weather. For example...
Definition: typen.h:70
void error(const ASCString &errmsg)
char * strrr(int a)
converts a to a string.
Definition: misc.cpp:66
void applyFieldMask(Surface &s, int x, int y, bool detecColorKey)
Definition: surface.cpp:593
BuildingType(void)
A simple string tokenizer.
std::bitset< 64 > features
Coordinate on the twodimensional map.
Definition: typen.h:202
int jamming
the radar jamming power
const char * buildingFunctionTags[24]
deprecated
ASCString getNextToken()
BitSet weatherBits
Definition: buildingtype.h:45
virtual void writeUint8(Uint8 c)
Writes a 8 bit unsigned Integer.
Definition: basestrm.cpp:380
The interface for the buildingtype class.
int efficiencymaterial
currently only used by mining stations: the efficiency of the resource extraction from the ground...
void paint(Surface &s, SPoint pos, const PlayerColor &player, int weather=0, int constructionStep=0) const
int material
Definition: typen.h:100
const char * heightTags[choehenstufennum]
const int guardInt
const Surface & getPicture(const LocalCoordinate &localCoordinate, int weather=0, int constructionStep=0) const
The IO for many basic classes and structurs of ACS.
#define fieldsizex
Definition: typen.h:440
TerrainAccess terrainaccess
the terrain properties which are necessary for the building to be constructed there ...
Definition: buildingtype.h:86
SDLmm::SPoint SPoint
Definition: surface.h:27
#define fielddistx
Definition: typen.h:433
virtual ASCString readString(bool includeCR=false)
Reads and returns a string.
Definition: basestrm.cpp:535
void read(tnstream &stream)
Definition: terraintype.cpp:74
int height
the levels of height which this unit can enter
void addInteger(const ASCString &name, int &property)
int _armor
the armor of the buildingtype.
Definition: buildingtype.h:80
int nominalresearchpoints
the number of reseach points for which the plus settings apllies
int getMemoryFootprint() const
bool field_Exists[xdimension][ydimension]
Definition: buildingtype.h:41
void write(tnstream &stream) const
Definition: terraintype.cpp:86
virtual void closeBracket()
int construction_steps
the number of stages that are required to construct a building using a construction unit...
Definition: buildingtype.h:89
void runTextIO(PropertyContainer &pc)
registers the properties of this item for loading/writing into asctxt files
This String Tokenizer is NOT intended to be a general purpose tool. It is exclusively used by the Tex...
DestructionObjects destructionObjects
when the building is destroyed, it can leave rubble objects behind. If set to 0 no objects are being ...
Definition: buildingtype.h:71
const char * weatherTags[cwettertypennum]
int maxresearchpoints
the maximum number of research points a research center may produce
ASCString location
The filename and location on disk (including containerfiles) of the object.
Definition: typen.h:296
virtual void openBracket(const ASCString &name)
void read(tnstream &stream)
Definition: research.cpp:434
ASCString infotext
an extensive information about the unit/building which may be several paragraphs long ...
void convertOldFunctions(int abilities, const ASCString &location)
the method for specifying a building's abilility was change at some point in time.
void megaBlitter(const Surface &src, Surface &dst, const SPoint &pos, const SourceColorTransformParameter &scmp=nullParam, const ColorMergerParameter &cmp=nullParam, const SourcePixelSelectorParameter spsp=nullParam, const TargetPixelSelectorParameter tpsp=nullParam)
Definition: blitter.h:410
void addString(const ASCString &name, ASCString &property)
const char * containerFunctionTags[ContainerBaseType::functionNum]
int bi_picture[cwettertypennum][maxbuildingpicnum][4][6]
Definition: buildingtype.h:43
bool find(const ASCString &name)
void addTagArray(const ASCString &name, BitSet &property, int tagNum, const char **tags, bool inverted=false)
Resources defaultProduction
if a new building is constructed, this will be the resource production of the building ...
LocalCoordinate entry
the position of the entrance, which is the field of the building where units can enter and leave ...
Definition: buildingtype.h:74
const int cwettertypennum
The number of different weather.
Definition: typen.h:61
ASCString name
a short name, for example B-52
LocalCoordinate getLocalCoordinate(const MapCoordinate &entryOnMap, const MapCoordinate &field) const
converts a global coordinate into a local coordinate.
void write(tnstream &stream) const
write the binary representation of this item to the given stream
void read(tnstream &stream)
read the binary representation of this item from the given stream
#define fielddisty
Definition: typen.h:434
int efficiencyfuel
currently only used by mining stations: the efficiency of the resource extraction from the ground...
void write(tnstream &stream) const
Definition: research.cpp:445