Advanced Strategic Command
objecttype.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  objecttype.cpp - description
3  -------------------
4  begin : Fri Jul 27 2001
5  copyright : (C) 2001 by Martin Bickel
6  email : bickel@asc-hq.org
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 
19 #include <algorithm>
20 #include <set>
21 
22 #include "objecttype.h"
23 #include "graphicset.h"
24 #include "textfileparser.h"
25 #include "textfiletags.h"
26 #include "sgstream.h"
27 #include "textfile_evaluation.h"
28 #include "mapalgorithms.h"
29 #include "graphics/blitter.h"
30 #include "graphics/drawing.h"
31 #include "fieldimageloader.h"
32 #include "memsize_interface.h"
33 #include "iconrepository.h"
34 
35 
36 #ifndef converter
37 #include "gamemap.h"
38 #endif
39 
40 
41 
43 {
44  terrain_and.flip();
45 }
46 
47 ObjectType :: ObjectType ( void ) : rotateImage(false)
48 {
50  groupID = -1;
51 
52  displayMethod = 0;
54  netBehaviour = 0;
55  viewbonus_abs = -1;
56  viewbonus_plus = 0;
57  imageHeight = 0;
58  physicalHeight = 0;
59  growthRate = 0;
60  growOnUnits = false;
61  lifetime = -1;
62  growthDuration = -1;
63 }
64 
65 const int ObjectType::namingMethodNum = 3;
66 
67 const char* ObjectType::namingMethodNames[namingMethodNum+1] = { "ReplaceTerrain", "AddToTerrain", "UnNamed", NULL };
68 
69 
70 
71 
73 {
74  return fieldModification[getWeather(weather)];
75 }
76 
77 bool ObjectType :: buildable ( MapField* fld ) const
78 {
79  #ifndef converter
80  if ( fld->building && !growOnUnits )
81  return false;
82 
83  if ( getFieldModification( fld->getWeather() ).terrainaccess.accessible ( fld->bdt ) <= 0 )
84  return false;
85 
86  #endif
87  return true;
88 }
89 
91 {
92  return 1 << physicalHeight;
93 }
94 
95 
96 int ObjectType :: getWeather( int weather ) const
97 {
98  while ( !this->weather.test(weather) ) {
99  if ( weather == 5 )
100  weather = 4;
101  else
102  if ( weather == 2 )
103  weather = 1;
104  else
105  weather = 0;
106  }
107  return weather;
108 }
109 
110 
111 const OverviewMapImage* ObjectType :: getOverviewMapImage( int picnum, int weather ) const
112 {
113  weather = getWeather(weather);
114 
115  if ( weatherPicture[weather].images.size() <= picnum )
116  picnum = 0;
117 
118  if ( weatherPicture[weather].bi3pic[picnum] > 0 )
119  return GraphicSetManager::Instance().getQuickView( weatherPicture[weather].bi3pic[picnum] );
120  else {
121  if ( weatherPicture[weather].overviewMapImage.size() <= picnum )
122  weatherPicture[weather].overviewMapImage.resize( picnum+1 );
123 
124  if ( !weatherPicture[weather].overviewMapImage[picnum].valid() )
125  weatherPicture[weather].overviewMapImage[picnum].create( weatherPicture[weather].images[picnum] );
126 
127  return &weatherPicture[weather].overviewMapImage[picnum];
128  }
129 }
130 
131 
132 const Surface& ObjectType :: getPicture ( int i, int w ) const
133 {
134  w = getWeather(w);
135 
136  if ( weatherPicture[w].images.size() <= i ) {
137  if ( i >= 64 && weatherPicture[w].images.size() > 34 )
138  i = 34;
139  else
140  i = 0;
141  }
142 
143  if ( weatherPicture[w].bi3pic[i] > 0 )
144  return GraphicSetManager::Instance().getPic(weatherPicture[w].bi3pic[i]);
145  else {
146  const Surface& s = weatherPicture[w].images[i];
147  if ( s.valid() )
148  return s;
149  else {
150  if ( i < 65 && weatherPicture[w].images.size() >= 66 ) {
151  const Surface& s2 = weatherPicture[w].images[65];
152  if ( s2.valid())
153  return s2;
154  }
155  if ( i < 64 && weatherPicture[w].images.size() >= 65 ) {
156  const Surface& s2 = weatherPicture[w].images[64];
157  if ( s2.valid())
158  return s2;
159  }
160  return IconRepository::getIcon("red-x-field.png");
161  }
162  }
163 }
164 
165 
166 void ObjectType :: display ( Surface& surface, const SPoint& pos, int dir, int weather ) const
167 {
168  weather = getWeather(weather);
169 
170  if ( id == 4 ) {
171  switch ( dir ) {
172  case 68 : realDisplay( surface, pos, 9, weather ); break;
173  case 34 : realDisplay( surface, pos, 10, weather ); break;
174  case 17 : realDisplay( surface, pos, 11, weather ); break;
175  case 136 : realDisplay( surface, pos, 12, weather ); break;
176  case 0 : realDisplay( surface, pos, 0, weather ); break;
177  default : {
178  for (int i = 0; i <= 7; i++)
179  if ( dir & (1 << i))
180  realDisplay( surface, pos, i+1, weather );
181  }
182  }
183  } else
184  realDisplay( surface, pos, dir, weather );
185 
186 }
187 
188 
189 template<
190 int BytesPerSourcePixel,
191 int BytesPerTargetPixel
192 >
194 {
195  public:
198  private:
199  SourcePixelType srcColorKey;
200  TargetPixelType destColorKey;
201  public:
202  ColorConverter_PassThrough( const Surface& sourceSurface, Surface& targetSurface )
203  {}
204  ;
206  {
207  return sp;
208  };
209 };
210 
211 
212 
213 void ObjectType::realDisplay ( Surface& surface, const SPoint& pos, int dir, int weather ) const
214 {
215  int flip = 0;
216  if ( dir < weatherPicture[weather].flip.size() )
217  flip = weatherPicture[weather].flip[dir];
218 
219  if ( displayMethod==1 ) { // SHADOW: buried pipeline, tracks, ...
220  const Surface& s = getPicture( dir, weather);
221  if ( dir != 0 && rotateImage ) {
222  megaBlitter<ColorTransform_None, ColorMerger_AlphaLighter, SourcePixelSelector_CacheRotation,TargetPixelSelector_All>(s, surface, pos, nullParam,0.7,make_pair(&s,directionangle[dir%6]),nullParam);
223  } else {
224  megaBlitter<ColorTransform_None, ColorMerger_AlphaLighter, SourcePixelSelector_DirectFlip,TargetPixelSelector_All>(s, surface, pos, nullParam, 0.7, flip, nullParam);
225  }
226  } else
227  if ( displayMethod == 2 ) { // translation
228  const Surface& s = getPicture( dir, weather);
229  if ( !s.valid() )
230  return;
231 
232  if ( s.GetPixelFormat().BitsPerPixel() == 8 ) {
233  MegaBlitter< 1,4,
239  >
240  blitter;
241  blitter.setFlipping( flip & 1, flip & 2 );
242  blitter.blit( s, surface, pos );
243  } // else
244  // warning("objects with palette translation as display method may not have truecolor images");
245  } else
246  if ( displayMethod == 4 ) {
247  const Surface& s = getPicture( dir, weather);
248  if ( !s.valid() )
249  return;
250 
251  if ( dir != 0 && rotateImage ) {
252  megaBlitter<ColorTransform_None, ColorMerger_AlphaMixer, SourcePixelSelector_CacheRotation ,TargetPixelSelector_All>(s, surface, pos, nullParam,nullParam,make_pair(&s,directionangle[dir%6]),nullParam);
253  } else {
254  megaBlitter<ColorTransform_None, ColorMerger_AlphaMixer, SourcePixelSelector_DirectFlip, TargetPixelSelector_All>(s, surface, pos, nullParam,nullParam, flip, nullParam);
255  }
256  } else {
257  bool disp = true;
258  #ifndef karteneditor
259  if ( displayMethod == 3 ) // mapeditorOnly
260  disp = false;
261  #endif
262  if ( disp ) {
263  const Surface& s = getPicture( dir, weather);
264  if ( !s.valid() )
265  return;
266  if ( flip ) {
267  // if ( s.flags() & SDL_SRCALPHA )
268  megaBlitter<ColorTransform_None, ColorMerger_AlphaMerge, SourcePixelSelector_DirectFlip,TargetPixelSelector_All>(s, surface, pos, nullParam,nullParam, flip, nullParam);
269  // else
270  // megaBlitter<ColorTransform_None, ColorMerger_AlphaOverwrite, SourcePixelSelector_DirectFlip,TargetPixelSelector_All>(getPicture( dir, weather), surface, pos, nullParam,nullParam, flip, nullParam);
271  } else {
272  if ( dir != 0 && rotateImage ) {
273  // if ( s.flags() & SDL_SRCALPHA )
274  megaBlitter<ColorTransform_None, ColorMerger_AlphaMerge, SourcePixelSelector_CacheRotation ,TargetPixelSelector_All>(s, surface, pos, nullParam,nullParam,make_pair(&s,directionangle[dir%6]),nullParam);
275  // else
276  // megaBlitter<ColorTransform_None, ColorMerger_AlphaOverwrite, SourcePixelSelector_CacheRotation,TargetPixelSelector_All>(s, surface, pos, nullParam,nullParam,make_pair(&s,directionangle[dir]),nullParam);
277  } else {
278  // if ( s.flags() & SDL_SRCALPHA )
279  megaBlitter<ColorTransform_None, ColorMerger_AlphaMerge, SourcePixelSelector_Plain,TargetPixelSelector_All>(s, surface, pos, nullParam,nullParam,nullParam,nullParam);
280  // else
281  // megaBlitter<ColorTransform_None, ColorMerger_AlphaOverwrite, SourcePixelSelector_Plain,TargetPixelSelector_All>(getPicture( dir, weather), surface, pos, nullParam,nullParam,nullParam,nullParam);
282  }
283  }
284  }
285  }
286 }
287 
288 
289 void ObjectType :: display ( Surface& surface, const SPoint& pos ) const
290 {
291  display ( surface, pos, rotateImage? 0 : 64, 0 );
292 }
293 
294 
295 
296 
297 #ifndef converter
298 
299 namespace ForestCalculation {
300 
301 /*
302  These smoothing functions are straight conversions from Joerg Richter's routines
303  he made for his Battle Isle Map editor
304  Many thanks for giving them to me !
305 */
306 
307 const int woodformnum = 28;
308 int woodform[ woodformnum ] = { 63,30,60,39,51,28,35,48,6,57,15,14,56,7,49,47,59,31,61,60,55, -1,-1,-1,-1,-1,-1,-1 };
309 
310 
312  4, 7, 10,101,
313  1,0x0001,243,
314  1,0x0115,243, // die die garnicht gehen
315  30,0x3F, 30,243,0x3F, 60,243,0x3F, 39,243,0x3F, 51,243,
316  0x3F, 28,243,0x3F, 35,243,0x3F, 48,243,0x3F, 6,243,
317  0x3F, 57,243,0x3F, 15,243,0x3F, 14,243,0x3F, 56,243,
318  0x3F, 7,243,0x3F, 49,243,0x3F, 47,243,0x3F, 59,243,
319  0x3F, 31,243,0x3F, 61,243,0x3F, 62,243,0x3F, 55,243,
320  0x3F, 23,243,0x3F, 46,243,0x3F, 29,243,0x3F, 58,243,
321  0x3F, 53,243,0x3F, 43,243,0x3F, 22,243,0x3F, 38,243,
322  0x3F, 50,243,0x3F, 52,243,
323  7,264,265,266,267,268,269,270
324  };
325 
327  4, 7, 10,101,
328  1,0x0001,243,
329  1,0x0115,243,
330  30,0x3F, 30,244,0x3F, 60,245,0x3F, 39,246,0x3F, 51,247,
331  0x3F, 28,248,0x3F, 29,248,0x3F, 35,249,0x3F, 43,249,
332  0x3F, 48,250,0x3F, 50,250,0x3F, 52,250,0x3F, 6,251,
333  0x3F, 22,251,0x3F, 38,251,0x3F, 57,252,0x3F, 15,253,
334  0x3F, 14,254,0x3F, 46,254,0x3F, 56,255,0x3F, 58,255,
335  0x3F, 7,256,0x3F, 23,256,0x3F, 49,257,0x3F, 53,257,
336  0x3F, 47,258,0x3F, 59,259,0x3F, 31,260,0x3F, 61,261,
337  0x3F, 62,262,0x3F, 55,263,
338  7,264,265,266,267,268,269,270
339  };
340 
342  4, 7, 8, 9,
343  1,0x011C,243,
344  0,
345  0,
346  1,243
347  };
348 
349 
350 
351 
352 int SmoothBanksData [] = {
353  4, 7, 16, 77,
354  1, 0x0103, 95, // was zu ersetzen ist - blaues wasser }
355  4, 0x010F, 95, // was als 1 zu betrachten ist - wasser und strand }
356  0x010E, 0, // - Hafen }
357  0x0109,110, // - Steine und Schilf }
358  0x0107,121, // - Schilf }
359  20,0x3F,59, 98, 0x3F,51, 98, 0x3F,47, 99, 0x3F,39, 99, // durch was ersetzen }
360  0x3F,31,100, 0x3F,30,100, 0x3F,61,101, 0x3F,60,101,
361  0x3F,55,102, 0x3F,62,103, 0x3F,35,104, 0x3F,28,105,
362  0x3F,56,106, 0x3F,48,106, 0x3F,49,106, 0x3F,57,106,
363  0x3F,14,107, 0x3F,15,107, 0x3F, 7,107, 0x3F, 6,107,
364  0 // wenn nicht gefunden }
365  };
366 
368  4, 7, 8, 9,
369  1, 0x010C, 98, // { alle str"nder ersetzen }
370  0,
371  0,
372  1, 95 // durch flaches wasser ersetzen }
373  };
374 
375 
377  4, 7, 16, 77,
378  1,0x0103,385, // dunkels wasser }
379  4,0x0103,385, // dunkles wasser }
380  0x010A,373,
381  0x0104,449,
382  0x0104,463,
383  20,0x3F,59,373, 0x3F,51,373, 0x3F,47,374, 0x3F,39,374, // durch was ersetzen }
384  0x3F,31,375, 0x3F,30,375, 0x3F,61,376, 0x3F,60,376,
385  0x3F,55,377, 0x3F,62,378, 0x3F,35,379, 0x3F,28,380,
386  0x3F,56,381, 0x3F,48,381, 0x3F,49,381, 0x3F,57,381,
387  0x3F,14,382, 0x3F,15,382, 0x3F, 7,382, 0x3F, 6,382,
388  0 // wenn nicht gefunden }
389  };
390 
392  4, 7, 8, 9,
393  1,0x010A,373,
394  0,
395  0,
396  1,385
397  };
398 
399 
400 
401 class Smoothing {
402  GameMap* actmap;
403  public:
404  Smoothing ( GameMap* gamemap ) : actmap ( gamemap ) {};
405  MapField* getfield ( int x, int y )
406  {
407  return actmap->getField ( x, y );
408  }
409 
410  int IsInSetOfWord( int Wert, int* A )
411  {
412  int Pos = 0;
413  int Anz1 = A[Pos];
414  Pos++;
415  int res = 0;
416  int Anz2;
417  while ( Anz1 > 0 ) {
418  int W = A[Pos];
419  Pos++;
420  Anz2 = W & 0xff;
421 
422  if ( W & 0x100 ) {
423  if (( Wert>= A[Pos]) && (Wert< A[Pos]+Anz2))
424  res = 1;
425  Pos++;
426  } else {
427  while ( Anz2 > 0) {
428  if ( Wert == A[Pos] )
429  res = 1;
430  Pos++;
431  Anz2--;
432  }
433  }
434 
435  Anz1--;
436  }
437 
438  return res;
439  };
440 
441 
442  int GetNeighbourMask( int x, int y, int* Arr, ObjectType* o )
443  {
444  int res = 0;
445  for ( int d = 0; d < sidenum; d++ ) {
446  int x1 = x;
447  int y1 = y;
448  x1 += getnextdx ( d, y1 );
449  y1 += getnextdy ( d );
450  MapField* fld = getfield ( x1, y1 );
451  if ( fld ) {
452 
453  Object* obj = fld->checkForObject ( o );
454  if ( obj )
455  if ( obj->typ->weather.test(0) )
456  if ( IsInSetOfWord ( obj->typ->weatherPicture[0].bi3pic[ obj->dir ], Arr ))
457  res += 1 << d;
458 
459  // if ( fld->checkforobject ( o ) )
460  // res += 1 << d;
461  } else
462  res += 1 << d;
463 
464  }
465  return res;
466  };
467 
468  int GetNeighbourMask( int x, int y, int* Arr )
469  {
470  int res = 0;
471  for ( int d = 0; d < sidenum; d++ ) {
472  int x1 = x;
473  int y1 = y;
474  x1 += getnextdx ( d, y1 );
475  y1 += getnextdy ( d );
476  MapField* fld = getfield ( x1, y1 );
477  if ( fld ) {
478 
479  if ( IsInSetOfWord ( fld->typ->bi_pict, Arr ))
480  res += 1 << d;
481 
482  } else
483  res += 1 << d;
484 
485  }
486  return res;
487  };
488 
489 
490  /*
491  Res:= 0;
492  for I:= Oben to LOben do begin
493  GetNear(P, I, R);
494  if ValidEck(R) then
495  Res:= Res or
496  (Byte(IsInSetOfWord( TRawArrEck( Mission.ACTN[R.Y, R.X] )[TerObj], Arr)) shl Ord(I))
497  else
498  Res:= Res or 1 shl Ord(I);
499  end;
500  GetNeighbourMask:= Res;
501  end;
502  */
503 
504 
505  int SearchAndGetInt( int Wert, int* Arr, int* Res )
506  {
507  int Anz = Arr[0];
508  int Pos = 1;
509  while ( Anz> 0 ) {
510  if (( Wert & Arr[Pos]) == Arr[Pos+1] ) {
511  *Res = Arr[Pos+2];
512  return Anz > 0;
513  }
514  Pos += 3;
515  Anz--;
516  }
517  return Anz> 0;
518  };
519 
520 
521  int SmoothIt( ObjectType* TerObj, int* SmoothData )
522  {
523  int P0 = SmoothData[0];
524  int P1 = SmoothData[1];
525  int P2 = SmoothData[2];
526  int P3 = SmoothData[3];
527  int Res = 0;
528  for ( int Y = 0 ; Y < actmap->ysize; Y++ )
529  for ( int X = 0; X < actmap->xsize; X++ ) {
530  if ( TerObj ) {
531  Object* obj = getfield ( X, Y )-> checkForObject ( TerObj );
532  if ( obj && obj->typ->weather.test(0) ) {
533  int Old = obj->dir; // bipicnum
534  // Old:= TRawArrEck(Mission.ACTN[Y, X])[TerObj]; // bisherige Form / oder Bildnummer ?
535 
536  if ( IsInSetOfWord( obj->typ->weatherPicture[0].bi3pic[ obj->dir ], &SmoothData[P0] )) { // Nur die "allesWald"-fielder werden gesmootht
537  int Mask = GetNeighbourMask( X, Y, &SmoothData[P1], TerObj );
538  if ( Mask < 63 ) {
539  int nw;
540  if ( !SearchAndGetInt(Mask, &SmoothData[P2], &nw) ) { // Wenn kein passendes field gefunden wurde
541  if ( SmoothData[P3] == 0 || SmoothData[P3] == 1 )
542  nw = SmoothData[P3+ 1];
543  else
544  nw = SmoothData[P3+ 1 ]; // + (ticker % SmoothData[P3] )
545  }
546  for ( int i = 0; i < TerObj->weatherPicture[0].bi3pic.size(); i++ )
547  if ( TerObj->weatherPicture[0].bi3pic[ i ] == nw )
548  obj->dir = i;
549  }
550  }
551  if ( Old != obj->dir )
552  Res = 1;
553  }
554  } else {
555  MapField* fld = getfield ( X, Y );
556  TerrainType::Weather* old = fld->typ;
557  // int odir = fld->direction;
558 
559  if ( IsInSetOfWord( fld->typ->bi_pict, &SmoothData[P0] )) { // Nur die "allesWald"-fielder werden gesmootht
560  int Mask = GetNeighbourMask( X, Y, &SmoothData[P1] );
561  if ( Mask < 63 ) {
562  int nw;
563  if ( !SearchAndGetInt(Mask, &SmoothData[P2], &nw) ) { // Wenn kein passendes field gefunden wurde
564  if ( SmoothData[P3] == 0 || SmoothData[P3] == 1 )
565  nw = SmoothData[P3+ 1];
566  else
567  nw = SmoothData[P3+ 1 ]; // + (ticker % SmoothData[P3] )
568  }
569  /*
570  for ( int i = 0; i < terrainTypeRepository.getNum; i++ ) {
571  pterraintype trrn = terrainTypeRepository.getObject_byPos( i );
572  if ( trrn )
573  for ( int j = 0; j < cwettertypennum; j++ )
574  if ( trrn->weather[j] )
575  for ( int k = 0; k < sidenum; k++ )
576  if ( trrn->weather[j]->pict )
577  if ( trrn->weather[j]->bi_pict == nw ) {
578  fld->typ = trrn->weather[j];
579  fld->direction = k;
580  fld->setparams();
581  }
582  }
583  */
584  }
585  }
586  if ( old != fld->typ )
587  Res = 1;
588 
589  }
590  }
591  return Res;
592  };
593 
594 
595 
596  void smooth ( int what, ObjectType* woodObj )
597  {
598  if ( what & 2 ) {
599  SmoothIt( NULL, UnSmoothBanksData);
601  SmoothIt( NULL, SmoothBanksData);
603  }
604 
605  if ( what & 1 ) {
606  if ( woodObj ) {
607  int count = 0;
608  while ( SmoothIt ( woodObj, SmoothTreesData0 ) && count < 20 ) {
609  count++;
610  }
611  SmoothIt ( woodObj, SmoothTreesData);
612  }
613  }
614  /* while SmoothIt(1, SmoothDarkTreesData0) do ShowAgain:= true;
615  if SmoothIt(1, SmoothDarkTreesData) then ShowAgain:= true;
616  if ShowAgain then begin
617  ShowAll;
618  Repaint;
619  end; */
620  };
621 
622 };
623 
624 
625 /*
626 procedure TMissView.Smooth;
627  var
628  ShowAgain: Boolean;
629  begin
630  ShowAgain:= false;
631  if SmoothIt(0, SmoothBanksData) then ShowAgain:= true;
632  if SmoothIt(0, SmoothDarkBanksData) then ShowAgain:= true;
633 
634  while SmoothIt(1, SmoothTreesData0) do ShowAgain:= true;
635  if SmoothIt(1, SmoothTreesData) then ShowAgain:= true;
636 { while SmoothIt(1, SmoothDarkTreesData0) do ShowAgain:= true;
637  if SmoothIt(1, SmoothDarkTreesData) then ShowAgain:= true;}
638  if ShowAgain then begin
639  ShowAll;
640  Repaint;
641  end;
642  end;
643 
644 function IsInSetofWord(Wert: Word; var A: array of Word): Boolean;
645  var
646  Anz1: Word;
647  Anz2: Word;
648  W: Word;
649  Pos: Word;
650  begin
651  Pos:= 0;
652  Anz1:= A[Pos];
653  Inc(Pos);
654  IsInSetOfWord:= false;
655  while Anz1> 0 do begin
656  W:= A[Pos];
657  Inc(Pos);
658  Anz2:= Lo(W);
659  case Hi(W) of
660  0: begin
661  while Anz2> 0 do begin
662  if Wert= A[Pos] then IsInSetOfWord:= true;
663  Inc(Pos);
664  Dec(Anz2);
665  end;
666  end;
667  1: begin
668  if (Wert>= A[Pos]) and (Wert< A[Pos]+Anz2) then
669  IsInSetOfWord:= true;
670  Inc(Pos);
671  end;
672  end;
673  Dec(Anz1);
674  end;
675  end;
676 
677 
678 
679 ****************
680 Smoothdaten
681 ****************
682 
683 {
684  Aufbau eines Set of Ints
685 
686  1. word anzahl der bl"cke
687  dann folgen die bl"cke
688 
689  aufbau eines blocks:
690  1. word:
691  hibyte- optionsnummer
692  0- nur rawdaten lobyte ist anzahl der folgenden raws
693  1- ab hier lobyte ist anzahl der ab hier
694  weitere ist entweder raw oder startzahl
695 }
696 
697 
698  SmoothBanksData: array[0..77] of Word= (
699  4, 7, 16, 77,
700  1, $0103, 95, { was zu ersetzen ist - blaues wasser }
701  4, $010F, 95, { was als 1 zu betrachten ist - wasser und strand }
702  $010E, 0, { - Hafen }
703  $0109,110, { - Steine und Schilf }
704  $0107,121, { - Schilf }
705  20,$3F,59, 98, $3F,51, 98, $3F,47, 99, $3F,39, 99, { durch was ersetzen }
706  $3F,31,100, $3F,30,100, $3F,61,101, $3F,60,101,
707  $3F,55,102, $3F,62,103, $3F,35,104, $3F,28,105,
708  $3F,56,106, $3F,48,106, $3F,49,106, $3F,57,106,
709  $3F,14,107, $3F,15,107, $3F, 7,107, $3F, 6,107,
710  0 { wenn nicht gefunden }
711  );
712 
713  UnSmoothBanksData: array[0..10] of Word= (
714  4, 7, 8, 9,
715  1, $010C, 98, { alle str"nder ersetzen }
716  0,
717  0,
718  1, 95 { durch flaches wasser ersetzen }
719  );
720 
721 
722  SmoothDarkBanksData: array[0..77] of Word= (
723  4, 7, 16, 77,
724  1,$0103,385, { dunkels wasser }
725  4,$0103,385, { dunkles wasser }
726  $010A,373,
727  $0104,449,
728  $0104,463,
729  20,$3F,59,373, $3F,51,373, $3F,47,374, $3F,39,374, { durch was ersetzen }
730  $3F,31,375, $3F,30,375, $3F,61,376, $3F,60,376,
731  $3F,55,377, $3F,62,378, $3F,35,379, $3F,28,380,
732  $3F,56,381, $3F,48,381, $3F,49,381, $3F,57,381,
733  $3F,14,382, $3F,15,382, $3F, 7,382, $3F, 6,382,
734  0 { wenn nicht gefunden }
735  );
736 
737  UnSmoothDarkBanksData: array[0..10] of Word= (
738  4, 7, 8, 9,
739  1,$010A,373,
740  0,
741  0,
742  1,385
743  );
744 
745 */
746 
747 
748 void smooth ( int what, GameMap* gamemap, ObjectType* woodObj )
749 {
750  Smoothing s ( gamemap );
751  s.smooth ( what, woodObj );
752 }
753 
754 
756 {
757  for ( int y = 0; y < actmap->ysize ; y++)
758  for ( int x = 0; x < actmap->xsize ; x++) {
759  MapField* fld = actmap->getField(x,y);
760 
761  for ( MapField::ObjectContainer::iterator i = fld->objects.begin(); i != fld->objects.end(); i++ )
762  if ( i->typ == woodObj )
763  i->dir = 0;
764  }
765 
766  Smoothing s ( actmap );
767  s.smooth( 1, woodObj );
768  return;
769 
770  int run = 0;
771  int changed ;
772  do {
773  changed = 0;
774  for ( int y = 0; y < actmap->ysize ; y++)
775  for ( int x = 0; x < actmap->xsize ; x++) {
776  MapField* fld = actmap->getField(x,y);
777 
778  for ( MapField::ObjectContainer::iterator o = fld->objects.begin(); o != fld->objects.end(); o++ )
779  if ( o->typ == woodObj ) {
780  int c = 0;
781  for ( int i = 0; i < sidenum; i++) {
782  int a = x;
783  int b = y;
784  a += getnextdx ( i, b );
785  b += getnextdy ( i );
786  MapField* fld2 = actmap->getField(a,b);
787 
788  if ( fld2 ) {
789  Object* oi = fld2->checkForObject ( o->typ );
790  if ( oi )
791  if ( oi->dir <= 20 || run == 0 )
792  c |= 1 << i ;
793  }
794  }
795 
796  // int found = 0;
797  int dr;
798  for ( int j = 0; j < woodformnum; j++ )
799  if ( woodform[j] == c ) {
800  dr = j;
801  // found = 1;
802  }
803 
804 // if ( !found )
805 // dr = 21 + ticker % 7;
806 
807  if ( o->dir != dr && !(o->dir >= 21 && dr >= 21)) {
808  o->dir = dr;
809  fld->setparams();
810  changed = 1;
811  }
812  }
813  }
814  run++;
815  } while ( changed );
816 }
817 
818 } // namespace forestcalculation
819 
820 
821 #else // ifdef converter
822 
823 
824 
825 #endif
826 
827 
829 {
830  int size = sizeof( *this );
831  for ( int ww = 0; ww < cwettertypennum; ww++ ) {
832  size += for_each( weatherPicture[ww].images.begin(), weatherPicture[ww].images.end(), MemorySum<Surface>() ).size;
833  size += for_each( weatherPicture[ww].overviewMapImage.begin(), weatherPicture[ww].overviewMapImage.end(), MemorySum<OverviewMapImage>() ).size;
834  }
835 
836  return size;
837 }
838 
839 
840 
841 const int object_version = 22;
842 
843 void ObjectType :: read ( tnstream& stream )
844 {
845  int version = stream.readInt();
846 
847  if ( version < 9 )
848  fatalError ( "sorry, the old file format for objects cannot be loaded any more" );
849 
850  if ( version <= object_version && version >= 9 ) {
851 
852  id = stream.readInt();
853  groupID = stream.readInt();
854 
855  int ___weather = stream.readInt();
856  weather.reset();
857  for ( int i = 0; i < cwettertypennum; i++ )
858  if ( ___weather & ( 1 << i ))
859  weather.set ( i );
860 
861  visibleago = stream.readInt();
862 
863  if ( version <= 20 ) {
864  vector<int> IDs;
865  readClassContainer( IDs, stream );
866  linkableObjects.clear();
867  for ( int i = 0; i < IDs.size(); ++i )
868  linkableObjects.push_back( IntRange(IDs[i]));
869 
870  readClassContainer( IDs, stream );
871  linkableTerrain.clear();
872  for ( int i = 0; i < IDs.size(); ++i )
873  linkableTerrain.push_back( IntRange(IDs[i]));
874  } else {
877  }
878  armor = stream.readInt();
879 
880  for ( int i = 0; i < cwettertypennum; ++i ) {
881  fieldModification[i].terrainaccess.read( stream );
882  fieldModification[i].terrain_and.read ( stream );
883  fieldModification[i].terrain_or.read ( stream );
884  fieldModification[i].movemalus_plus.read ( stream, 0 );
885  fieldModification[i].movemalus_abs.read ( stream, -1 );
886  }
887 
888 
889  attackbonus_plus = stream.readInt();
890  attackbonus_abs = stream.readInt();
891 
892  defensebonus_plus = stream.readInt();
893  defensebonus_abs = stream.readInt();
894 
895  basicjamming_plus = stream.readInt();
896  basicjamming_abs = stream.readInt();
897 
898  if ( version >= 10 ) {
899  viewbonus_plus = stream.readInt();
900  viewbonus_abs = stream.readInt();
901  }
902 
903  if ( version <= 10 ) {
904  imageHeight = stream.readInt();
906  } else {
907  imageHeight = stream.readInt();
908  physicalHeight = stream.readInt();
909  }
910 
911 
912  buildcost.read( stream );
913  removecost.read ( stream );
914  build_movecost = stream.readInt();
915  remove_movecost = stream.readInt();
916 
918 
919  name = stream.readString();
920 
921  netBehaviour = stream.readInt();
922 
923  displayMethod = stream.readInt();
924 
925  if ( version < 15 ) {
926  Surface s;
927  s.read( stream );
928  s.read( stream );
929  }
930 
931  techDependency.read ( stream );
932 
933  if ( version >= 12 )
934  growthRate = stream.readFloat();
935  else
936  growthRate = 0;
937 
938  if ( version >= 13 )
939  lifetime = stream.readInt();
940  else
941  lifetime = -1;
942 
943 
944  for ( int ww = 0; ww < cwettertypennum; ww++ )
945  if ( weather.test ( ww ) ) {
946 
947  int pictnum = stream.readInt();
948  stream.readInt( ); // weatherPicture[ww].gfxReference =
949 
950  weatherPicture[ww].bi3pic.resize( pictnum );
951  weatherPicture[ww].flip.resize( pictnum );
952  weatherPicture[ww].images.resize( pictnum );
953 
954  for ( int n = 0; n < pictnum; n++ ) {
955  int bi3 = stream.readInt();
956  if ( bi3 == 1 ) {
957  weatherPicture[ww].bi3pic[n] = stream.readInt();
958  weatherPicture[ww].flip[n] = stream.readInt();
959  } else {
960  weatherPicture[ww].bi3pic[n] = -1;
961  weatherPicture[ww].images[n].read ( stream );
962  if ( object_version >= 13 )
963  weatherPicture[ww].flip[n] = stream.readInt();
964  else
965  weatherPicture[ww].flip[n] = 0;
966  }
967  }
968  if ( version >= 22 )
970  }
971 
972  if ( version >= 16 )
973  namingMethod = NamingMethod( stream.readInt() );
974 
975  if ( version >= 17 )
976  growthDuration = stream.readInt();
977 
978  if ( version >= 18 )
979  rotateImage = stream.readInt();
980 
981  if ( version >= 19 )
982  growOnUnits = stream.readInt();
983 
984  if ( version >= 20 )
985  readClassContainer( secondaryIDs, stream );
986 
987  } else
988  throw tinvalidversion ( stream.getLocation(), object_version, version );
989 }
990 
991 
992 void ObjectType :: write ( tnstream& stream ) const
993 {
994  stream.writeInt ( object_version );
995 
996  stream.writeInt ( id );
997  stream.writeInt ( groupID );
998 
999  int ___weather = 0;
1000  for ( int i = 0; i < cwettertypennum; i++ )
1001  if ( weather.test ( i ))
1002  ___weather |= 1 << i;
1003  stream.writeInt ( ___weather );
1004  stream.writeInt ( visibleago );
1005 
1008 
1009  stream.writeInt ( armor );
1010 
1011  for ( int i = 0; i < cwettertypennum; i++ ) {
1012  fieldModification[i].terrainaccess.write( stream );
1013  fieldModification[i].terrain_and.write ( stream );
1014  fieldModification[i].terrain_or.write ( stream );
1015  fieldModification[i].movemalus_plus.write ( stream );
1016  fieldModification[i].movemalus_abs.write ( stream );
1017  }
1018 
1019 
1020  stream.writeInt ( attackbonus_plus );
1021  stream.writeInt ( attackbonus_abs );
1022  stream.writeInt ( defensebonus_plus );
1023  stream.writeInt ( defensebonus_abs );
1024 
1025  stream.writeInt ( basicjamming_plus );
1026  stream.writeInt ( basicjamming_abs );
1027 
1028  stream.writeInt ( viewbonus_plus );
1029  stream.writeInt ( viewbonus_abs );
1030 
1031 
1032  stream.writeInt ( imageHeight );
1033  stream.writeInt ( physicalHeight );
1034 
1035  buildcost.write( stream );
1036  removecost.write ( stream );
1037  stream.writeInt( build_movecost );
1038  stream.writeInt( remove_movecost );
1039 
1041 
1042  stream.writeString ( name );
1043 
1044  stream.writeInt ( netBehaviour );
1045 
1046  stream.writeInt ( displayMethod );
1047 
1048  techDependency.write ( stream );
1049 
1050  stream.writeFloat( growthRate );
1051  stream.writeInt( lifetime );
1052 
1053 
1054  for ( int ww = 0; ww < cwettertypennum; ww++ )
1055  if ( weather.test( ww ) ) {
1056  stream.writeInt( weatherPicture[ww].images.size() );
1057  stream.writeInt( 0 ); // weatherPicture[ww].gfxReference
1058 
1059  for ( int l = 0; l < weatherPicture[ww].images.size(); l++ ) {
1060  if ( weatherPicture[ww].bi3pic[l] >= 0 ) {
1061  stream.writeInt ( 1 );
1062  stream.writeInt ( weatherPicture[ww].bi3pic[l] );
1063  } else {
1064  stream.writeInt ( 2 );
1065  weatherPicture[ww].images[l].write( stream );
1066  }
1067  stream.writeInt ( weatherPicture[ww].flip.at(l) );
1068  }
1069  stream.writeString( weatherPicture[ww].originalFilename );
1070  }
1071 
1072  stream.writeInt( namingMethod );
1073  stream.writeInt( growthDuration );
1074  stream.writeInt( rotateImage );
1075  stream.writeInt( growOnUnits );
1076 
1077  writeClassContainer( secondaryIDs, stream );
1078 
1079 }
1080 
1081 
1083 {
1084  pc.addDFloatArray ( "Movemalus_plus", movemalus_plus );
1085  size_t mm = movemalus_plus.size();
1086  movemalus_plus.resize( cmovemalitypenum );
1087  for ( size_t i = mm; i < cmovemalitypenum; i++ ) {
1088  if ( i == 0 )
1089  movemalus_plus[i] = 0;
1090  else
1092  }
1093 
1094 
1095  pc.addDFloatArray ( "Movemalus_abs", movemalus_abs );
1096  mm = movemalus_abs.size();
1097  movemalus_abs.resize( cmovemalitypenum );
1098  for ( size_t i = mm; i < cmovemalitypenum; i++ ) {
1099  if ( i == 0 )
1100  movemalus_abs[i] = -1;
1101  else
1102  movemalus_abs[i] = movemalus_abs[0];
1103  }
1104 
1105  pc.openBracket ( "TerrainAccess" );
1106  terrainaccess.runTextIO ( pc );
1107  pc.closeBracket ();
1108 
1109  pc.addTagArray ( "TerrainProperties_Filter", terrain_and, terrainPropertyNum, terrainProperties, true );
1110  pc.addTagArray ( "TerrainProperties_Add", terrain_or, terrainPropertyNum, terrainProperties );
1111 }
1112 
1114 {
1115  pc.addBreakpoint();
1116 
1117  pc.addInteger ( "ID", id );
1118 
1119  if ( pc.find( "SecondaryIDs") || !pc.isReading())
1120  pc.addIntegerArray("SecondaryIDs", secondaryIDs );
1121 
1122  pc.addInteger ( "GroupID", groupID, -1 );
1123  pc.addTagArray ( "Weather", weather, cwettertypennum, weatherTags );
1124  pc.addBool ( "visible_in_fogOfWar", visibleago );
1125  pc.addIntRangeArray ( "LinkableObjects", linkableObjects );
1126  if ( pc.find ( "LinkableTerrain" ) || !pc.isReading() )
1127  pc.addIntRangeArray ( "LinkableTerrain", linkableTerrain );
1128 
1129  pc.addBool ( "canExistBeneathBuildings", canExistBeneathBuildings, false );
1130 
1131  pc.addInteger ( "Armor", armor );
1132 
1133  bool oldWeatherSpecification;
1134 
1135  if ( pc.find ( "Movemalus_plus" )) {
1136  oldWeatherSpecification = true;
1137 
1138  fieldModification[0].runTextIO ( pc );
1139 
1140  for ( int i = 1; i < cwettertypennum; ++i )
1142 
1143  } else
1144  oldWeatherSpecification= false;
1145 
1146 
1147  pc.addInteger ( "AttackBonus_abs", attackbonus_abs );
1148  pc.addInteger ( "AttackBonus_plus", attackbonus_plus );
1149  pc.addInteger ( "DefenseBonus_abs", defensebonus_abs );
1150  pc.addInteger ( "DefenseBonus_plus", defensebonus_plus );
1151  pc.addInteger ( "Jamming_abs", basicjamming_abs );
1152 
1153  if ( pc.find( "Jammming_plus"))
1154  pc.addInteger ( "Jammming_plus", basicjamming_plus );
1155  else
1156  pc.addInteger ( "Jamming_plus", basicjamming_plus );
1157 
1158  pc.addInteger ( "Height", imageHeight );
1159  if ( pc.find ( "PhysicalHeight" ) || !pc.isReading() ) {
1160  pc.addInteger ( "PhysicalHeight", physicalHeight );
1161  } else
1162  physicalHeight = imageHeight / 30;
1163 
1164  pc.addInteger ( "ViewBonus_abs", viewbonus_abs, -1 );
1165  pc.addInteger ( "ViewBonus_plus", viewbonus_plus, 0 );
1166 
1167  pc.openBracket ( "ConstructionCost" );
1168  buildcost.runTextIO ( pc );
1169  pc.addInteger ( "Movement", build_movecost );
1170  pc.closeBracket ();
1171 
1172  pc.openBracket ( "RemovalCost" );
1173  removecost.runTextIO ( pc );
1174  pc.addInteger ( "Movement", remove_movecost );
1175  pc.closeBracket ();
1176 
1177  pc.addString( "Name", name );
1178  pc.addTagInteger ( "NamingMethod", namingMethod, namingMethodNum, namingMethodNames, int(0) );
1179 
1180  pc.addDFloat( "GrowthRate", growthRate, 0 );
1181  pc.addInteger( "MaxChildSpawnNumber", growthDuration, -1 );
1182  pc.addInteger( "LifeTime", lifetime, -1 );
1183  pc.addBool( "GrowOnUnits", growOnUnits, false );
1184 
1185 
1186  pc.addTagInteger ( "NetBehaviour", netBehaviour, netBehaviourNum, objectNetMethod, int(NetToSelf) );
1187 
1188  if ( pc.isReading() && pc.find ( "NoSelfChaining" )) {
1189  bool no_autonet;
1190  pc.addBool ( "NoSelfChaining", no_autonet );
1191  if ( !no_autonet )
1193  }
1194 
1195 
1196  for ( int i = 0; i < cwettertypennum; i++ )
1197  if ( weather.test(i) ) {
1198 
1199  pc.openBracket ( weatherTags[i] );
1200  bool bi3pics = false;
1201 
1202  if ( !pc.isReading() )
1203  for ( int j = 0; j < weatherPicture[i].bi3pic.size(); j++ )
1204  if ( weatherPicture[i].bi3pic[j] >= 0 )
1205  bi3pics = true;
1206 
1207  pc.addBool ( "UseGFXpics", bi3pics );
1208  if ( bi3pics ) {
1209  pc.addIntegerArray ( "GFXpictures", weatherPicture[i].bi3pic );
1210  pc.addIntegerArray ( "FlipPictures", weatherPicture[i].flip );
1211  // int oldsize = weatherPicture[i].flip.size();
1212  weatherPicture[i].flip.resize( weatherPicture[i].bi3pic.size() );
1213  weatherPicture[i].images.resize( weatherPicture[i].bi3pic.size() );
1214  } else {
1216  if ( s.empty() ) {
1217  s = "object";
1218  s += strrr(id);
1219  }
1220  ASCString filename = s + weatherAbbrev[i];
1221  pc.addImageArray ( "picture", weatherPicture[i].images, filename );
1222  if ( pc.isReading() )
1223  weatherPicture[i].originalFilename = filename;
1224  else
1225  pc.addString( "OriginalImageFilename", weatherPicture[i].originalFilename );
1226 
1227  weatherPicture[i].bi3pic.resize( weatherPicture[i].images.size() );
1228  weatherPicture[i].flip.resize( weatherPicture[i].images.size() );
1229 
1230  if ( pc.find ( "FlipPictures" ) || !pc.isReading() ) {
1231  vector<int> imgReferences;
1232  imgReferences.resize ( weatherPicture[i].images.size() );
1233 
1234  if ( pc.isReading() )
1235  for ( int j = 0; j < weatherPicture[i].images.size(); j++ ) {
1236  weatherPicture[i].bi3pic[j] = -1;
1237  weatherPicture[i].flip[j] = 0;
1238  imgReferences[j] = -1;
1239  }
1240 
1241  pc.addIntegerArray ( "FlipPictures", weatherPicture[i].flip );
1242  pc.addIntegerArray ( "ImageReference", imgReferences );
1243 
1244  if ( pc.isReading() ) {
1245  for ( int j = 0; j < weatherPicture[i].images.size(); j++ )
1246  if ( j < imgReferences.size() && imgReferences[j] >= 0 && imgReferences[j] < weatherPicture[i].images.size() )
1247  weatherPicture[i].images[j] = weatherPicture[i].images[imgReferences[j]];
1248 
1249  while ( weatherPicture[i].flip.size() < weatherPicture[i].images.size() )
1250  weatherPicture[i].flip.push_back(0);
1251  }
1252  } else {
1253  for ( int u = 0; u < weatherPicture[i].images.size(); u++ ) {
1254  weatherPicture[i].bi3pic[u] = -1;
1255  weatherPicture[i].flip[u] = 0;
1256  }
1257  }
1258 
1259  if ( pc.isReading() ) {
1260  int operations;
1261  std::set<void*> processedImages;
1262  pc.addNamedInteger("GraphicOperations", operations, graphicOperationNum, graphicOperations, 0 );
1263  if ( operations == 1 ) {
1264  for ( int j = 0; j < weatherPicture[i].images.size(); j++ )
1265  if ( processedImages.find( weatherPicture[i].images[j].getBaseSurface() ) == processedImages.end() ) {
1266  snowify( weatherPicture[i].images[j] );
1267  processedImages.insert( weatherPicture[i].images[j].getBaseSurface() ) ;
1268  }
1269  } else
1270  if ( operations == 2 ) {
1271  for ( int j = 0; j < weatherPicture[i].images.size(); j++ )
1272  if ( processedImages.find( weatherPicture[i].images[j].getBaseSurface() ) == processedImages.end() ) {
1273  snowify( weatherPicture[i].images[j], false );
1274  processedImages.insert( weatherPicture[i].images[j].getBaseSurface() ) ;
1275  }
1276 
1277  }
1278  }
1279 
1280  }
1281 
1282  if ( pc.find ( "DisplayMethod" ) || !pc.isReading() ) {
1284  if ( displayMethod == 2 && pc.isReading() && weatherPicture[i].images[0].GetPixelFormat().BitsPerPixel() != 8 )
1285  pc.error("Error parsing object " + name + " (ID=" + ASCString::toString(id)+"): invalid image; displaymethod=translation is only a available for 8 Bit images");
1286 
1287  } else
1288  displayMethod = 0;
1289 
1290 
1291  if ( !oldWeatherSpecification ) {
1292  fieldModification[i].runTextIO( pc );
1293  }
1294  pc.closeBracket ( );
1295  }
1296 
1297  techDependency.runTextIO( pc );
1298 
1299  if ( weatherPicture[0].images.size() == 1 && (netBehaviour&KeepOrientation) )
1300  rotateImage = true;
1301 
1302 
1303 
1304 }
const int object_version
Definition: objecttype.cpp:841
TerrainType::Weather * typ
the terraintype of the field
Definition: mapfield.h:38
int viewbonus_plus
units standing on this object will get a bonus to their view
Definition: objecttype.h:94
TerrainType::MoveMalus movemalus_abs
The movemalus_abs replaces the current movemalus of the field by a new one. Values of 0 and -1 won't ...
Definition: objecttype.h:65
int getMemoryFootprint() const
Definition: objecttype.cpp:828
void runTextIO(PropertyContainer &pc)
void read(tnstream &stream, int defaultValue, int moveMalusCount=-1)
int displayMethod
some objects require special displaying methods, for example shading the terrain they are build on ...
Definition: objecttype.h:175
ASCString filename
The name of the file from which the item was loaded.
Definition: typen.h:290
int xsize
the size of the map
Definition: gamemap.h:201
const char * graphicOperations[graphicOperationNum]
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
PixelSize2Type< BytesPerTargetPixel >::PixelType SourcePixelType
Definition: objecttype.cpp:196
const int objectDisplayingMethodNum
Definition: objecttype.h:205
Smoothing(GameMap *gamemap)
Definition: objecttype.cpp:404
void snowify(Surface &s, bool adaptive)
TerrainBits terrain_and
the terrain properties of the field will be AND-masked with this field and then OR-masked with terrai...
Definition: objecttype.h:71
virtual ASCString getLocation()
returns the location of the stream.
Definition: basestrm.cpp:274
const char * objectNetMethod[ObjectType::netBehaviourNum]
void write(tnstream &stream) const
bool visibleago
is the object displayed under fog of war
Definition: objecttype.h:47
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 lifetime
the object is removed when it is lifetime turns old. -1 disables removal
Definition: objecttype.h:187
void addIntegerArray(const ASCString &name, vector< int > &property, bool required=true)
int build_movecost
The movement points that are needed to build this object.
Definition: objecttype.h:113
Functions to evaluate the parsed *.asctxt files.
int netBehaviour
specifies how the object is going to connect to other things
Definition: objecttype.h:138
BitSet weather
bitmapped variable containing the different weather types the objects exist for
Definition: objecttype.h:44
void runTextIO(PropertyContainer &pc)
Definition: typen.cpp:254
void addTagInteger(const ASCString &name, int &property, int tagNum, const char **tags, bool inverted=false)
const int graphicOperationNum
Definition: textfiletags.h:36
const char * weatherAbbrev[cwettertypennum]
A system that provides a set of images for vehicles, buildings, etc.
void display(Surface &surface, const SPoint &pos) const
displays the objecttype at x/y on the screen
Definition: objecttype.cpp:289
const char * terrainProperties[terrainPropertyNum]
int getWeather(int weather) const
Definition: objecttype.cpp:96
void read(tnstream &stream)
Definition: typen.cpp:195
The interface for all kinds of IO stream.
a single field of the map
Definition: mapfield.h:26
int SearchAndGetInt(int Wert, int *Arr, int *Res)
Definition: objecttype.cpp:505
int SmoothIt(ObjectType *TerObj, int *SmoothData)
Definition: objecttype.cpp:521
PixelSize2Type< BytesPerTargetPixel >::PixelType TargetPixelType
Definition: objecttype.cpp:197
void write(tnstream &stream) const
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
const int terrainPropertyNum
the number of bits that specify the terrain of a field
Definition: terraintype.h:28
void read(tnstream &stream)
static const char * namingMethodNames[]
Definition: objecttype.h:128
void runTextIO(PropertyContainer &pc, const ASCString &defaultTechAdapter="")
Definition: research.cpp:454
const char * objectDisplayingMethodTags[objectDisplayingMethodNum]
TargetPixelType convert(SourcePixelType sp)
Definition: objecttype.cpp:205
bool growOnUnits
is the object growth stopped by units and buildings
Definition: objecttype.h:184
const OverviewMapImage * getOverviewMapImage(int picnum, int weather) const
Definition: objecttype.cpp:111
int attackbonus_abs
The attackbonus_abs replaces the current attackbonus of the field by a new one. A value of -1 won't a...
Definition: objecttype.h:81
ASCString extractFileName_withoutSuffix(const ASCString &filename)
Definition: basestrm.cpp:2585
bool canExistBeneathBuildings
if a building is constructed on the field containing the object, will the object be removed or will i...
Definition: objecttype.h:119
void calculateforest(GameMap *actmap, ObjectType *woodObj)
Definition: objecttype.cpp:755
int basicjamming_abs
basicjamming_abs replaces the current basicjamming of the field by a new one. A value < 0 won't affect...
Definition: objecttype.h:91
int getWeather()
the weather that is on this field
Definition: mapfield.cpp:370
virtual void writeString(const string &pc, bool binary=true)
writes the C++ String pc to the stream.
Definition: basestrm.cpp:545
const int sidenum
the number of sides that a field has; is now fixed at 6;
Definition: typen.h:438
virtual float readFloat(void)
Reads a flaot variable.
Definition: basestrm.cpp:328
void read(tnstream &stream)
Definition: surface.cpp:265
const Surface & getPicture(int i=0, int weather=0) const
returns the pointer to the image i
Definition: objecttype.cpp:132
int defensebonus_abs
The defensebonus_abs replaces the current defensebonus of the field by a new one. A value of -1 won't...
Definition: objecttype.h:86
void runTextIO(PropertyContainer &pc)
Definition: terraintype.cpp:96
double growthRate
the probability that an object of this type spawns another object on a neighbouring field ...
Definition: objecttype.h:181
int remove_movecost
The movement points that are needed to remove this object.
Definition: objecttype.h:116
vector< Surface > images
Definition: objecttype.h:149
int defensebonus_plus
this is added to the current defensebonus of the field to form the new defensebonus.
Definition: objecttype.h:84
Resources buildcost
The resources required to construct the object with a unit; Note that units usually don't have any en...
Definition: objecttype.h:107
static ASCString toString(int i)
converts the parameter to a String
Definition: ascstring.cpp:193
void error(const ASCString &errmsg)
TerrainAccess terrainaccess
The terrain on which this object can be placed.
Definition: objecttype.h:68
char * strrr(int a)
converts a to a string.
Definition: misc.cpp:66
const int woodformnum
Definition: objecttype.cpp:307
void write(tnstream &stream) const
Definition: typen.cpp:201
const ObjectType * typ
Definition: objects.h:48
const int directionangle[sidenum]
Definition: typen.cpp:81
An object that can be placed on fields. Roads, pipelines and ditches are examples of objects...
Definition: objecttype.h:30
int imageHeight
the level of height the object is on. This is not the simple system of 8 levels used for units and bu...
Definition: objecttype.h:101
const int cmovemalitypenum
The number of vehicle categories; Each category has its own move malus.
Definition: typen.h:384
Definition of THE central asc class: GameMap.
vector< int > secondaryIDs
when loading a file and these IDs are encountered, this object will be used.
Definition: objecttype.h:38
void setparams(ObjectRemovalStrategy *objectRemovalStrategy)
recalculates the terrain properties, movemalus etc from the terraintype and the objects,
Definition: mapfield.cpp:605
const FieldModification & getFieldModification(int weather) const
Definition: objecttype.cpp:72
void write(tnstream &stream) const
write the objecttype from a stream
Definition: objecttype.cpp:992
int getnextdx(int dir, int y)
Definition: mapalgorithms.h:77
static const int namingMethodNum
Definition: objecttype.h:129
int getEffectiveHeight() const
returns the level of height of this object in the normal 8 level scheme of asc (deep submerged...
Definition: objecttype.cpp:90
int dir
Definition: objects.h:51
struct ObjectType::FieldModification fieldModification[cwettertypennum]
void runTextIO(PropertyContainer &pc)
reads or writes the objecttype to the text stream pc
int namingMethod
Definition: objecttype.h:127
MapField * getfield(int x, int y)
Definition: objecttype.cpp:405
vector< IntRange > linkableTerrain
objects can be graphically linked to terrain, as if the terrain was an object of the same type...
Definition: objecttype.h:53
int growthDuration
the time after which any growth stops.
Definition: objecttype.h:191
int attackbonus_plus
this is added to the current attackbonus of the field to form the new attackbonus.
Definition: objecttype.h:79
int GetNeighbourMask(int x, int y, int *Arr)
Definition: objecttype.cpp:468
void addDFloatArray(const ASCString &name, vector< double > &property)
The IO for many basic classes and structurs of ACS.
int woodform[woodformnum]
Definition: objecttype.cpp:308
Represents a range of numbers, with a lower and upper boundary.
Definition: typen.h:334
void readClassContainer(C &c, tnstream &stream)
Definition: basestrm.h:752
int GetNeighbourMask(int x, int y, int *Arr, ObjectType *o)
Definition: objecttype.cpp:442
SDLmm::SPoint SPoint
Definition: surface.h:27
bool buildable(MapField *fld) const
can the object be build on the field fld
Definition: objecttype.cpp:77
int getnextdy(int dir)
Definition: mapalgorithms.h:80
int ysize
Definition: gamemap.h:201
TechAdapterDependency techDependency
Definition: objecttype.h:142
TerrainBits bdt
the terraintype properties. They determine which units can move over the field. This variable is reca...
Definition: mapfield.h:161
int bi_pict
the image index from the graphic set. -1 if graphics is not from graphic set.
Definition: terraintype.h:122
ObjectType(void)
Definition: objecttype.cpp:47
void read(tnstream &stream)
reads the objecttype from a stream
Definition: objecttype.cpp:843
TerrainType::MoveMalus movemalus_plus
the movemalus_plus is added to the current movemalus of the field to form the new movemalus...
Definition: objecttype.h:62
virtual ASCString readString(bool includeCR=false)
Reads and returns a string.
Definition: basestrm.cpp:535
void read(tnstream &stream)
Definition: terraintype.cpp:74
void addInteger(const ASCString &name, int &property)
int groupID
the group ID allows units to specify whole groups of objects to be buildable / removable without spec...
Definition: objecttype.h:41
void write(tnstream &stream) const
Definition: terraintype.cpp:86
virtual void closeBracket()
int viewbonus_abs
units standing on this object will get a bonus to their view
Definition: objecttype.h:96
void addNamedInteger(const ASCString &name, int &property, int tagNum, const char **tags)
static Surface & getIcon(const ASCString &name)
Building * building
Definition: mapfield.h:102
void addImageArray(const ASCString &name, vector< Surface > &property, ASCString &fileName)
virtual void writeFloat(float f)
Write a floating point variable.
Definition: basestrm.cpp:385
GameMap * actmap
Definition: spfst.cpp:64
struct ObjectType::WeatherPicture weatherPicture[cwettertypennum]
const char * weatherTags[cwettertypennum]
void writeClassContainer(const C &c, tnstream &stream)
Definition: basestrm.h:742
void smooth(int what, GameMap *gamemap, ObjectType *woodObj)
automatically adjusting the pictures of woods and coasts to form coherent structures ...
Definition: objecttype.cpp:748
virtual void openBracket(const ASCString &name)
int UnSmoothDarkBanksData[]
Definition: objecttype.cpp:391
vector< IntRange > linkableObjects
some objects are graphically linked with others on neighbouring fields.
Definition: objecttype.h:50
void read(tnstream &stream)
Definition: research.cpp:434
an instance of an object type (ObjectType) on the map
Definition: objects.h:46
the image for a TerrainType that is shown on the small map
void addString(const ASCString &name, ASCString &property)
int basicjamming_plus
this is added to the current basicjamming of the field to form the new jamming.
Definition: objecttype.h:89
void addIntRangeArray(const ASCString &name, vector< IntRange > &property, bool required=true)
void smooth(int what, ObjectType *woodObj)
Definition: objecttype.cpp:596
int IsInSetOfWord(int Wert, int *A)
Definition: objecttype.cpp:410
bool find(const ASCString &name)
vector< OverviewMapImage > overviewMapImage
Definition: objecttype.h:148
ColorConverter_PassThrough(const Surface &sourceSurface, Surface &targetSurface)
Definition: objecttype.cpp:202
Resources removecost
The resources required to remove the object with a unit; Note that units usually don't have any energ...
Definition: objecttype.h:110
Object * checkForObject(const ObjectType *o)
checks if there are objects from the given type on the field and returns them
Definition: mapfield.cpp:648
void fatalError(const ASCString &string)
void addTagArray(const ASCString &name, BitSet &property, int tagNum, const char **tags, bool inverted=false)
const int cwettertypennum
The number of different weather.
Definition: typen.h:61
int armor
if an object should not be attackable, set armor to 0
Definition: objecttype.h:56
int physicalHeight
the 'real' height of the object, which evaluated for construction and attack. The destinction between...
Definition: objecttype.h:104
void addDFloat(const ASCString &name, double &property)
static const int netBehaviourNum
Definition: objecttype.h:134
Functions to parse the *.asctxt files.
ObjectContainer objects
Definition: mapfield.h:124
The map. THE central structure of ASC, which holds everything not globally available together...
Definition: gamemap.h:182
void write(tnstream &stream) const
Definition: research.cpp:445
MapField * getField(int x, int y)
Definition: gamemap.h:465
ASCString name
The name of the object.
Definition: objecttype.h:122