working fixes
This commit is contained in:
+15
-3
@@ -1,14 +1,26 @@
|
||||
#include "ProjectileProfile.h"
|
||||
|
||||
// Constructor implementation
|
||||
ProjectileProfile::ProjectileProfile() {}
|
||||
ProjectileProfile::ProjectileProfile() {
|
||||
memset(_name, 0, sizeof(_name));
|
||||
_type = PELLET;
|
||||
_caliber = 0;
|
||||
_weight = 0;
|
||||
}
|
||||
ProjectileProfile::ProjectileProfile(String name, ProjectileType type, float caliber, float weight) {
|
||||
strcpy(_name, name.c_str());
|
||||
memset(_name, 0, sizeof(_name));
|
||||
strncpy(_name, name.c_str(), sizeof(_name) - 1);
|
||||
_type=type;
|
||||
_caliber=caliber;
|
||||
_weight=weight;
|
||||
}
|
||||
String ProjectileProfile::getName(){return String(_name);}
|
||||
String ProjectileProfile::getName(){
|
||||
_name[sizeof(_name)-1] = '\0';
|
||||
for (int i = 0; i < sizeof(_name) - 1; i++) {
|
||||
if (_name[i] == '\0') { _name[i+1] = '\0'; break; }
|
||||
}
|
||||
return String(_name);
|
||||
}
|
||||
float ProjectileProfile::getWeight(){return _weight;}
|
||||
String ProjectileProfile::getType(){if (_type==PELLET){return "Pellet";}else{return "Slug";}}
|
||||
float ProjectileProfile::getCaliber(){return _caliber;}
|
||||
Reference in New Issue
Block a user