Advanced Strategic Command
vehicletype.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  vehicletype.cpp - description
3  -------------------
4  begin : Fri Sep 29 2000
5  copyright : (C) 2000 by Martin Bickel
6  email : bickel@asc-hq.org
7  ***************************************************************************/
8 
14 /***************************************************************************
15  * *
16  * This program is free software; you can redistribute it and/or modify *
17  * it under the terms of the GNU General Public License as published by *
18  * the Free Software Foundation; either version 2 of the License, or *
19  * (at your option) any later version. *
20  * *
21  ***************************************************************************/
22 
23 #include <algorithm>
24 #include "global.h"
25 #include "vehicletype.h"
26 #include "sgstream.h"
27 #include "graphicset.h"
28 #include "terraintype.h"
29 #include "objecttype.h"
30 #include "textfileparser.h"
31 #include "textfiletags.h"
32 #include "textfile_evaluation.h"
33 #include "graphics/blitter.h"
36 #include "unitcostcalculator-pbp.h"
37 
38 /*
39 const char* cvehiclefunctions[cvehiclefunctionsnum+1] = {
40  "sonar",
41  "paratrooper",
42  "mine-layer",
43  "cruiser landing",
44  "repair vehicle",
45  "conquer buildings",
46  "move after attack",
47  "view satellites",
48  "construct ALL buildings",
49  "view mines",
50  "construct vehicles",
51  "construct specific buildings",
52  "refuel units",
53  "icebreaker",
54  "cannot be refuelled in air",
55  "refuels material",
56  "! (unused) !",
57  "makes tracks",
58  "drill for mineral resources manually",
59  "no reactionfire",
60  "auto repair",
61  "generator",
62  "search for mineral resources automatically",
63  "Kamikaze only",
64  "immune to mines",
65  "refuels energy",
66  "jams only own field",
67  "move with reaction fire on",
68  "only move to and from transports",
69  NULL };
70 */
71 const char* cwaffentypen[weaponTypeNum] = {"cruise missile", "mine", "bomb", "large missile", "small missile", "torpedo", "machine gun",
72  "cannon", "service", "ammunition refuel", "laser", "shootable", "object placement"
73  };
74 
75 const int ammoProductionCost[weaponTypeNum][3] = { { 1500,1500,1500 }, // cruise missile
76  {10, 10, 10}, // mine
77  {40, 40, 40}, // bomb
78  {200, 200, 200}, // big missile
79  {50, 50, 50}, // small missile
80  {20, 30, 40}, // torpedo
81  {1, 1, 1}, // machine gun
82  {5, 5, 1}, // cannon
83  {0, 0, 0}, // service
84  {0, 0, 0}, // ammo refuel
85  {0, 0, 0}, // laser
86  {0, 0, 0}, // shootable
87  {0, 0, 0}
88 }
89 ; // objectPlacement
90 
91 
92 const bool weaponAmmo[weaponTypeNum] = {
93  true, true, true, true, true, true, true, true, false, false, false, false, false
94 };
95 
97 {
99 
100  int i;
101 
102  armor = 0;
103 
104  height = 0;
106  wait = 0;
107  fuelConsumption = 0;
108 
109  movement.resize(8);
110  for ( i = 0; i < 8; i++ )
111  movement[i] = 0;
112  movemalustyp = 0;
113 
115  digrange = 0;
116  initiative = 0;
117 
118  weight = 0;
119  bipicture = -1;
120 
121  autorepairrate = 0;
122 
124 
125  for ( i = 0; i < 8; i++ )
126  aiparam[i] = NULL;
127 
129 
132 }
133 
134 
135 int VehicleType::maxsize ( void ) const
136 {
137  return weight;
138 }
139 
140 
141 const int vehicle_version = 34;
142 
143 
144 
145 void VehicleType::setupRemovableObjectsFromOldFileLayout ( )
146 {
147  for ( vector<IntRange>::iterator i = objectsBuildable.begin(); i != objectsBuildable.end(); )
148  if ( i->to < 0 && i->from < 0 ) {
149  int mi = min ( -i->from, -i->to );
150  int ma = max ( -i->from, -i->to );
151  objectsRemovable.push_back ( IntRange ( mi, ma ));
152  i = objectsBuildable.erase ( i );
153  } else {
154  objectsRemovable.push_back ( *i );
155  i++;
156  }
157 }
158 
160 {
161  int version = stream.readInt();
162  if ( version > vehicle_version || version < 1)
163  throw tinvalidversion ( stream.getLocation(), vehicle_version, version );
164 
165  int j;
166 
167  bool ___load_name = stream.readInt();
168  bool ___load_description = stream.readInt();
169  bool ___load_infotext = stream.readInt();
170 
171  if ( version <= 2 ) {
172  weapons.count = stream.readUint8();
173  for ( j = 0; j< 8; j++ ) {
174  weapons.weapon[j].set ( stream.readWord() );
175  weapons.weapon[j].targ = stream.readUint8();
176  weapons.weapon[j].sourceheight = stream.readUint8();
177  weapons.weapon[j].maxdistance = stream.readWord();
178  weapons.weapon[j].mindistance = stream.readWord();
179  weapons.weapon[j].count = stream.readUint8();
180  weapons.weapon[j].maxstrength = stream.readUint8();
181  weapons.weapon[j].minstrength = stream.readUint8();
182  for ( int k = 0; k < 13; k++ )
183  weapons.weapon[j].efficiency[k] = 100;
184  }
185  }
186 
187  if ( version <= 27 ) {
188  productionCost.energy = stream.readWord();
189  productionCost.material = stream.readWord();
190  } else
191  productionCost.read( stream );
192 
193  armor = stream.readWord();
194 
195  bool picture[8];
196  for ( j = 0; j < 8; j++ )
197  if ( version <= 18 )
198  picture[j] = stream.readInt();
199  else
200  picture[j] = false;
201 
202  height = stream.readUint8();
203  stream.readWord(); // was: researchID
204  int _terrain = 0;
205  int _terrainreq = 0;
206  int _terrainkill = 0;
207  if ( version <= 2 ) {
208  _terrain = stream.readInt();
209  _terrainreq = stream.readInt();
210  _terrainkill = stream.readInt();
211  }
212  stream.readUint8(); // steigung
213  jamming = stream.readUint8();
214  view = stream.readWord();
215  wait = stream.readUint8();
216 
217  if ( version <= 2 )
218  stream.readUint8 (); // dummy
219 
220  stream.readWord(); // dummy
221  stream.readWord(); // dummy
222  stream.readUint8(); // dummy
223  stream.readUint8(); // dummy
224  stream.readUint8(); // dummy
225  if ( version <= 18 )
226  id = stream.readWord();
227  else
228  id = stream.readInt();
229 
230  if ( version < 24 ) {
232  fuelConsumption = stream.readWord();
235  } else
236  fuelConsumption = stream.readInt();
237 
238  if ( version <= 22 ) {
239  int functions = stream.readInt();
240  features = convertOldFunctions ( functions, stream.getLocation() );
241  }
242 
243  for ( j = 0; j < 8; j++ )
244  if ( version <= 4 )
245  movement[j] = stream.readUint8();
246  else
247  movement[j] = stream.readInt();
248 
249 
250  movemalustyp = stream.readUint8();
253 
254  if ( version <= 2 )
255  for ( j = 0; j < 9; j++ )
256  stream.readWord( ); // dummy1
257 
258  bool ___load_classnames[8];
259  if ( version <= 15 ) {
260  stream.readUint8(); // classnum
261 
262  for ( j = 0; j < 8; j++ )
263  ___load_classnames[j] = stream.readInt();
264 
265  for ( j = 0; j < 8; j++ ) {
266  int k;
267  for ( k = 0; k < 8; k++ )
268  stream.readWord();
269 
270  if ( version <= 2 )
271  stream.readWord ( ); // dummy2
272 
273  stream.readWord();
274  stream.readWord();
275  for ( k = 0; k < 4; k++ )
276  stream.readWord();
277 
278  stream.readUint8();
279  stream.readInt();
280  if ( version <= 2 )
281  stream.readUint8( ); // dummy
282  }
283  }
284 
285  maxwindspeedonwater = stream.readUint8();
286  digrange = stream.readUint8();
287  initiative = stream.readInt();
288  int _terrainnot = 0;
289  if ( version <= 4 ) {
290  _terrainnot = stream.readInt();
291  stream.readInt(); // _terrainreq1
292  }
293  int objectsbuildablenum = stream.readInt();
294  if ( version <= 4 )
295  stream.readInt(); // objectsbuildableid = (int*)
296 
297  weight = stream.readInt();
298 
299  bool ___loadterrainaccess = false;
300  if ( version <= 4 )
301  ___loadterrainaccess = stream.readInt();
302 
303  bipicture = stream.readInt();
304  int vehiclesbuildablenum = stream.readInt();
305  if ( version <= 4 )
306  stream.readInt(); // vehiclesbuildableid = (int*)
307 
308  if ( version <= 4 )
309  stream.readInt(); // buildicon
310 
311  int buildingsbuildablenum = stream.readInt();
312  if ( version <= 4 )
313  stream.readInt(); // buildingsbuildable = (Vehicletype::tbuildrange*)
314 
315  bool load_weapons = stream.readInt();
316  autorepairrate = stream.readInt();
317  if ( version >= 15 )
319  else
320  if ( version >= 8 ) {
321  wreckageObject.clear();
322  wreckageObject.push_back ( stream.readInt() );
323  }
324 
325 
326  if ( version <= 2 )
327  stream.readInt( ); // dummy
328 
329  if ( version >= 4 )
330  stream.readInt(); // dummy
331 
332  if (___load_name)
333  name = stream.readString( true );
334 
335  if (___load_description)
336  description = stream.readString( true );
337 
338  if (___load_infotext)
339  infotext = stream.readString ( true );
340 
341  int i;
342  if ( version <= 15 )
343  for ( i=0;i<8 ;i++ )
344  if ( ___load_classnames[i] )
345  stream.readString ( true );
346 
347  if ( hasFunction( AutoRepair ) )
348  if ( !autorepairrate )
349  autorepairrate = 10;
350 
351  if ( version <= 18 ) {
352  if ( picture[0] )
353  image.read ( stream );
354 
355  for ( int i=1;i<8 ;i++ ) {
356  if ( picture[i] ) {
357  Surface s;
358  s.read ( stream );
359  bipicture = 0;
360  }
361  }
362  } else {
363  image.read ( stream );
364  }
365 
366 
367  if ( objectsbuildablenum )
368  for ( i = 0; i < objectsbuildablenum; i++ ) {
369  int from = stream.readInt ( );
370  int to;
371  if ( version <= 4 )
372  to = from;
373  else
374  to = stream.readInt();
375 
376  objectsBuildable.push_back ( IntRange ( from, to ));
377  }
378 
379  if ( version >= 6 ) {
380  int num = stream.readInt();
381  for ( int i = 0; i < num; i++ ) {
382  int from = stream.readInt();
383  int to = stream.readInt();
384 
385  objectsRemovable.push_back ( IntRange ( from, to ));
386  }
387  } else
388  setupRemovableObjectsFromOldFileLayout();
389 
390  if ( version >= 8 ) {
391  int num = stream.readInt();
392  for ( int i = 0; i < num; i++ ) {
393  int from = stream.readInt();
394  int to = stream.readInt();
395 
396  objectGroupsBuildable.push_back ( IntRange ( from, to ));
397  }
398 
399  num = stream.readInt();
400  for ( int i = 0; i < num; i++ ) {
401  int from = stream.readInt();
402  int to = stream.readInt();
403 
404  objectGroupsRemovable.push_back ( IntRange ( from, to ));
405  }
406  }
407 
408  if ( vehiclesbuildablenum )
409  for ( i = 0; i < vehiclesbuildablenum; i++ ) {
410  int from = stream.readInt ( );
411  int to;
412  if ( version <= 4 )
413  to = from;
414  else
415  to = stream.readInt();
416 
417  vehiclesBuildable.push_back ( IntRange ( from, to ));
418  }
419 
420  if ( load_weapons && version > 1) {
421  weapons.count = stream.readInt();
422  for ( j = 0; j< 16; j++ ) {
423  weapons.weapon[j].set ( stream.readInt() );
424  weapons.weapon[j].targ = stream.readInt();
425  weapons.weapon[j].sourceheight = stream.readInt();
426  weapons.weapon[j].maxdistance = stream.readInt();
427  weapons.weapon[j].mindistance = stream.readInt();
428  weapons.weapon[j].count = stream.readInt();
429  weapons.weapon[j].maxstrength = stream.readInt();
430  weapons.weapon[j].minstrength = stream.readInt();
431 
432  if ( version >= 17 )
433  weapons.weapon[j].reactionFireShots = stream.readInt();
434 
435  if ( version >= 22 )
436  weapons.weapon[j].name = stream.readString();
437 
438  /*
439  if ( weapons.weapon[j].getScalarWeaponType() == cwminen )
440  if ( weapons.weapon[j].mindistance < 8 )
441  warningMessage ( ASCString("unit with id ") + strrr ( id ) + " has invalid mine weapon range ");
442  */
443 
444  for ( int k = 0; k < 13; k++ )
445  weapons.weapon[j].efficiency[k] = stream.readInt();
446 
447  if ( version <= 6 ) {
448  int targets_not_hittable = stream.readInt();
449  for ( int i = 0; i < cmovemalitypenum; i++ )
450  if ( targets_not_hittable & ( 1 << i))
451  weapons.weapon[j].targetingAccuracy[i] = 0;
452  } else {
453  int num = stream.readInt();
454  for ( int i = 0; i < num; i++ )
455  weapons.weapon[j].targetingAccuracy[i] = stream.readInt();
456  }
457 
458 
459  if ( version <= 2 )
460  for ( int l = 0; l < 9; l++ )
461  stream.readInt(); // dummy
462 
463  if ( version >= 11 ) {
464  weapons.weapon[j].laserRechargeRate = stream.readInt();
465  weapons.weapon[j].laserRechargeCost.read( stream );
466  }
467  if ( version >= 20 )
468  weapons.weapon[j].soundLabel = stream.readString();
469 
470  }
471 
472  if ( version <= 2 )
473  for ( int m = 0; m< 10; m++ )
474  stream.readInt(); // dummy
475 
476  }
477 
478  if ( ___loadterrainaccess || version >= 5 )
479  terrainaccess.read ( stream );
480  else {
481  terrainaccess.terrain.setInt ( _terrain, 0 );
482  terrainaccess.terrainreq.setInt ( _terrainreq, 0 );
483  terrainaccess.terrainnot.setInt ( _terrainnot, 0 );
484  terrainaccess.terrainkill.setInt ( _terrainkill, 0 );
485  }
486 
487  if ( buildingsbuildablenum )
488  for ( i = 0; i < buildingsbuildablenum; i++ ) {
489  int from = stream.readInt();
490  int to = stream.readInt();
491  buildingsBuildable.push_back ( IntRange ( from, to ));
492  }
493 
494 
495  filename = stream.getDeviceName();
496  location = stream.getLocation();
497 
498  if ( version >= 9 )
499  ContainerBaseType::read ( stream );
500 
501  if ( version >= 10 ) {
502  heightChangeMethodNum = stream.readInt();
504  for ( int i = 0; i < heightChangeMethodNum; i++ )
505  heightChangeMethod[i].read( stream );
506  } else
508 
509  if ( version >= 12 )
510  techDependency.read( stream );
511 
512  if ( version >= 13 && version <= 24 ) {
513  Surface s;
514  s.read( stream );
515  }
516 
517  if ( version >= 14 && version < 18)
518  cargoMovementDivisor = stream.readInt();
519  else
520  if ( version >= 18 )
521  cargoMovementDivisor = stream.readFloat();
522 
523  if ( version >= 20 ) {
524  movementSoundLabel = stream.readString();
525  killSoundLabel = stream.readString();
526  }
527 
528  if ( version >= 22 )
530 
531  if ( version >= 24 ) {
532  efficiencyfuel = stream.readInt( );
533  efficiencymaterial = stream.readInt( );
534  asc_mode_tank.read( stream );
535  bi_mode_tank.read( stream );
536 
537 
538  maxresearchpoints = stream.readInt();
540  nominalresearchpoints = stream.readInt();
541  maxplus.read( stream );
542  defaultProduction.read( stream );
543  }
544 
545  for ( int w = 0; w < weapons.count; ++w )
546  if ( weapons.weapon[w].canRefuel() )
548 
549  if ( version >= 26 ) {
550  jumpDrive.height = stream.readInt();
551  jumpDrive.targetterrain.read( stream );
552  jumpDrive.consumption.read( stream );
553  jumpDrive.maxDistance = stream.readInt();
554  }
555 
556  if ( version >= 27 ) {
557  int num = stream.readInt();
558  for ( int i = 0; i < num; i++ ) {
559  int from = stream.readInt();
560  int to = stream.readInt();
561  objectLayedByMovement.push_back ( IntRange ( from, to ));
562  }
563  }
564 
565  if ( version >= 29 )
567 
568  if ( version >= 30 ) {
571  }
572 
573  if ( version >= 31 )
574  imageFilename = stream.readString();
575 
576  if ( version >= 32 )
578 
579  if ( version >= 33 )
580  costCalculator = stream.readString();
581 
582  if ( version >= 34 ) {
583  jumpDrive.attackAfterJump = stream.readInt();
584  jumpDrive.jumpAfterAttack = stream.readInt();
586  }
587 
588 }
589 
590 
591 
592 
593 void VehicleType:: write ( tnstream& stream ) const
594 {
595  int i,j;
596 
597  stream.writeInt ( vehicle_version );
598 
599  if ( !name.empty() )
600  stream.writeInt( 1 );
601  else
602  stream.writeInt( 0 );
603 
604  if ( !description.empty() )
605  stream.writeInt( 1 );
606  else
607  stream.writeInt( 0 );
608 
609  if ( !infotext.empty() )
610  stream.writeInt( 1 );
611  else
612  stream.writeInt( 0 );
613 
614  productionCost.write( stream );
615  stream.writeWord( armor );
616  stream.writeUint8( height );
617  stream.writeWord(0); // researchid
618  stream.writeUint8(0); // steigung
619  stream.writeUint8(jamming);
620  stream.writeWord(view);
621  stream.writeUint8(wait);
622  stream.writeWord(0);
623  stream.writeWord(0);
624  stream.writeUint8(0);
625  stream.writeUint8(0);
626  stream.writeUint8(0);
627  stream.writeInt(id );
628  stream.writeInt(fuelConsumption );
629  for ( j = 0; j < 8; j++ )
630  stream.writeInt( movement[j] );
631 
632 
633  stream.writeUint8(movemalustyp );
634 
636  stream.writeUint8(digrange );
637  stream.writeInt(initiative );
638  stream.writeInt( objectsBuildable.size() );
639 
640  stream.writeInt(weight );
641 
642  stream.writeInt(bipicture );
643  stream.writeInt(vehiclesBuildable.size() );
644  stream.writeInt( buildingsBuildable.size() );
645  stream.writeInt( 1 ); // weapons
646 
647  stream.writeInt( autorepairrate );
649 
650  stream.writeInt( 0 );
651 
652  if ( !name.empty() )
653  stream.writeString( name );
654 
655  if ( !description.empty() )
656  stream.writeString( description );
657 
658  if ( !infotext.empty() )
659  stream.writeString( infotext );
660 
661  image.write( stream );
662 
663  for ( i = 0; i < objectsBuildable.size(); i++ ) {
664  stream.writeInt ( objectsBuildable[i].from );
665  stream.writeInt ( objectsBuildable[i].to );
666  }
667 
668  stream.writeInt ( objectsRemovable.size() );
669  for ( i = 0; i < objectsRemovable.size(); i++ ) {
670  stream.writeInt ( objectsRemovable[i].from );
671  stream.writeInt ( objectsRemovable[i].to );
672  }
673 
674  stream.writeInt ( objectGroupsBuildable.size() );
675  for ( i = 0; i < objectGroupsBuildable.size(); i++ ) {
676  stream.writeInt ( objectGroupsBuildable[i].from );
677  stream.writeInt ( objectGroupsBuildable[i].to );
678  }
679 
680  stream.writeInt ( objectGroupsRemovable.size() );
681  for ( i = 0; i < objectGroupsRemovable.size(); i++ ) {
682  stream.writeInt ( objectGroupsRemovable[i].from );
683  stream.writeInt ( objectGroupsRemovable[i].to );
684  }
685 
686 
687  for ( i = 0; i < vehiclesBuildable.size(); i++ ) {
688  stream.writeInt ( vehiclesBuildable[i].from );
689  stream.writeInt ( vehiclesBuildable[i].to );
690  }
691 
692  stream.writeInt(weapons.count );
693  for ( j = 0; j< 16; j++ ) {
694  stream.writeInt(weapons.weapon[j].gettype( ));
695  stream.writeInt(weapons.weapon[j].targ);
696  stream.writeInt(weapons.weapon[j].sourceheight );
697  stream.writeInt(weapons.weapon[j].maxdistance );
698  stream.writeInt(weapons.weapon[j].mindistance );
699  stream.writeInt(weapons.weapon[j].count );
700  stream.writeInt(weapons.weapon[j].maxstrength );
701  stream.writeInt(weapons.weapon[j].minstrength );
703  stream.writeString( weapons.weapon[j].name );
704 
705  for ( int k = 0; k < 13; k++ )
706  stream.writeInt(weapons.weapon[j].efficiency[k] );
707 
708  stream.writeInt ( cmovemalitypenum );
709  for ( int i = 0; i < cmovemalitypenum; i++ )
710  stream.writeInt(weapons.weapon[j].targetingAccuracy[i] );
711 
713  weapons.weapon[j].laserRechargeCost.write( stream );
714  stream.writeString( weapons.weapon[j].soundLabel );
715  }
716 
717  terrainaccess.write ( stream );
718 
719  for ( i = 0; i < buildingsBuildable.size(); i++ ) {
720  stream.writeInt( buildingsBuildable[i].from );
721  stream.writeInt( buildingsBuildable[i].to );
722  }
723 
724  ContainerBaseType::write ( stream );
725 
726 
728  for ( i = 0; i < heightChangeMethodNum; i++ )
729  heightChangeMethod[i].write( stream );
730 
731  techDependency.write( stream );
732 
733  stream.writeFloat ( cargoMovementDivisor );
734 
736  stream.writeString( killSoundLabel );
738 
739  stream.writeInt( efficiencyfuel );
740  stream.writeInt( efficiencymaterial );
741 
742  asc_mode_tank.write( stream );
743  bi_mode_tank.write( stream );
744 
745  stream.writeInt( maxresearchpoints );
748  maxplus.write ( stream );
749  defaultProduction.write( stream );
750 
751  stream.writeInt( jumpDrive.height );
752  jumpDrive.targetterrain.write( stream );
753  jumpDrive.consumption.write( stream );
754  stream.writeInt( jumpDrive.maxDistance );
755 
756  stream.writeInt ( objectLayedByMovement.size() );
757  for ( i = 0; i < objectLayedByMovement.size(); i++ ) {
758  stream.writeInt ( objectLayedByMovement[i].from );
759  stream.writeInt ( objectLayedByMovement[i].to );
760  }
761 
765  stream.writeString( imageFilename );
766  stream.writeInt( recommendedAIJob );
767 
768  stream.writeString( costCalculator );
769 
773 
774 }
775 
776 
778 {
779  if ( !name.empty() )
780  return name;
781  else
782  return description;
783 }
784 
786 {
787  int maxUnitMovement = 0;
788  for ( int i = 0; i < 8; i++ )
789  maxUnitMovement = max ( maxUnitMovement, movement[i] );
790  return maxUnitMovement;
791 }
792 
794 {
795  return sizeof(*this) + image.getMemoryFootprint();
796 }
797 
798 
800 {
801  for ( int i = 0; i < 8; i++ )
802  if ( aiparam[i] ) {
803  delete aiparam[i];
804  aiparam[i] = NULL;
805  }
806 }
807 
808 
809 
811 {
812  typ = 0;
813  targ = 0;
814  sourceheight = 0;
815  maxdistance = 0;
816  mindistance = 0;
817  count = 0;
818  maxstrength= 0;
819  minstrength = 0;
820  laserRechargeRate = 0;
821  for ( int i = 0; i < 13; i++ )
822  efficiency[i] = 0;
823  for ( int i = 0; i < cmovemalitypenum; i++ )
824  targetingAccuracy[i] = 100;
825 
826  reactionFireShots = 1;
827 }
828 
829 
830 /* Translate the weapon/mine/service bit pattern into scalar
831  * weapon number for use in fetching UI resources.
832  */
834 {
835  if ( typ & (cwweapon | cwmineb) )
836  return getFirstBit ( typ & (cwweapon | cwmineb) );
837  else
838  return -1;
839 }
840 
841 
843 {
844  if ( typ & cwlaserb )
845  return false;
846  else
847  return typ & ( cwweapon | cwmineb );
848 }
849 
850 bool SingleWeapon::shootable( void ) const
851 {
852  return typ & cwshootableb;
853 }
854 
855 bool SingleWeapon::offensive( void ) const
856 {
857  return typ & cwweapon;
858 }
859 
860 bool SingleWeapon::service( void ) const
861 {
862  return typ & cwserviceb;
863 }
864 
866 {
867  return typ & cwobjectplacementb;
868 }
869 
870 
871 bool SingleWeapon::canRefuel( void ) const
872 {
873  return typ & cwammunitionb;
874 }
875 
877 ( int type )
878 {
879  typ = type;
880 }
881 
883 {
884  if ( !name.empty() )
885  return name;
886 
887  ASCString s;
888 
889  int k = getScalarWeaponType();
890  if ( k < weaponTypeNum && k >= 0 )
891  s = cwaffentypen[k];
892  else
893  if ( service() || placeObjects() )
895  else
896  s = "undefined";
897 
898  return s;
899 }
900 
902 {
903  switch ( numerical ) {
904  case cwcruisemissilen:
905  return "weap-cruisemissile";
906  case cwbombn:
907  return "weap-bomb";
908  case cwlargemissilen:
909  return "weap-bigmissile";
910  case cwsmallmissilen:
911  return "weap-smallmissile";
912  case cwtorpedon:
913  return "weap-torpedo";
914  case cwmachinegunn:
915  return "weap-machinegun";
916  case cwcannonn:
917  return "weap-cannon";
918  case cwminen:
919  return "weap-mine";
920  case cwservicen:
921  return "weap-service";
922  case cwlasern:
923  return "weap-laser";
924  default:
925  return "weap-undefined";
926  };
927 }
928 
929 
930 bool SingleWeapon::equals( const SingleWeapon* otherWeapon ) const
931 {
932  if (
933  otherWeapon->targ == this->targ &&
934  otherWeapon->sourceheight == this->sourceheight &&
935  otherWeapon->maxdistance == this->maxdistance &&
936  otherWeapon->mindistance == this->mindistance &&
937  otherWeapon->count == this->count &&
938  otherWeapon->maxstrength == this->maxstrength &&
939  otherWeapon->minstrength == this->minstrength &&
940  otherWeapon->gettype() == this->gettype()
941  ) {
942  bool equal = true;
943  for ( int i=0; i<13; i++ ) {
944  if ( otherWeapon->efficiency[ i ] != this->efficiency[ i ] ) {
945  equal = false;
946  }
947  }
948  if ( equal ) return true;
949  }
950 
951  return false;
952 }
953 
954 
956 {
957  count = 0;
958 }
959 
960 
961 
962 
964 {
966 
967  pc.addInteger( "Armor", armor );
968 
969  ASCString fn;
970  if ( filename.empty() ) {
971  fn += "vehicle";
972  fn += strrr(id);
973  } else
975 
976  pc.addImage( "Picture", image, fn, true );
977  if ( pc.isReading() )
978  imageFilename = fn;
979  else
980  pc.addString("OriginalImageFilename", imageFilename );
981 
982  if ( image.w() < fieldsizex || image.h() < fieldsizey )
983  image.strech( fieldsizex, fieldsizey );
984 
985  image.assignDefaultPalette();
986 
988  pc.addBool ( "WaitForAttack", wait );
989 
990  if ( bi_mode_tank == Resources(0,0,0) && asc_mode_tank == Resources(0,0,0)) {
991  pc.openBracket( "Tank" );
992  Resources tank;
993  tank.runTextIO ( pc );
994  pc.closeBracket();
995  bi_mode_tank = tank;
996  asc_mode_tank = tank;
997  }
998 
999  pc.addInteger( "FuelConsumption", fuelConsumption );
1000  if ( !pc.find("Features") && pc.isReading() ) {
1001  int abilities;
1002  pc.addTagInteger ( "Abilities", abilities, legacyVehicleFunctionNum, vehicleAbilities );
1003 
1004  features = convertOldFunctions ( abilities, pc.getFileName() );
1005 
1006  } else
1008 
1009 
1010  pc.addIntegerArray ( "Movement", movement );
1011  while ( movement.size() < 8 )
1012  movement.push_back(0);
1013  for ( vector<int>::iterator i = movement.begin(); i != movement.end(); i++ )
1014  if ( *i > 350 )
1015  *i = 350;
1016 
1018  pc.addInteger("MaxSurvivableStorm", maxwindspeedonwater, 255 );
1019  pc.addInteger("ResourceDrillingRange", digrange, 0 );
1020  pc.addInteger("SelfRepairRate", autorepairrate, 0 );
1021  if ( pc.find ( "WreckageObject" ) || !pc.isReading() )
1022  pc.addIntegerArray("WreckageObject", wreckageObject );
1023 
1024 
1025  if ( pc.find( "CargoMovementDivisor" ))
1026  pc.addDFloat("CargoMovementDivisor", cargoMovementDivisor);
1027  else {
1028  pc.openBracket( "Transportation" );
1029  pc.addDFloat("CargoMovementDivisor", cargoMovementDivisor, 2 );
1030  pc.closeBracket();
1031  }
1032 
1033 
1034  pc.addInteger("Weight", weight);
1035  pc.openBracket("TerrainAccess" );
1036  terrainaccess.runTextIO ( pc );
1037  pc.closeBracket();
1038 
1039  pc.openBracket ( "Construction" );
1040  pc.addIntRangeArray ( "Buildings", buildingsBuildable );
1041  pc.addIntRangeArray ( "Vehicles", vehiclesBuildable );
1042  pc.addIntRangeArray ( "Objects", objectsBuildable );
1043  if ( pc.isReading() ) {
1044  if ( pc.find ( "ObjectsRemovable" ))
1045  pc.addIntRangeArray ( "ObjectsRemovable", objectsRemovable );
1046  else
1047  setupRemovableObjectsFromOldFileLayout();
1048  } else
1049  pc.addIntRangeArray ( "ObjectsRemovable", objectsRemovable );
1050 
1051  pc.addIntRangeArray ( "ObjectGroupsBuildable", objectGroupsBuildable, false );
1052  pc.addIntRangeArray ( "ObjectGroupsRemovable", objectGroupsRemovable, false );
1053  pc.addInteger("UnitConstructionMoveCostPercentage", unitConstructionMoveCostPercentage, 50);
1054  pc.addInteger("UnitConstructionMinDistance", unitConstructionMinDistance, 1 );
1055  pc.addInteger("UnitConstructionMaxDistance", unitConstructionMaxDistance, 1 );
1056  pc.closeBracket();
1057 
1058  pc.openBracket ( "Weapons");
1059  // pc.addInteger("Initiative", initiative );
1060  pc.addInteger("Number", weapons.count );
1061  for ( int i = 0; i < weapons.count; i++ ) {
1062  pc.openBracket ( ASCString("Weapon")+strrr(i) );
1063  weapons.weapon[i].runTextIO( pc );
1064  pc.closeBracket();
1065  if ( hasFunction( NoReactionfire ) )
1067 
1068  }
1069 
1070  pc.closeBracket();
1071 
1072  int job = recommendedAIJob;
1075 
1076  pc.addString("MovementSound", movementSoundLabel, "" );
1077  pc.addString("KillSound", killSoundLabel, "" );
1078 
1079  pc.addInteger("HeightChangeMethodNum", heightChangeMethodNum, 0 );
1081  for ( int i = 0; i < heightChangeMethodNum; i++ ) {
1082  pc.openBracket( ASCString("HeightChangeMethod")+strrr(i) );
1083  heightChangeMethod[i].runTextIO ( pc );
1084  pc.closeBracket();
1085  }
1086 
1087  techDependency.runTextIO( pc, strrr(id) );
1088 
1089 
1090 
1091  pc.openBracket ( "ConstructionCost" );
1092  pc.addString( "CalculationFunction", unitCostCalculatorName, "standard" );
1093  productionCost.runTextIO ( pc );
1094  int costCalcMethod = 0;
1095  pc.addNamedInteger( "CalculationMethod", costCalcMethod, productionCostCalculationMethodNum, productionCostCalculationMethod, 0 );
1096  if ( pc.isReading() ) {
1097  if ( !pc.find ( "material" ) && costCalcMethod == 0)
1098  costCalcMethod = 1;
1099  }
1100 
1101  pc.addString( "Calculator", costCalculator, "standard" );
1102 
1103  pc.closeBracket ();
1104 
1105  if ( pc.find( "guideSortHelp") || !pc.isReading() )
1106  pc.addIntegerArray("guideSortHelp", guideSortHelp );
1107 
1108  bool hasService = false;
1109  for ( int w = 0; w < weapons.count; ++w ) {
1110  if ( weapons.weapon[w].canRefuel() )
1112  if ( weapons.weapon[w].service() )
1113  hasService = true;
1114  }
1115 
1116  if ( !hasService ) {
1117  features.reset( ExternalRepair );
1120  features.reset( ExternalFuelTransfer );
1121  features.reset( ExternalAmmoTransfer );
1122  }
1123 
1124 
1125 
1126  pc.openBracket ( "JumpDrive" );
1128  pc.openBracket ( "consumption" );
1129  jumpDrive.consumption.runTextIO ( pc, Resources(0,0,0) );
1130  pc.closeBracket();
1131  if ( jumpDrive.height || !pc.isReading() )
1133  pc.addInteger( "MaxDistance", jumpDrive.maxDistance, maxint );
1134  pc.addBool( "AttackAfterJump", jumpDrive.attackAfterJump, false );
1135  pc.addBool( "JumpAfterAttack", jumpDrive.jumpAfterAttack, false );
1136  pc.addInteger( "MovementConsumptionPercentage", jumpDrive.movementConsumptionPercentage, 100 );
1137  pc.closeBracket();
1138 
1139  if ( jumpDrive.height && view )
1140  pc.error( "only units without radar may have a jump drive." );
1141 
1142  if ( !pc.isReading() || pc.find ( "ObjectsLayedByMovement" ))
1143  pc.addIntRangeArray ( "ObjectsLayedByMovement", objectLayedByMovement );
1144  else
1145  objectLayedByMovement.clear();
1146 
1148  objectLayedByMovement.push_back ( 6 );
1149 
1151  objectLayedByMovement.push_back ( 7 );
1152 
1153 
1154  if ( costCalcMethod == 1 )
1156 
1157  if ( costCalcMethod == 2 )
1159 
1160  if ( costCalcMethod != 0 ) {
1161  displayLogMessage ( 4, "unit %s id %d has a production cost of %d E; %d M; %d F \n", name.c_str(), id, productionCost.energy, productionCost.material, productionCost.fuel );
1162  }
1163 }
1164 
1165 BitSet VehicleType::convertOldFunctions( int abilities, const ASCString& location )
1166 {
1167  BitSet features;
1168  if ( abilities & 1 )
1169  features.set( Sonar );
1170  if ( abilities & 2 )
1171  features.set( Paratrooper );
1172  if ( abilities & 4 )
1173  features.set( PlaceMines );
1174  if ( abilities & 8 )
1175  features.set( CruiserLanding );
1176  if ( abilities & 16 ) {
1177  features.set( ExternalRepair );
1178  features.set( InternalUnitRepair );
1179  }
1180  if ( abilities & 32 )
1181  features.set( ConquerBuildings );
1182  if ( abilities & 64 )
1183  features.set( MoveAfterAttack );
1184  if ( abilities & 128 )
1185  features.set( SatelliteView );
1186  if ( abilities & 256 )
1187  errorMessage( location + ": The features construct_ALL_buildings is not supported any more");
1188  if ( abilities & 512 )
1189  features.set( MineView );
1190  if ( abilities & 1024 )
1191  features.set( ExternalVehicleProduction );
1192  if ( abilities & 2048 )
1193  features.set( ConstructBuildings );
1194  if ( abilities & 4096 )
1195  features.set( ExternalFuelTransfer );
1196  if ( abilities & 8192 )
1197  features.set( IceBreaker );
1198  if ( abilities & 16384 )
1199  features.set( NoInairRefuelling );
1200  if ( abilities & 32768 )
1201  features.set( ExternalMaterialTransfer );
1202  if ( abilities & (1 << 17) )
1203  features.set( MakesTracks );
1204  if ( abilities & (1 << 18) )
1205  features.set( DetectsMineralResources );
1206  if ( abilities & (1 << 19) )
1207  features.set( NoReactionfire );
1208  if ( abilities & (1 << 20) )
1209  features.set( AutoRepair );
1210  if ( abilities & (1 << 21) )
1211  features.set( MatterConverter );
1212  // we probably need to setup the conversion matrix at this point
1213 
1214  if ( abilities & (1 << 22) )
1215  features.set( DetectsMineralResources );
1216  if ( abilities & (1 << 23) )
1217  features.set( KamikazeOnly );
1218  if ( abilities & (1 << 24) )
1219  features.set( ImmuneToMines );
1220  if ( abilities & (1 << 25) )
1221  features.set( ExternalEnergyTransfer );
1222  if ( abilities & (1 << 26) )
1223  features.set( JamsOnlyOwnField );
1224  if ( abilities & (1 << 27) )
1225  features.set( MoveWithReactionFire );
1226  if ( abilities & (1 << 28) )
1227  features.set( OnlyMoveToAndFromTransports );
1228  return features;
1229 }
1230 
1231 void VehicleType::paint ( Surface& s, SPoint pos, const PlayerColor& player, int direction ) const
1232 {
1233  megaBlitter<ColorTransform_PlayerCol,ColorMerger_AlphaOverwrite,SourcePixelSelector_Plain,TargetPixelSelector_All>( getImage(), s, pos, player, nullParam, nullParam, nullParam );
1234 }
1235 
1236 void VehicleType::paint ( Surface& s, SPoint pos ) const
1237 {
1238  megaBlitter<ColorTransform_None,ColorMerger_AlphaOverwrite,SourcePixelSelector_Plain,TargetPixelSelector_All>( getImage(), s, pos, nullParam, nullParam, nullParam, nullParam );
1239 }
1240 
1241 
1243 {
1244  pc.addTagInteger( "Type", typ, weaponTypeNum, weaponTags );
1245  pc.addTagInteger( "targets", targ, choehenstufennum, heightTags );
1247  pc.addInteger("MaxRange", maxdistance );
1248  pc.addInteger("MinRange", mindistance );
1249  pc.addInteger("Ammo", count );
1250  pc.addInteger("Punch@MaxRange", minstrength );
1251  pc.addInteger("Punch@MinRange", maxstrength );
1252  pc.addString("Sound", soundLabel, "");
1253  pc.addInteger("LaserRechargeRate", laserRechargeRate, 0 );
1254  pc.openBracket( "laserRechargeCost" );
1255  laserRechargeCost.runTextIO ( pc, Resources(0,0,0) );
1256  pc.closeBracket();
1257 
1258  pc.addInteger("ReactionFireShots", reactionFireShots, 1 );
1259  if ( getScalarWeaponType() == cwminen && reactionFireShots > 0 )
1260  warningMessage(pc.getFileName() + " has a mine with Reactionfire. This doesn't make sense.");
1261 
1262  pc.openBracket("HitAccuracy" );
1263  {
1264  for ( int j = 0; j < 13; j++ )
1265  if ( j < 6 )
1266  pc.addInteger( ASCString("d")+strrr(abs(j-6)), efficiency[j] );
1267  else
1268  if ( j == 6 )
1269  pc.addInteger( "0", efficiency[j] );
1270  else
1271  pc.addInteger( ASCString("u")+strrr(j-6), efficiency[j] );
1272  }
1273  pc.closeBracket();
1274 
1275  if ( pc.isReading() ) {
1276  if ( pc.find ( "cantHit" )) {
1277  int targets_not_hittable;
1278  pc.addTagInteger( "cantHit", targets_not_hittable, cmovemalitypenum, unitCategoryTags );
1279  for ( int i = 0; i < cmovemalitypenum; i++ )
1280  if ( targets_not_hittable & ( 1 << i ))
1281  targetingAccuracy[i] = 0;
1282  }
1283  pc.openBracket("WeaponEffectiveness" );
1284  for ( int i = 0; i < cmovemalitypenum; i++ ) {
1285  if ( pc.find ( unitCategoryTags[i] ))
1287  }
1288  pc.closeBracket();
1289  } else {
1290  pc.openBracket("WeaponEffectiveness" );
1291  for ( int i = 0; i < cmovemalitypenum; i++ )
1292  if ( targetingAccuracy[i] != 100 )
1294  pc.closeBracket();
1295  }
1296  pc.addString("name", name, "");
1297 }
1298 
1299 
1301 {
1302  pc.addTagInteger( "StartHeight", startHeight, choehenstufennum, heightTags );
1303  pc.addInteger("HeightDelta", heightDelta );
1304  pc.addInteger("MoveCost", moveCost, 0 );
1305  pc.addBool ( "CanAttack", canAttack );
1306  pc.addInteger("Dist", dist );
1307 }
1308 
1309 
1310 
1312 
1313 
1315 {
1316  int version = stream.readInt();
1317  if ( version > vehicleHeightChangeMethodVersion || version < 1 ) {
1318  ASCString s = "invalid version for reading VehicleType :: HeightChangeMethod : ";
1319  s += strrr ( version );
1320  throw ASCmsgException ( s );
1321  }
1322  startHeight = stream.readInt();
1323  heightDelta = stream.readInt();
1324  moveCost = stream.readInt();
1325  canAttack = stream.readInt();
1326  dist = stream.readInt();
1327 }
1328 
1330 {
1331  stream.writeInt ( vehicleHeightChangeMethodVersion );
1332  stream.writeInt ( startHeight );
1333  stream.writeInt ( heightDelta );
1334  stream.writeInt ( moveCost );
1335  stream.writeInt ( canAttack );
1336  stream.writeInt ( dist );
1337 }
1338 
1340 {
1341  static UnitCostCalculator* standard = new StandardUnitCostCalculator();
1342  static UnitCostCalculator* pbp = new PBPUnitCostCalculator();
1343 
1344  if ( unitCostCalculatorName.toLower() == "pbp" )
1345  return pbp->productionCost( this );
1346  else if ( unitCostCalculatorName.toLower() == "standard" )
1347  return standard->productionCost( this );
1348  else throw ASCmsgException("Invalid cost calculator for unit " + ASCString::toString( id ));
1349 
1350 }
VehicleType(void)
Definition: vehicletype.cpp:96
virtual Resources productionCost(const VehicleType *vehicle)=0
int fuel
Definition: typen.h:101
vector< IntRange > objectsBuildable
the ids of objects this unit can construct
Definition: vehicletype.h:233
bool wait
If the unit cannot attack in the same turn after it has moved, it has to wait.
Definition: vehicletype.h:197
ASCString filename
The name of the file from which the item was loaded.
Definition: typen.h:290
struct VehicleType::JumpDrive jumpDrive
int defaultMaxResearchpoints
when a building of this type is placed on a map, its maxResearch property will be set to this value ...
vector< int > guideSortHelp
Definition: vehicletype.h:279
void addBool(const ASCString &name, bool &property)
ASCString getName(void) const
bool service(void) const
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
vector< IntRange > vehiclesBuildable
the ids of units this unit can construct
Definition: vehicletype.h:230
#define cwmachinegunn
Definition: vehicletype.h:77
ASCString & toLower()
Definition: ascstring.cpp:36
#define cwsmallmissilen
Definition: vehicletype.h:73
int maxsize(void) const
returns the maximum weight of this unit without fuel and material
const int choehenstufennum
The number of levels of height.
Definition: typen.h:67
void set(int type)
const char * AIjobs[AiParameter::jobNum]
int initiative
unused
Definition: vehicletype.h:215
#define weaponTypeNum
Definition: vehicletype.h:63
int energy
Definition: typen.h:99
void read(tnstream &stream)
read the binary representation of this item from the given stream
#define cwservicen
Definition: vehicletype.h:88
virtual ASCString getLocation()
returns the location of the stream.
Definition: basestrm.cpp:274
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
#define cwcruisemissilen
Definition: vehicletype.h:65
NullParamType nullParam
Definition: blitter.cpp:30
virtual ASCString getDeviceName()
returns the name of the stream.
Definition: basestrm.cpp:269
double cargoMovementDivisor
if a transport moves the movement for the units inside a transport is decreased by 1/n of the tranpor...
Definition: vehicletype.h:194
#define cwbombn
Definition: vehicletype.h:69
int getFirstBit(int zahl)
Count the number of zero bits on the LSB side of "zahl".
Definition: misc.cpp:45
UnitWeapon weapons
The weapons.
Definition: vehicletype.h:248
vector< IntRange > objectGroupsRemovable
the group-ids of objects this unit can remove
Definition: vehicletype.h:242
void addImage(const ASCString &name, Surface &property, ASCString &fileName, bool applyFieldMask)
int sourceheight
the weapon can be shot from these levels of height (bitmapped)
Definition: vehicletype.h:108
int efficiency[13]
the targeting accuracy of the weapon over different height differences between the attacking unit and...
Definition: vehicletype.h:132
#define cwweapon
Definition: vehicletype.h:81
bool shootable(void) const
void runTextIO(PropertyContainer &pc)
registers the properties of this item for loading/writing into asctxt files
int targ
the weapon can attack targets at these levels of height (bitmapped)
Definition: vehicletype.h:105
bool hasFunction(ContainerFunctions function) const
bool canRefuel(void) const
vector< IntRange > buildingsBuildable
the ids of buildings this unit can construct
Definition: vehicletype.h:227
void addIntegerArray(const ASCString &name, vector< int > &property, bool required=true)
#define cwlaserb
Definition: vehicletype.h:85
int bipicture
the image index from the GraphicSet , or -1 if no graphics from graphic sets are used.
Definition: vehicletype.h:224
Functions to evaluate the parsed *.asctxt files.
const char * cwaffentypen[weaponTypeNum]
Definition: vehicletype.cpp:71
const Surface & getImage() const
Definition: vehicletype.h:325
void read(tnstream &stream)
void runTextIO(PropertyContainer &pc)
Definition: typen.cpp:254
void addTagInteger(const ASCString &name, int &property, int tagNum, const char **tags, bool inverted=false)
virtual int readWord(void)
Reads a 16 bit unsigned Integer. In the stream little-endian byte order is used and a translation is ...
Definition: basestrm.cpp:291
vector< IntRange > objectsRemovable
the ids of objects this unit can remove
Definition: vehicletype.h:236
void warningMessage(const ASCString &str)
int count
amount of ammunition the unit having this weapon can carry
Definition: vehicletype.h:117
static const int legacyVehicleFunctionNum
Definition: vehicletype.h:187
const bool weaponAmmo[weaponTypeNum]
Definition: vehicletype.cpp:92
A system that provides a set of images for vehicles, buildings, etc.
int gettype(void) const
Definition: vehicletype.h:158
Resources laserRechargeCost
the resources that recharging the laser for a single shot requires
Definition: vehicletype.h:143
static const int functionNum
SingleWeapon weapon[16]
Definition: vehicletype.h:170
void read(tnstream &stream)
Definition: typen.cpp:195
Global platform dependant definitions. This file just branches to the platform specific files in thei...
ASCString getName() const
The interface for all kinds of IO stream.
const int vehicle_version
TerrainAccess targetterrain
Definition: vehicletype.h:314
void strech(int width, int height)
Definition: surface.cpp:457
#define cwlasern
Definition: vehicletype.h:84
const int productionCostCalculationMethodNum
Definition: textfiletags.h:33
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)
vector< int > movement
the distance a unit can travel each round. One value for each of the 8 levels of height ...
Definition: vehicletype.h:203
void runTextIO(PropertyContainer &pc, const ASCString &defaultTechAdapter="")
Definition: research.cpp:454
int view
the visibility range
int digrange
radius of the circle in which a unit can search for mineral resolures (measured in number of fields...
Definition: vehicletype.h:212
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
virtual float readFloat(void)
Reads a flaot variable.
Definition: basestrm.cpp:328
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
int getScalarWeaponType(void) const
void setFunction(ContainerFunctions function)
int unitConstructionMinDistance
the minimal distance (measured in number of fields) in which units can be externally constructed ...
Definition: vehicletype.h:257
static ASCString toString(int i)
converts the parameter to a String
Definition: ascstring.cpp:193
void error(const ASCString &errmsg)
#define cwcannonn
Definition: vehicletype.h:79
int mindistance
the minimal distance the weapon can shoot
Definition: vehicletype.h:114
void write(tnstream &stream) const
write the binary representation of this item to the given stream
const char * weaponTags[weaponTypeNum]
char * strrr(int a)
converts a to a string.
Definition: misc.cpp:66
int minstrength
strength of the weapon when fired over the maximum distance
Definition: vehicletype.h:123
TerrainBits terrainreq
ALL these bits must be set in the terrain.
Definition: terraintype.h:50
void write(tnstream &stream) const
Definition: typen.cpp:201
bool placeObjects() const
static BitSet convertOldFunctions(int abilities, const ASCString &location)
int getMemoryFootprint() const
Resources calcProductionCost()
std::bitset< 64 > features
const int ammoProductionCost[weaponTypeNum][3]
Definition: vehicletype.cpp:75
void displayLogMessage(int msgVerbosity, const char *message,...)
int unitConstructionMaxDistance
the maximum distance (measured in number of fields) in which units can be externally constructed ...
Definition: vehicletype.h:259
int reactionFireShots
Definition: vehicletype.h:145
#define cwmineb
Definition: vehicletype.h:68
int movemalustyp
The category of the unit. Original used only to distinguish only between different movement costs for...
Definition: vehicletype.h:206
const int cmovemalitypenum
The number of vehicle categories; Each category has its own move malus.
Definition: typen.h:384
int jamming
the radar jamming power
const char * productionCostCalculationMethod[productionCostCalculationMethodNum]
int height
bitmapped: on these levels of height the jump drive can be activated
Definition: vehicletype.h:310
virtual void writeUint8(Uint8 c)
Writes a 8 bit unsigned Integer.
Definition: basestrm.cpp:380
TerrainBits terrainnot
if one of these bits is set, the field will NOT be accessible
Definition: terraintype.h:53
bool requiresAmmo(void) const
static ASCString getIconFileName(int weaponType)
int efficiencymaterial
currently only used by mining stations: the efficiency of the resource extraction from the ground...
int unitConstructionMoveCostPercentage
if this unit constructs another unit externally (for example a turret), it costs this much of its mov...
Definition: vehicletype.h:254
int maxdistance
the maximum distance the weapon can shoot
Definition: vehicletype.h:111
const int vehicleHeightChangeMethodVersion
ASCString killSoundLabel
this label can select a special sound to be played when this unit is killed
Definition: vehicletype.h:277
A single weapon of a #Vehicletype.
Definition: vehicletype.h:100
int material
Definition: typen.h:100
const char * heightTags[choehenstufennum]
void runTextIO(PropertyContainer &pc)
registers the properties of this item for loading/writing into asctxt files
AiParameter::Job recommendedAIJob
the recommended task for the unit, set by the unit creater
Definition: vehicletype.h:268
int targetingAccuracy[cmovemalitypenum]
the effectiveness of the weapon against different targets.
Definition: vehicletype.h:137
#define cwshootableb
Definition: vehicletype.h:83
The IO for many basic classes and structurs of ACS.
#define fieldsizex
Definition: typen.h:440
int autorepairrate
the damage this unit can repair itself automatically each turn.
Definition: vehicletype.h:251
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
#define cwminen
Definition: vehicletype.h:67
SDLmm::SPoint SPoint
Definition: surface.h:27
void errorMessage(const ASCString &string)
int weight
the weight of the unit, without fuel or other cargo
Definition: vehicletype.h:218
TerrainBits terrainkill
if a terrain is not accessible AND one of these bits is matched, the unit will be destroyed ...
Definition: terraintype.h:56
static const int jobNum
UnitWeapon(void)
bool equals(const SingleWeapon *otherWeapon) const
vector< HeightChangeMethod > heightChangeMethod
Definition: vehicletype.h:294
const char * unitCategoryTags[cmovemalitypenum]
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 assignDefaultPalette()
assigns the default ASC palette to the surface (only for 8 Bit surfaces)
Definition: surface.cpp:429
void addInteger(const ASCString &name, int &property)
AiValue * aiparam[8]
some information the AI stores about this unit
Definition: vehicletype.h:265
void setInt(int terrain1=0, int terrain2=0)
int nominalresearchpoints
the number of reseach points for which the plus settings apllies
TerrainBits terrain
at least one of these bits must match on of the terrain
Definition: terraintype.h:47
int fuelConsumption
the fuel consumption to move a single field
Definition: vehicletype.h:200
int & resource(int type)
Definition: typen.h:105
void write(tnstream &stream) const
Definition: terraintype.cpp:86
int heightChangeMethodNum
Definition: vehicletype.h:281
virtual void closeBracket()
ASCString name
Definition: vehicletype.h:149
void addNamedInteger(const ASCString &name, int &property, int tagNum, const char **tags)
const VehicleType * typ
Definition: vehicle.h:83
Uint8 direction
the direction in which the unit is facing
Definition: vehicle.h:121
int maxwindspeedonwater
the maximum speed of the wind that the unit can survive when on open water without sinking ...
Definition: vehicletype.h:209
vector< IntRange > objectGroupsBuildable
the group-ids of objects this unit can construct
Definition: vehicletype.h:239
bool offensive(void) const
virtual void writeFloat(float f)
Write a floating point variable.
Definition: basestrm.cpp:385
virtual void writeWord(int w)
Writes a 16 bit unsigned Integer. In the stream little-endian byte order is used and a translation is...
Definition: basestrm.cpp:369
void paint(Surface &s, SPoint pos, const PlayerColor &player, int direction=0) const
#define maxint
Definition: typen.h:462
ASCString movementSoundLabel
this label can select a special sound to be played when moving
Definition: vehicletype.h:274
vector< IntRange > objectLayedByMovement
the IDs of objects that are automatically layed by moving the movement
Definition: vehicletype.h:245
void writeClassContainer(const C &c, tnstream &stream)
Definition: basestrm.h:742
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)
const T & max(const T &a, const T &b, const T &c)
Definition: misc.h:97
void read(tnstream &stream)
Definition: research.cpp:434
const T & min(const T &a, const T &b, const T &c)
Definition: misc.h:80
ASCString infotext
an extensive information about the unit/building which may be several paragraphs long ...
int maxstrength
strength of the weapon when fired over the minimal distance
Definition: vehicletype.h:120
Resources are basically the currency of ASC.
Definition: typen.h:97
void addString(const ASCString &name, ASCString &property)
const char * containerFunctionTags[ContainerBaseType::functionNum]
#define cwserviceb
Definition: vehicletype.h:89
void runTextIO(PropertyContainer &pc)
void addIntRangeArray(const ASCString &name, vector< IntRange > &property, bool required=true)
#define cwammunitionb
Definition: vehicletype.h:87
vector< int > wreckageObject
if the unit is destroyed, it can leave an wreckage object behind ( < 0 to disable ) ...
Definition: vehicletype.h:262
void write(tnstream &stream) const
int getMemoryFootprint() const
Definition: surface.cpp:716
bool find(const ASCString &name)
std::bitset< 64 > BitSet
Definition: basictypes.h:48
#define cwtorpedon
Definition: vehicletype.h:75
int maxSpeed() const
void addTagArray(const ASCString &name, BitSet &property, int tagNum, const char **tags, bool inverted=false)
TerrainAccess terrainaccess
the terrain this unit can move to
Definition: vehicletype.h:221
Resources defaultProduction
if a new building is constructed, this will be the resource production of the building ...
ASCString soundLabel
Definition: vehicletype.h:147
#define cwlargemissilen
Definition: vehicletype.h:71
ASCString name
a short name, for example B-52
const char * vehicleAbilities[VehicleType::legacyVehicleFunctionNum]
deprecated
void write(tnstream &stream) const
write the binary representation of this item to the given stream
void addDFloat(const ASCString &name, double &property)
void read(tnstream &stream)
read the binary representation of this item from the given stream
Functions to parse the *.asctxt files.
#define cwobjectplacementb
Definition: vehicletype.h:91
int laserRechargeRate
the number of shots that the laser is recharged each turn
Definition: vehicletype.h:140
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