[colobot] 63/145: Removed misc.cpp / misc.h

Didier Raboud odyx at moszumanska.debian.org
Mon Jul 11 12:56:18 UTC 2016


This is an automated email from the git hooks/post-receive script.

odyx pushed a commit to branch debian/master
in repository colobot.

commit 04d7c343ef20bbf2d634cdd4cd8f923b1d772ab4
Author: krzys-h <krzys_h at interia.pl>
Date:   Sat Apr 9 18:46:12 2016 +0200

    Removed misc.cpp / misc.h
---
 src/CMakeLists.txt                     |   1 -
 src/common/misc.cpp                    | 207 ---------------------------------
 src/common/misc.h                      |  36 ------
 src/level/robotmain.cpp                |  11 +-
 src/object/auto/autolabo.cpp           |   1 -
 src/ui/controls/button.cpp             |   1 -
 src/ui/controls/check.cpp              |   1 -
 src/ui/controls/color.cpp              |   1 -
 src/ui/controls/edit.cpp               |  17 +--
 src/ui/controls/editvalue.cpp          |   1 -
 src/ui/controls/group.cpp              |   1 -
 src/ui/controls/image.cpp              |   1 -
 src/ui/controls/scroll.cpp             |   1 -
 src/ui/controls/shortcut.cpp           |   1 -
 src/ui/controls/slider.cpp             |   1 -
 src/ui/displayinfo.cpp                 |   1 -
 src/ui/screen/screen_io.cpp            |   1 -
 src/ui/screen/screen_player_select.cpp |  25 ----
 src/ui/studio.cpp                      |  11 +-
 19 files changed, 17 insertions(+), 303 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 482de23..d397fb2 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -90,7 +90,6 @@ set(BASE_SOURCES
     common/key.cpp
     common/language.cpp
     common/logger.cpp
-    common/misc.cpp
     common/regex_utils.cpp
     common/resources/inputstream.cpp
     common/resources/inputstreambuffer.cpp
diff --git a/src/common/misc.cpp b/src/common/misc.cpp
deleted file mode 100644
index 578b4a6..0000000
--- a/src/common/misc.cpp
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * This file is part of the Colobot: Gold Edition source code
- * Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
- * http://epsitec.ch; http://colobot.info; http://github.com/colobot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see http://gnu.org/licenses
- */
-
-
-#include "common/misc.h"
-
-#include <math.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <time.h>
-#include <sstream>
-#include <iomanip>
-#include <chrono>
-
-
-// Returns a non-accented letter.
-
-char GetNoAccent(char letter)
-{
-    /*
-    if ( letter < 0 )
-    {
-        if ( letter == '�' ||
-             letter == '�' ||
-             letter == '�' ||
-             letter == '�' ||
-             letter == '�' )  return 'a';
-
-        if ( letter == '�' ||
-             letter == '�' ||
-             letter == '�' ||
-             letter == '�' )  return 'e';
-
-        if ( letter == '�' ||
-             letter == '�' ||
-             letter == '�' ||
-             letter == '�' )  return 'i';
-
-        if ( letter == '�' ||
-             letter == '�' ||
-             letter == '�' ||
-             letter == '�' ||
-             letter == '�' )  return 'o';
-
-        if ( letter == '�' ||
-             letter == '�' ||
-             letter == '�' ||
-             letter == '�' )  return 'u';
-
-        if ( letter == '�' )  return 'c';
-
-        if ( letter == '�' )  return 'n';
-
-        if ( letter == '�' ||
-             letter == '�' ||
-             letter == '�' ||
-             letter == '�' ||
-             letter == '�' )  return 'A';
-
-        if ( letter == '�' ||
-             letter == '�' ||
-             letter == '�' ||
-             letter == '�' )  return 'E';
-
-        if ( letter == '�' ||
-             letter == '�' ||
-             letter == '�' ||
-             letter == '�' )  return 'I';
-
-        if ( letter == '�' ||
-             letter == '�' ||
-             letter == '�' ||
-             letter == '�' ||
-             letter == '�' )  return 'O';
-
-        if ( letter == '�' ||
-             letter == '�' ||
-             letter == '�' ||
-             letter == '�' )  return 'U';
-
-        if ( letter == '�' )  return 'C';
-
-        if ( letter == '�' )  return 'N';
-    }*/
-
-    return letter;
-}
-
-// Returns an uppercase letter.
-
-char GetToUpper(char letter)
-{
-    /*if ( letter < 0 )
-    {
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-
-        if ( letter == '�' )  return '�';
-
-        if ( letter == '�' )  return '�';
-    }*/
-
-    return toupper(letter);
-}
-
-// Returns a lowercase letter.
-
-char GetToLower(char letter)
-{
-    /*if ( letter < 0 )
-    {
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-        if ( letter == '�' )  return '�';
-
-        if ( letter == '�' )  return '�';
-
-        if ( letter == '�' )  return '�';
-    }*/
-
-    return tolower(letter);
-}
-
-std::string TimeFormat(float time)
-{
-    int minutes = floor(time/60);
-    double time2 = fmod(time, 60);
-    double seconds;
-    double fraction = modf(time2, &seconds)*100;
-    std::ostringstream sstream;
-    sstream << std::setfill('0') << std::setw(2) << minutes << ":" << std::setfill('0') << std::setw(2) << floor(seconds) << "." << std::setfill('0') << std::setw(2) << floor(fraction);
-    return sstream.str();
-}
-
-
-// Adds an extension to file, if doesn't already one.
-
-void AddExt(char* filename, const char* ext)
-{
-    if ( strchr(filename, '.') != nullptr )  return;  // already an extension?
-    strcat(filename, ext);
-}
diff --git a/src/common/misc.h b/src/common/misc.h
deleted file mode 100644
index 4177f3d..0000000
--- a/src/common/misc.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * This file is part of the Colobot: Gold Edition source code
- * Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
- * http://epsitec.ch; http://colobot.info; http://github.com/colobot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see http://gnu.org/licenses
- */
-
-
-#pragma once
-
-
-#include <time.h>
-#include <string>
-
-
-// TODO: rewrite/refactor or remove
-
-extern char GetNoAccent(char letter);
-extern char GetToUpper(char letter);
-extern char GetToLower(char letter);
-
-extern std::string TimeFormat(float time);
-
-extern void AddExt(char* filename, const char* ext);
diff --git a/src/level/robotmain.cpp b/src/level/robotmain.cpp
index e2afb5b..ff3ae3b 100644
--- a/src/level/robotmain.cpp
+++ b/src/level/robotmain.cpp
@@ -29,7 +29,6 @@
 #include "common/event.h"
 #include "common/logger.h"
 #include "common/make_unique.h"
-#include "common/misc.h"
 #include "common/restext.h"
 #include "common/settings.h"
 #include "common/stringutils.h"
@@ -2420,6 +2419,16 @@ void CRobotMain::AbortMovie()
 }
 
 
