* Add a new struct-level qualifier: %csv-field-override

- This qualifier allows overriding of CSV field numbers given in base classes
  - This is required for the WEAPON stats because it differs from most other stats in that it doesn't have the "designable" field as the last CSV field
 * Specify all CSV field numbers for the fields in struct WEAPON
 * Generate SQL INSERT statements from weapons.txt


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@6553 4a71c877-e1ca-e34f-864e-861f7616d084
master
Giel van Schijndel 2009-01-22 22:18:48 +00:00
parent ca71081504
commit 1f4e369cf2
7 changed files with 11016 additions and 11 deletions

View File

@ -242,6 +242,10 @@ LINE:
$curStruct{"qualifiers"}->{"csv-file"} = $file;
}
elsif (/csv-field-override\s+(\w+)\s+(\d+|last)\s*;/)
{
$curStruct{"qualifiers"}->{"csv-field-overrides"}{$1} = $2;
}
else
{
die "error: line $ARGV:$.: Unrecognized struct-level specifier: %$_";

View File

@ -25,12 +25,13 @@ sub printComments
sub printStructFields
{
my ($output, $struct, $first, $values) = @_;
my ($output, $struct, $first, $values, $fieldOverrides) = @_;
foreach my $field (@{$struct->{"fields"}})
{
if (my $CSV = $field->{"CSV"})
{
$CSV = $fieldOverrides->{$field->{"name"}} if $fieldOverrides->{$field->{"name"}};
$CSV = @$values - 1 if $CSV eq "last" and $values;
$$output .= ",\n" unless $first;
@ -135,7 +136,7 @@ sub getUniqueBaseField
sub printStructContent
{
my ($output, $struct, $structMap, $values) = @_;
my ($output, $struct, $structMap, $values, $fieldOverrides) = @_;
my $abstract = 0;
my $inherit = 0;
@ -145,7 +146,7 @@ sub printStructContent
{
my $inheritStruct = $struct->{"qualifiers"}{"inherit"};
printStructContent($output, $inheritStruct, $structMap, $values);
printStructContent($output, $inheritStruct, $structMap, $values, $fieldOverrides);
$inherit = 1;
}
@ -160,7 +161,7 @@ sub printStructContent
$$output .= "INSERT INTO `$name` (\n";
$$output .= "\t`unique_inheritance_id`" if $inherit;
printStructFields($output, $struct, !$inherit, 0);
printStructFields($output, $struct, !$inherit, 0, $fieldOverrides);
$$output .= "\n)\n";
my $unique_field = 0;
@ -186,7 +187,7 @@ sub printStructContent
}
}
printStructFields($output, $struct, !$inherit, $values);
printStructFields($output, $struct, !$inherit, $values, $fieldOverrides);
if ($inherit)
{
@ -196,6 +197,7 @@ sub printStructContent
if ($unique_field)
{
my $CSV = $unique_field->{"CSV"};
$CSV = $fieldOverrides->{$unique_field->{"name"}} if $fieldOverrides->{$unique_field->{"name"}};
$CSV = @$values - 1 if $CSV eq "last";
my $value = $values->[$CSV-1];
$value =~ s/'/''/g;
@ -240,7 +242,7 @@ sub printStruct()
s/'/''/g foreach (@values);
printStructContent($output, $struct, $structMap, \@values);
printStructContent($output, $struct, $structMap, \@values, $struct->{"qualifiers"}->{"csv-field-overrides"});
$$output .= "\n";
}
close CSV;

File diff suppressed because it is too large Load Diff

View File

@ -112,6 +112,7 @@ CREATE TABLE `WEAPON` (
-- Automatically generated ID to link the inheritance hierarchy.
unique_inheritance_id INTEGER PRIMARY KEY NOT NULL,
-- WEAPON's CSV layout differs from the rest for this field
-- Max distance to target for short range shot
shortRange INTEGER NOT NULL,

View File

@ -589,7 +589,7 @@ in_statement_err:
* false otherwise.
*/
bool
#line 502 "stats-db2.tpl"
#line 549 "stats-db2.tpl"
loadConstructStatsFromDB
#line 595 "stats-db2.c"
(sqlite3* db)
@ -626,7 +626,7 @@ loadConstructStatsFromDB
ROW_COUNT_VAR = sqlite3_column_int(stmt, 0);
sqlite3_finalize(stmt);
#line 504 "stats-db2.tpl"
#line 551 "stats-db2.tpl"
if (!statsAllocConstruct(ROW_COUNT_VAR))
return false;
#line 633 "stats-db2.c"
@ -797,7 +797,7 @@ loadConstructStatsFromDB
{
#line 508 "stats-db2.tpl"
#line 555 "stats-db2.tpl"
stats->ref = REF_CONSTRUCT_START + CUR_ROW_NUM;
// save the stats

View File

@ -806,6 +806,7 @@ typedef struct WEAPON_STATS
iIMDShape* pIMD;
/* END of inherited "COMPONENT" definition */
/**
* WEAPON's CSV layout differs from the rest for this field
* Max distance to target for short range shot
*/
UDWORD shortRange;
@ -1171,9 +1172,9 @@ struct sqlite3;
* false otherwise.
*/
extern bool
#line 502 "stats-db2.tpl"
#line 549 "stats-db2.tpl"
loadConstructStatsFromDB
#line 1177 "stats-db2.h"
#line 1178 "stats-db2.h"
(struct sqlite3* db);
#endif // __INCLUDED_DB_TEMPLATE_SCHEMA_STRUCTDEF_STATS_DB2_TPL_H__

View File

@ -385,99 +385,146 @@ struct WEAPON
%fetchRowById Row Id
$Row = statsGetWeapon($Id - 1);
end;
%csv-file "weapons.txt";
# WEAPON's CSV layout differs from the rest for this field
%csv-field-override designable 52;
# Max distance to target for short range shot
%csv-field 17;
UDWORD shortRange;
# Max distance to target for long range shot
%csv-field 18;
UDWORD longRange;
# Min distance to target for shot
%csv-field 47;
UDWORD minRange;
# Chance to hit at short range
%csv-field 19;
UDWORD shortHit;
# Chance to hit at long range
%csv-field 20;
UDWORD longHit;
# Time between each weapon fire
%csv-field 21;
UDWORD firePause;
# The number of explosions per shot
%csv-field 22;
UDWORD numExplosions;
# The number of rounds per salvo(magazine)
%csv-field 23;
UBYTE numRounds;
# Time to reload the round of ammo (salvo fire)
%csv-field 24;
UDWORD reloadTime;
# How much damage the weapon causes
%csv-field 25;
UDWORD damage;
# Basic blast radius of weapon
%csv-field 26;
UDWORD radius;
# Chance to hit in the blast radius
%csv-field 27;
UDWORD radiusHit;
# Damage done in the blast radius
%csv-field 28;
UDWORD radiusDamage;
# How long the round burns
%csv-field 29;
UDWORD incenTime;
# Damage done each burn cycle
%csv-field 30;
UDWORD incenDamage;
# Burn radius of the round
%csv-field 31;
UDWORD incenRadius;
# speed ammo travels at
%csv-field 34;
UDWORD flightSpeed;
# how high the ammo travels for indirect fire
%csv-field 35;
UDWORD indirectHeight;
# indicates whether the droid has to stop before firing
%csv-field 36;
enum FIREONMOVE fireOnMove;
# the class of weapon
%csv-field 37;
enum WEAPON_CLASS weaponClass;
# the subclass to which the weapon belongs
%csv-field 38;
enum WEAPON_SUBCLASS weaponSubClass;
# which projectile model to use for the bullet
%csv-field 39;
enum MOVEMENT_MODEL movementModel;
# which type of warhead is associated with the weapon
%csv-field 40;
enum WEAPON_EFFECT weaponEffect;
# used to compare with weight to see if recoils or not
%csv-field 46;
UDWORD recoilValue;
# amount the weapon(turret) can rotate 0 = none
%csv-field 41;
UBYTE rotate;
# max amount the turret can be elevated up
%csv-field 42;
UBYTE maxElevation;
# min amount the turret can be elevated down
%csv-field 43;
SBYTE minElevation;
# flag to make the (explosion) effect face the player when drawn
%csv-field 44;
UBYTE facePlayer;
# flag to make the inflight effect face the player when drawn
%csv-field 45;
UBYTE faceInFlight;
# size of the effect 100 = normal, 50 = half etc
%csv-field 49;
UBYTE effectSize;
# flag to indicate whether the effect lights up the world
%csv-field 48;
bool lightWorld;
# indicates how good in the air - SHOOT_ON_GROUND, SHOOT_IN_AIR or both
%csv-field 50;
UBYTE surfaceToAir;
# number of attack runs a VTOL droid can do with this weapon
%csv-field 51;
UBYTE vtolAttackRuns;
# flag to indicate whether pentrate droid or not
%csv-field 53;
bool penetrate;
# Graphics control stats
# How long a direct fire weapon is visible. Measured in 1/100 sec.
%csv-field 32;
UDWORD directLife;
# How long a blast radius is visible
%csv-field 33;
UDWORD radiusLife;
# Graphics used for the weapon
# The turret mount to use
%csv-field 10;
IMD_model optional pMountGraphic;
# The muzzle flash
%csv-field 11;
IMD_model pMuzzleGraphic;
# The ammo in flight
%csv-field 12;
IMD_model pInFlightGraphic;
# The ammo hitting a target
%csv-field 13;
IMD_model pTargetHitGraphic;
# The ammo missing a target
%csv-field 14;
IMD_model pTargetMissGraphic;
# The ammo hitting water
%csv-field 15;
IMD_model pWaterHitGraphic;
# The trail used for in flight
%csv-field 16;
IMD_model optional pTrailGraphic;
# Audio