*/
float Skeleton::DoConstraints(XYZ *coords, float *scale)
{
- float friction = 1.5;
const float elasticity = .3;
XYZ bounceness;
const int numrepeats = 3;
muscles[i].DoConstraint(spinny);
}
+ float friction;
for (i = 0; i < joints.size(); i++) {
//Length constraints
//Ground constraint
void ch_path(const char *args)
{
- int n = sizeof(pathtypenames) / sizeof(pathtypenames[0]);
- for (int i = 0; i < n; i++)
+ unsigned int n = sizeof(pathtypenames) / sizeof(pathtypenames[0]);
+ for (unsigned int i = 0; i < n; i++)
if (stripfx(args, pathtypenames[i])) {
editorpathtype = i;
break;
void Terrain::AddObject(XYZ where, float radius, int id)
{
- bool done;
- int i, j;
XYZ points[4];
if (id >= 0 && id < 10000)
- for (i = 0; i < subdivision; i++) {
- for (j = 0; j < subdivision; j++) {
+ for (int i = 0; i < subdivision; i++) {
+ for (int j = 0; j < subdivision; j++) {
if (patchobjectnum[i][j] < 300 - 1) {
- done = 0;
+ bool done = false;
points[0].x = (size / subdivision) * i;
points[0].z = (size / subdivision) * j;
points[0].y = heightmap[(int)points[0].x][(int)points[0].z];
static float tempmult;
float tutorialopac;
std::string string;
- std::string string2;
- std::string string3;
static int drawmode = 0;
if ( stereomode == stereoAnaglyph ) {
} else {
glColorMask( 1.0, 1.0, 1.0, 1.0 );
- if ( stereomode == stereoHorizontalInterlaced || stereomode == stereoVerticalInterlaced ) {
+ if ( stereomode == stereoHorizontalInterlaced ||
+ stereomode == stereoVerticalInterlaced ) {
glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
}
}
//Hot spots
if (Hotspot::hotspots.size() && (bonustime >= 1 || bonus <= 0 || bonustime < 0) && !Tutorial::active) {
float closestdist = -1;
- float distance = 0;
int closest = Hotspot::current;
for (unsigned i = 0; i < Hotspot::hotspots.size(); i++) {
- distance = distsq(&Person::players[0]->coords, &Hotspot::hotspots[i].position);
+ float distance = distsq(&Person::players[0]->coords, &Hotspot::hotspots[i].position);
if (closestdist == -1 || distance < closestdist) {
if (distsq(&Person::players[0]->coords, &Hotspot::hotspots[i].position) < Hotspot::hotspots[i].size && ((Hotspot::hotspots[i].type <= 10 && Hotspot::hotspots[i].type >= 0) || (Hotspot::hotspots[i].type <= 40 && Hotspot::hotspots[i].type >= 20))) {
closestdist = distance;
int findPathDist(int start, int end)
{
- int smallestcount, count, connected;
- int last, last2, last3, last4;
+ int smallestcount, connected;
int closest;
smallestcount = 1000;
- for (int i = 0; i < 50; i++) {
- count = 0;
- last = start;
- last2 = -1;
- last3 = -1;
- last4 = -1;
+ for (char i = 0; i < 50; i++) {
+ unsigned count = 0;
+ int last = start;
+ int last2 = -1;
+ int last3 = -1;
+ int last4 = -1;
while (last != end && count < 30) {
closest = -1;
for (int j = 0; j < Game::numpathpoints; j++) {
#if PLATFORM_LINUX
/* Generic code for XDG ENVVAR test and fallback */
-std::string Folders::getGenericDirectory(const char* ENVVAR, const std::string fallback) {
+std::string Folders::getGenericDirectory(const char* ENVVAR, const std::string& fallback) {
const char* path = getenv(ENVVAR);
std::string ret;
if ((path != NULL) && (strlen(path) != 0)) {
}
#endif
-bool Folders::makeDirectory(std::string path) {
+bool Folders::makeDirectory(const std::string& path) {
#ifdef _WIN32
int status = CreateDirectory(path.c_str(), NULL);
- if (status != 0) {
- return true;
- } else if(GetLastError() == ERROR_ALREADY_EXISTS) {
- return true;
- } else {
- return false;
- }
+ return status != 0 || GetLastError() == ERROR_ALREADY_EXISTS;
#else
errno = 0;
int status = mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
- if (status == 0) {
- return true;
- } else if(errno == EEXIST) {
- return true;
- } else {
- return false;
- }
+ return status == 0 || errno == EEXIST;
#endif
}
-FILE* Folders::openMandatoryFile(std::string filename, const char* mode)
+FILE* Folders::openMandatoryFile(const std::string& filename, const char* mode)
{
FILE* tfile = fopen(filename.c_str(), mode);
if (tfile == NULL) {
struct FileNotFoundException: public std::exception
{
std::string errorText;
- FileNotFoundException (const std::string& filename) {
- errorText = filename + " could not be found";
- }
+
+ FileNotFoundException (const std::string& filename)
+ : errorText(filename + " could not be found")
+ {}
const char * what () const throw () {
return errorText.c_str();
static const std::string dataDir;
public:
- /* Returns path to the screenshot directory. Creates it if needed. */
+ /** Returns path to the screenshot directory. Creates it if needed. */
static std::string getScreenshotDir();
- /* Returns full path for user data */
+ /** Returns full path for user data */
static std::string getUserDataPath();
- /* Returns full path for config file */
+ /** Returns full path for config file */
static std::string getConfigFilePath();
- static FILE* openMandatoryFile(std::string filename, const char* mode);
+ static FILE* openMandatoryFile(const std::string& filename, const char* mode);
/* Returns full path for a game resource */
- static inline std::string getResourcePath(std::string filepath) { return dataDir + '/' + filepath; }
+ static inline std::string getResourcePath(const std::string& filepath)
+ { return dataDir + '/' + filepath; }
- /* Returns full path for user progress save */
- static inline std::string getUserSavePath() { return getUserDataPath() + "/users"; }
+ /** Returns full path for user progress save */
+ static inline std::string getUserSavePath()
+ { return getUserDataPath() + "/users"; }
private:
static const char* getHomeDirectory();
- static std::string getGenericDirectory(const char* ENVVAR, const std::string fallback);
- static bool makeDirectory(std::string path);
+ static std::string getGenericDirectory(const char* ENVVAR, const std::string& fallback);
+ static bool makeDirectory(const std::string& path);
};
#endif /* _FOLDERS_H_ */