+std::string TimeFormat(float time)
+{
+    int minutes = static_cast<int>(floor(time/60));
+    double time2 = fmod(time, 60);
+    double seconds;
+    double fraction = modf(time2, &seconds)*100;
+    std::ostringstream sstream;
+    sstream << std::setfill('0') << std::setw(2) << minutes << ":" << std::setfill('0') << std::setw(2) << floor(seconds) << "." << std::setfill('0') << std::setw(2) << floor(fraction);
+    return sstream.str();
+}
 
 //! Updates the text information
 void CRobotMain::UpdateInfoText()
diff --git a/src/object/auto/autolabo.cpp b/src/object/auto/autolabo.cpp
index 45375ba..0fb087d 100644
--- a/src/object/auto/autolabo.cpp
+++ b/src/object/auto/autolabo.cpp
@@ -21,7 +21,6 @@
 #include "object/auto/autolabo.h"
 
 #include "common/make_unique.h"
-#include "common/misc.h"
 
 #include "level/robotmain.h"
 
diff --git a/src/ui/controls/button.cpp b/src/ui/controls/button.cpp
index 37d1ad2..ece43a8 100644
--- a/src/ui/controls/button.cpp
+++ b/src/ui/controls/button.cpp
@@ -21,7 +21,6 @@
 #include "ui/controls/button.h"
 
 #include "common/event.h"
-#include "common/misc.h"
 #include "common/restext.h"
 
 #include "graphics/engine/engine.h"
