]> git.mxchange.org Git - quix0rs-blobwars.git/commitdiff
Use UNIX line endings everywhere.
authorGuus Sliepen <guus@debian.org>
Mon, 28 Jun 2010 22:09:44 +0000 (00:09 +0200)
committerGuus Sliepen <guus@debian.org>
Mon, 28 Jun 2010 22:09:44 +0000 (00:09 +0200)
Reapplication of commit 927fcd8193a4d0c9365796f30f246bf519b2cce2.

src/CConfig.cpp
src/CConfig.h

index a2bc4ee3a897122389102efff138546800047035..ce87a06ce358c35fdefe27b89b5c29712b48d7d1 100644 (file)
-#include "headers.h"\r
-\r
-Config::Config()\r
-{\r
-       sdlJoystick = NULL;\r
-       \r
-       for (int i = 0 ; i < CONTROL::MAX ; i++)\r
-       {\r
-               command[i] = 0;\r
-       }\r
-}\r
-\r
-Config::~Config()\r
-{\r
-}\r
-\r
-void Config::populate()\r
-{\r
-       for (int i = 0 ; i < CONTROL::MAX ; i++)\r
-       {\r
-               command[i] = (engine->keyState[keyboard.control[i]]); \r
-               \r
-               if (joystick.control[i] >= 0)\r
-               {\r
-                       command[i] = (command[i] || (engine->joystickState[joystick.control[i]]));\r
-               }\r
-       }\r
-       \r
-       if (engine->joyX < -joystick.sensitivity) command[CONTROL::LEFT] = 1;\r
-       if (engine->joyX > joystick.sensitivity)  command[CONTROL::RIGHT] = 1;\r
-       if (engine->joyY < -joystick.sensitivity) command[CONTROL::UP] = 1;\r
-       if (engine->joyY > joystick.sensitivity)  command[CONTROL::DOWN] = 1;\r
-}\r
-\r
-void Config::populate(int *data)\r
-{\r
-       for (int i = 0 ; i < CONTROL::MAX ; i++)\r
-       {\r
-               command[i] = data[i];\r
-       }\r
-       \r
-       command[CONTROL::MAP] = 0;\r
-       command[CONTROL::PAUSE] = 0;\r
-}\r
-\r
-bool Config::isControl(CONTROL::TYPE type)\r
-{\r
-       return command[type];\r
-}\r
-\r
-void Config::resetControl(CONTROL::TYPE type)\r
-{\r
-       engine->keyState[keyboard.control[type]] = 0;\r
-       \r
-       command[type] = 0;\r
-       \r
-       if (joystick.control[type] >= 0)\r
-       {\r
-               engine->joystickState[joystick.control[type]] = 0;\r
-       }\r
-       \r
-       if (type == CONTROL::LEFT) engine->joyX = 0;\r
-       if (type == CONTROL::RIGHT) engine->joyX = 0;\r
-       if (type == CONTROL::UP) engine->joyY = 0;\r
-       if (type == CONTROL::DOWN) engine->joyY = 0;\r
-}\r
-\r
-void Config::doPause()\r
-{\r
-       if (!engine->paused)\r
-       {\r
-               if (engine->keyState[keyboard.control[CONTROL::PAUSE]])\r
-               {\r
-                       engine->paused = true;\r
-                       engine->keyState[keyboard.control[CONTROL::PAUSE]] = 0;\r
-               }\r
-       }\r
-       else\r
-       {\r
-               if ((engine->keyState[keyboard.control[CONTROL::PAUSE]]) || (engine->keyState[SDLK_ESCAPE]))\r
-               {\r
-                       engine->paused = false;\r
-                       engine->keyState[keyboard.control[CONTROL::PAUSE]] = 0;\r
-                       engine->keyState[SDLK_ESCAPE] = 0;\r
-               }\r
-       }\r
-}\r
-\r
-bool Config::loadJoystickConfig()\r
-{\r
-       char filename[PATH_MAX];\r
-       snprintf(filename, sizeof filename, "%sjoystick.cfg", engine->userHomeDirectory);\r
-       \r
-       debug(("Loading joystick config from %s\n", filename));\r
-       \r
-       FILE *fp = fopen(filename, "rb");\r
-       \r
-       if (!fp)\r
-       {\r
-               return false;\r
-       }\r
-               \r
-       if (fread(&joystick, sizeof(Joystick), 1, fp) != 1)\r
-       {\r
-               fclose(fp);\r
-               return false;\r
-       }\r
-               \r
-       fclose(fp);\r
-       \r
-       return true;\r
-}\r
-\r
-bool Config::saveJoystickConfig()\r
-{\r
-       char filename[PATH_MAX];\r
-       snprintf(filename, sizeof filename, "%sjoystick.cfg", engine->userHomeDirectory);\r
-       \r
-       debug(("Saving joystick config to %s\n", filename));\r
-       \r
-       FILE *fp = fopen(filename, "wb");\r
-       \r
-       if (!fp)\r
-       {\r
-               debug(("WARNING: Couldn't save joystick config\n"));\r
-               return false;\r
-       }\r
-               \r
-       fwrite(&joystick, sizeof(Joystick), 1, fp);\r
-               \r
-       fclose(fp);\r
-       \r
-       return true;\r
-}\r
-\r
-bool Config::loadKeyConfig()\r
-{\r
-       char filename[PATH_MAX];\r
-       snprintf(filename, sizeof filename, "%skeyboard.cfg", engine->userHomeDirectory);\r
-       \r
-       debug(("Loading keyboard config from %s\n", filename));\r
-       \r
-       FILE *fp = fopen(filename, "rb");\r
-       \r
-       if (!fp)\r
-       {\r
-               return false;\r
-       }\r
-               \r
-       if (fread(&keyboard, sizeof(Keyboard), 1, fp) != 1)\r
-       {\r
-               fclose(fp);\r
-               return false;\r
-       }\r
-               \r
-       fclose(fp);\r
-       \r
-       // Keyboard break fix - Feb 09\r
-       keyboard.control[CONTROL::UP] = 0;\r
-       \r
-       return true;\r
-}\r
-\r
-bool Config::saveKeyConfig()\r
-{\r
-       char filename[PATH_MAX];\r
-       snprintf(filename, sizeof filename, "%skeyboard.cfg", engine->userHomeDirectory);\r
-       \r
-       debug(("Saving keyboard config to %s\n", filename));\r
-       \r
-       FILE *fp = fopen(filename, "wb");\r
-       \r
-       if (!fp)\r
-       {\r
-               return false;\r
-       }\r
-               \r
-       fwrite(&keyboard, sizeof(keyboard), 1, fp);\r
-               \r
-       fclose(fp);\r
-       \r
-       return true;\r
-}\r
-\r
-void Config::restoreKeyDefaults()\r
-{\r
-       keyboard.setDefaultKeys();\r
-}\r
+#include "headers.h"
+
+Config::Config()
+{
+       sdlJoystick = NULL;
+       
+       for (int i = 0 ; i < CONTROL::MAX ; i++)
+       {
+               command[i] = 0;
+       }
+}
+
+Config::~Config()
+{
+}
+
+void Config::populate()
+{
+       for (int i = 0 ; i < CONTROL::MAX ; i++)
+       {
+               command[i] = (engine->keyState[keyboard.control[i]]); 
+               
+               if (joystick.control[i] >= 0)
+               {
+                       command[i] = (command[i] || (engine->joystickState[joystick.control[i]]));
+               }
+       }
+       
+       if (engine->joyX < -joystick.sensitivity) command[CONTROL::LEFT] = 1;
+       if (engine->joyX > joystick.sensitivity)  command[CONTROL::RIGHT] = 1;
+       if (engine->joyY < -joystick.sensitivity) command[CONTROL::UP] = 1;
+       if (engine->joyY > joystick.sensitivity)  command[CONTROL::DOWN] = 1;
+}
+
+void Config::populate(int *data)
+{
+       for (int i = 0 ; i < CONTROL::MAX ; i++)
+       {
+               command[i] = data[i];
+       }
+       
+       command[CONTROL::MAP] = 0;
+       command[CONTROL::PAUSE] = 0;
+}
+
+bool Config::isControl(CONTROL::TYPE type)
+{
+       return command[type];
+}
+
+void Config::resetControl(CONTROL::TYPE type)
+{
+       engine->keyState[keyboard.control[type]] = 0;
+       
+       command[type] = 0;
+       
+       if (joystick.control[type] >= 0)
+       {
+               engine->joystickState[joystick.control[type]] = 0;
+       }
+       
+       if (type == CONTROL::LEFT) engine->joyX = 0;
+       if (type == CONTROL::RIGHT) engine->joyX = 0;
+       if (type == CONTROL::UP) engine->joyY = 0;
+       if (type == CONTROL::DOWN) engine->joyY = 0;
+}
+
+void Config::doPause()
+{
+       if (!engine->paused)
+       {
+               if (engine->keyState[keyboard.control[CONTROL::PAUSE]])
+               {
+                       engine->paused = true;
+                       engine->keyState[keyboard.control[CONTROL::PAUSE]] = 0;
+               }
+       }
+       else
+       {
+               if ((engine->keyState[keyboard.control[CONTROL::PAUSE]]) || (engine->keyState[SDLK_ESCAPE]))
+               {
+                       engine->paused = false;
+                       engine->keyState[keyboard.control[CONTROL::PAUSE]] = 0;
+                       engine->keyState[SDLK_ESCAPE] = 0;
+               }
+       }
+}
+
+bool Config::loadJoystickConfig()
+{
+       char filename[PATH_MAX];
+       snprintf(filename, sizeof filename, "%sjoystick.cfg", engine->userHomeDirectory);
+       
+       debug(("Loading joystick config from %s\n", filename));
+       
+       FILE *fp = fopen(filename, "rb");
+       
+       if (!fp)
+       {
+               return false;
+       }
+               
+       if (fread(&joystick, sizeof(Joystick), 1, fp) != 1)
+       {
+               fclose(fp);
+               return false;
+       }
+               
+       fclose(fp);
+       
+       return true;
+}
+
+bool Config::saveJoystickConfig()
+{
+       char filename[PATH_MAX];
+       snprintf(filename, sizeof filename, "%sjoystick.cfg", engine->userHomeDirectory);
+       
+       debug(("Saving joystick config to %s\n", filename));
+       
+       FILE *fp = fopen(filename, "wb");
+       
+       if (!fp)
+       {
+               debug(("WARNING: Couldn't save joystick config\n"));
+               return false;
+       }
+               
+       fwrite(&joystick, sizeof(Joystick), 1, fp);
+               
+       fclose(fp);
+       
+       return true;
+}
+
+bool Config::loadKeyConfig()
+{
+       char filename[PATH_MAX];
+       snprintf(filename, sizeof filename, "%skeyboard.cfg", engine->userHomeDirectory);
+       
+       debug(("Loading keyboard config from %s\n", filename));
+       
+       FILE *fp = fopen(filename, "rb");
+       
+       if (!fp)
+       {
+               return false;
+       }
+               
+       if (fread(&keyboard, sizeof(Keyboard), 1, fp) != 1)
+       {
+               fclose(fp);
+               return false;
+       }
+               
+       fclose(fp);
+       
+       // Keyboard break fix - Feb 09
+       keyboard.control[CONTROL::UP] = 0;
+       
+       return true;
+}
+
+bool Config::saveKeyConfig()
+{
+       char filename[PATH_MAX];
+       snprintf(filename, sizeof filename, "%skeyboard.cfg", engine->userHomeDirectory);
+       
+       debug(("Saving keyboard config to %s\n", filename));
+       
+       FILE *fp = fopen(filename, "wb");
+       
+       if (!fp)
+       {
+               return false;
+       }
+               
+       fwrite(&keyboard, sizeof(keyboard), 1, fp);
+               
+       fclose(fp);
+       
+       return true;
+}
+
+void Config::restoreKeyDefaults()
+{
+       keyboard.setDefaultKeys();
+}
index 3a288cda40c74068fb14698f9b42ef1048b836e2..6a6f5f70221646be516b305e613fbf700f9eb2b4 100755 (executable)
@@ -1,30 +1,30 @@
-class Config\r
-{\r
-       public:\r
-       \r
-               Engine *engine;\r
-\r
-               int command[CONTROL::MAX];\r
-               \r
-               SDL_Joystick *sdlJoystick;\r
-               \r
-               Joystick joystick;\r
-               Keyboard keyboard;\r
-\r
-       Config();\r
-       ~Config();\r
-       \r
-       void populate();\r
-       void populate(int *data);\r
-       \r
-       bool isControl(CONTROL::TYPE type);\r
-       void resetControl(CONTROL::TYPE type);\r
-       \r
-       void doPause();\r
-       \r
-       bool loadJoystickConfig();\r
-       bool saveJoystickConfig();\r
-       bool loadKeyConfig();\r
-       bool saveKeyConfig();\r
-       void restoreKeyDefaults();\r
-};\r
+class Config
+{
+       public:
+       
+               Engine *engine;
+
+               int command[CONTROL::MAX];
+               
+               SDL_Joystick *sdlJoystick;
+               
+               Joystick joystick;
+               Keyboard keyboard;
+
+       Config();
+       ~Config();
+       
+       void populate();
+       void populate(int *data);
+       
+       bool isControl(CONTROL::TYPE type);
+       void resetControl(CONTROL::TYPE type);
+       
+       void doPause();
+       
+       bool loadJoystickConfig();
+       bool saveJoystickConfig();
+       bool loadKeyConfig();
+       bool saveKeyConfig();
+       void restoreKeyDefaults();
+};