long InitCADD (void);
long FreeCADD (void);

char textline[80];
char grabtext[80];
char itemtext[80];

class Country{

public:
	char Name[32];
	Country *Next;
	Country *CountryFirst, *CountryCurrent, *CountryLast;
	Country ();
	long AddCountry ();	
	long FreeCountries ();
	long DisplayNames ();
	long SearchCountry (char *CountryName);
	long countries;
};

/*
	coming soon recoil support & scope support (aim bonus)
*/
class Weapon{

public:
	char Name[32];
	long HitAccuracy;
	long Damage;
	long Peneration;
	long Cost;
	long MagSize;
	long MagType;
	long MagCost;
	long Cost1;
	long Cost2;
	long WeaponType;
	long FireType;
	long Malfunction;
	long Country;
	long DamageLoss;
	long HitAccuracyLoss;
	long Weight;
	Weapon *Next;
	Weapon *WeaponFirst, *WeaponCurrent, *WeaponLast;
	Weapon ();
	long AddWeapon ();
	long FreeWeapons ();
	long DisplayWeaponInfo (long weapon_index);
	long weapons;
};

class Team{

public:
	char name[32];
	long AddTeam ();
	long FreeTeams ();
	long SelectCurrentTeam (long teamindex);
	long DeleteTeam (long teamindex);

	Team ();
	Team *TeamFirst, *TeamCurrent, *TeamLast;
	Team *Next;
	long teams;
	long teamsoldiers;
	long money;
};

class Name{

public:
	long Country;
	char FirstName[16];
	char SurName[16];	
	Name ();
	long AddName ();
	long FreeNames ();
	long GenerateAllPossibleNames ();
	long GetName (long firstindex, long surindex);
	long DisplayNames ();
	long GetNameCountry (long nameindex);
	char *GetFirstName (long nameindex);
	char *GetSurName (long nameindex);

	Name *Next;
	Name *NameFirst, *NameCurrent, *NameLast;
	long names;
};

/*
	Soldier class prototype
*/
class Soldier{

public:
	long Team;
	long FirstName;		// linked name list entry
	long SurName;		// linked name list entry
	long HP[7];			// hit points for 7 body parts

	/*
		body parts are:
		0 - head (str + con), head has 2 hit "parts" and
		hits to head are very deadly (2-3x normal damage!)
		1 - left arm (str + con) * 2
		2 - right arm
		3 - chest (str + con) * 3
		4 - abdomen
		5 - left leg
		6 - right leg
	*/
	
	long Weapon;		// linked weapon list entry
	long Ammo;			// total ammo
	long Inmag;			// in magazine ammo
	long MPs;			// moving points
	long Strength;
	long Constitution;
	long Kills;			// kills
	long Experience;	// experience points... 
	long Rank;			// rank (can be, 0=NOVICE, 1=GREEN, 2=VETERAN, 3=ELITE)
	long Cost;			// buy/sell price
	long Load;			// soldier's load in KGs
	long FireSkill;

	Soldier ();
	long AddSoldier (void);
	long FreeSoldiers (void);
	long GenerateSoldier (long country, long mixednames);
	long DisplaySoldierInfo (long index);
	long DeleteSoldier (long soldierindex);

	Soldier *Next;	// not used
	Soldier *SoldierFirst, *SoldierCurrent, *SoldierLast;
	long soldiers;	// not used
};

#define HEAD_HPS 0
#define CHEST_HPS 1
#define LEFTARM_HPS 2
#define RIGHTARM_HPS 3
#define ABDOMEN_HPS 4
#define LEFTLEG_HPS 5
#define RIGHTLEG_HPS 6

class Country *CaddCountry;
class Weapon *CaddWeapon;
class Team *CaddTeam;
class Name *CaddName;
class Soldier *CaddSoldier;	// used in soldier generate routine
class Soldier *CaddGeneratedSoldier;

long itempos = 0;
long itemindex = 0;

#define FIRE_TYPES 6

char *FireType[FIRE_TYPES] = {
	"SS",		// singleshot
	"PA",		// pump-action
	"SA",		// semiautomatic
	"BURST3",	// 3-burst
	"BURST5",	// 5-burst
	"BURST10"	// 10-burst
};

#define WEAPON_TYPES 5

char *WeaponType[WEAPON_TYPES] = {
	"PISTOL",
	"RIFLE",
	"SHOTGUN",
	"SUBMACHINEGUN",
	"ASSAULTRIFLE"
};

long oc1, oc2;
long lstr, lcon;

long DuplicateGeneratedSoldier (long target);