diff --git a/src/ui/controls/check.cpp b/src/ui/controls/check.cpp
index 8026243..b1b70b4 100644
--- a/src/ui/controls/check.cpp
+++ b/src/ui/controls/check.cpp
@@ -21,7 +21,6 @@
 #include "ui/controls/check.h"
 
 #include "common/event.h"
-#include "common/misc.h"
 #include "common/restext.h"
 
 #include "graphics/engine/engine.h"
diff --git a/src/ui/controls/color.cpp b/src/ui/controls/color.cpp
index b92598b..2aec2a9 100644
--- a/src/ui/controls/color.cpp
+++ b/src/ui/controls/color.cpp
@@ -21,7 +21,6 @@
 #include "ui/controls/color.h"
 
 #include "common/event.h"
-#include "common/misc.h"
 #include "common/restext.h"
 
 #include "graphics/core/device.h"
diff --git a/src/ui/controls/edit.cpp b/src/ui/controls/edit.cpp
index 9cf9d33..c881aa7 100644
--- a/src/ui/controls/edit.cpp
+++ b/src/ui/controls/edit.cpp
@@ -27,7 +27,6 @@
 
 #include "common/logger.h"
 #include "common/make_unique.h"
-#include "common/misc.h"
 
 #include "common/resources/inputstream.h"
 #include "common/resources/outputstream.h"
@@ -73,15 +72,9 @@ bool IsSpace(int character)
 
 //! Indicates whether a character is part of a word.
 
-bool IsWord(int character)
+bool IsWord(char c)
 {
-    char    c;
-
-    c = tolower(GetNoAccent(character));
-
-    return ( (c >= 'a' && c <= 'z') ||
-             (c >= '0' && c <= '9') ||
-             c == '_' );
+    return ( isalnum(c) || c == '_');
 }
 
 //! Indicates whether a character is a word separator.
@@ -2920,13 +2913,13 @@ bool CEdit::MinMaj(bool bMaj)
 
     c1 = m_cursor1;
     c2 = m_cursor2;
-    if ( c1 > c2 )  Math::Swap(c1, c2);  // alwyas c1 <= c2
+    if ( c1 > c2 )  Math::Swap(c1, c2);  // always c1 <= c2
 
     for ( i=c1 ; i<c2 ; i++ )
     {
         character = static_cast<unsigned char>(m_text[i]);
-        if ( bMaj )  character = GetToUpper(character);
-        else         character = GetToLower(character);
+        if ( bMaj )  character = toupper(character);
+        else         character = tolower(character);
         m_text[i] = character;
     }
 
diff --git a/src/ui/controls/editvalue.cpp b/src/ui/controls/editvalue.cpp
index d8e2af7..cb3d5bb 100644
--- a/src/ui/controls/editvalue.cpp
+++ b/src/ui/controls/editvalue.cpp
@@ -22,7 +22,6 @@
 
 #include "common/event.h"
 #include "common/make_unique.h"
-#include "common/misc.h"
 
 #include "level/robotmain.h"
 
diff --git a/src/ui/controls/group.cpp b/src/ui/controls/group.cpp
index b45b99d..0f7c8c9 100644
--- a/src/ui/controls/group.cpp
+++ b/src/ui/controls/group.cpp
@@ -21,7 +21,6 @@
 #include "ui/controls/group.h"
 
 #include "common/event.h"
-#include "common/misc.h"
 #include "common/restext.h"
 
 #include "graphics/engine/engine.h"
diff --git a/src/ui/controls/image.cpp b/src/ui/controls/image.cpp
index 41b7a1e..ea365b7 100644
--- a/src/ui/controls/image.cpp
+++ b/src/ui/controls/image.cpp
@@ -21,7 +21,6 @@
 #include "ui/controls/image.h"
 
 #include "common/event.h"
-#include "common/misc.h"
 #include "common/restext.h"
 
 #include "graphics/engine/engine.h"
diff --git a/src/ui/controls/scroll.cpp b/src/ui/controls/scroll.cpp
index e020589..256a67b 100644
--- a/src/ui/controls/scroll.cpp
+++ b/src/ui/controls/scroll.cpp
@@ -22,7 +22,6 @@
 
 #include "common/event.h"
 #include "common/make_unique.h"
-#include "common/misc.h"
 
 #include "graphics/engine/engine.h"
 
diff --git a/src/ui/controls/shortcut.cpp b/src/ui/controls/shortcut.cpp
index 480da37..ef4f543 100644
--- a/src/ui/controls/shortcut.cpp
+++ b/src/ui/controls/shortcut.cpp
@@ -21,7 +21,6 @@
 #include "ui/controls/shortcut.h"
 
 #include "common/event.h"
-#include "common/misc.h"
 
 #include "graphics/core/device.h"
 
diff --git a/src/ui/controls/slider.cpp b/src/ui/controls/slider.cpp
index eecb472..6a85178 100644
--- a/src/ui/controls/slider.cpp
+++ b/src/ui/controls/slider.cpp
@@ -21,7 +21,6 @@
 #include "ui/controls/slider.h"
 
 #include "common/event.h"
-#include "common/misc.h"
 #include "common/stringutils.h"
 
 #include "graphics/engine/engine.h"
diff --git a/src/ui/displayinfo.cpp b/src/ui/displayinfo.cpp
index 0b9c1bd..325a16a 100644
--- a/src/ui/displayinfo.cpp
+++ b/src/ui/displayinfo.cpp
@@ -23,7 +23,6 @@
 #include "app/app.h"
 #include "app/pausemanager.h"
 
-#include "common/misc.h"
 #include "common/restext.h"
 #include "common/settings.h"
 #include "common/stringutils.h"
diff --git a/src/ui/screen/screen_io.cpp b/src/ui/screen/screen_io.cpp
index 19fc79d..52e62ee 100644
--- a/src/ui/screen/screen_io.cpp
+++ b/src/ui/screen/screen_io.cpp
@@ -20,7 +20,6 @@
 #include "ui/screen/screen_io.h"
 
 #include "common/logger.h"
-#include "common/misc.h"
 #include "common/restext.h"
 #include "common/stringutils.h"
 
diff --git a/src/ui/screen/screen_player_select.cpp b/src/ui/screen/screen_player_select.cpp
index f4f30c9..9c707d7 100644
--- a/src/ui/screen/screen_player_select.cpp
+++ b/src/ui/screen/screen_player_select.cpp
@@ -22,7 +22,6 @@
 #include "app/app.h"
 
 #include "common/logger.h"
-#include "common/misc.h"
 #include "common/stringutils.h"
 
 #include "level/player_profile.h"
@@ -388,30 +387,6 @@ bool CScreenPlayerSelect::NameCreate()
         return false;
     }
 
-    len = strlen(name);
-    j = 0;
-    for ( i=0 ; i<len ; i++ )
-    {
-        c = GetNoAccent(GetToLower(name[i]));
-        if ( (c >= '0' && c <= '9') ||
-             (c >= 'a' && c <= 'z') ||
-             c == ' ' ||
-             c == '-' ||
-             c == '_' ||
-             c == '.' ||
-             c == ',' ||
-             c == '\'' )
-        {
-            name[j++] = name[i];
-        }
-    }
-    name[j] = 0;
-    if ( j == 0 )
-    {
-        m_sound->Play(SOUND_TZOING);
-        return false;
-    }
-
     m_main->SelectPlayer(name);
     m_main->GetPlayerProfile()->Create();
 
diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp
index ff34ea4..b07b631 100644
--- a/src/ui/studio.cpp
+++ b/src/ui/studio.cpp
@@ -25,7 +25,6 @@
 
 #include "common/event.h"
 #include "common/logger.h"
-#include "common/misc.h"
 #include "common/settings.h"
 
 #include "common/resources/resourcemanager.h"
@@ -425,15 +424,9 @@ bool CStudio::EventFrame(const Event &event)
 
 // Indicates whether a character is part of a word.
 
-bool IsToken(int character)
+bool IsToken(char c)
 {
-    char    c;
-
-    c = tolower(GetNoAccent(character));
-
-    return ( (c >= 'a' && c <= 'z') ||
-             (c >= '0' && c <= '9') ||
-             c == '_' );
+    return ( isalnum(c) || c == '_' );
 }
 
 // Seeks if the cursor is on a keyword.

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git



More information about the Pkg-games-commits mailing list