Endianness detection cleanup
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4446 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
3c675b3206
commit
ef7beff5af
@ -329,6 +329,7 @@ supertuxkart_SOURCES = \
|
||||
tracks/track_object_manager.cpp \
|
||||
tracks/track_object_manager.hpp \
|
||||
utils/constants.hpp \
|
||||
utils/constants.cpp \
|
||||
utils/coord.hpp \
|
||||
utils/no_copy.hpp \
|
||||
utils/ptr_vector.hpp \
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include "audio/sound_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "utils/constants.hpp"
|
||||
|
||||
MusicOggStream::MusicOggStream()
|
||||
{
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "config/user_config.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
#include "utils/constants.hpp"
|
||||
|
||||
SFXManager* sfx_manager= NULL;
|
||||
|
||||
|
@ -39,18 +39,6 @@
|
||||
SoundManager* sound_manager= NULL;
|
||||
|
||||
|
||||
// the ogg loader needs to know about endianness so do a simple test.
|
||||
// 0 : little endian
|
||||
// 1 : big endian
|
||||
// I'm doing it at runtime rather than at compile-time to be friendly with
|
||||
// cross-compilation (universal binaries on mac, namely)
|
||||
static const int endianness_test = 0x01000000;
|
||||
static const char* endianness_test_ptr = (const char*)&endianness_test;
|
||||
|
||||
// in little-endian, byte 0 will be 0. in big endian, byte 0 will be 1
|
||||
bool IS_LITTLE_ENDIAN = (endianness_test_ptr[0] == 0);
|
||||
|
||||
|
||||
SoundManager::SoundManager()
|
||||
{
|
||||
m_current_music= NULL;
|
||||
|
@ -31,8 +31,6 @@
|
||||
|
||||
class Vec3;
|
||||
|
||||
extern bool IS_LITTLE_ENDIAN;
|
||||
|
||||
class SoundManager
|
||||
{
|
||||
private:
|
||||
|
@ -241,6 +241,7 @@
|
||||
9551CBD70FC1BB7600DB481B /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 95F423120E26E3DC00692113 /* OpenGL.framework */; };
|
||||
9551CBDA0FC1BB9200DB481B /* AGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9551CBD90FC1BB9200DB481B /* AGL.framework */; };
|
||||
9551DB34104CABFC001C53E5 /* race_over_dialog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9551DB33104CABFC001C53E5 /* race_over_dialog.cpp */; };
|
||||
9553823A10FD4FEC00737979 /* constants.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9553823910FD4FEC00737979 /* constants.cpp */; };
|
||||
955DE88310042701006A4F3C /* check_manager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 955DE88110042701006A4F3C /* check_manager.cpp */; };
|
||||
955DE88C1004273B006A4F3C /* check_structure.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 955DE8871004273B006A4F3C /* check_structure.cpp */; };
|
||||
956541BB10DD5F0A00C83E99 /* arenas_screen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 956541B910DD5F0A00C83E99 /* arenas_screen.cpp */; };
|
||||
@ -429,6 +430,7 @@
|
||||
9551CBD90FC1BB9200DB481B /* AGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AGL.framework; path = /System/Library/Frameworks/AGL.framework; sourceTree = "<absolute>"; };
|
||||
9551DB32104CABFC001C53E5 /* race_over_dialog.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = race_over_dialog.hpp; path = ../../states_screens/dialogs/race_over_dialog.hpp; sourceTree = SOURCE_ROOT; };
|
||||
9551DB33104CABFC001C53E5 /* race_over_dialog.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = race_over_dialog.cpp; path = ../../states_screens/dialogs/race_over_dialog.cpp; sourceTree = SOURCE_ROOT; };
|
||||
9553823910FD4FEC00737979 /* constants.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = constants.cpp; path = ../../utils/constants.cpp; sourceTree = SOURCE_ROOT; };
|
||||
955DE88110042701006A4F3C /* check_manager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = check_manager.cpp; path = ../../tracks/check_manager.cpp; sourceTree = SOURCE_ROOT; };
|
||||
955DE88210042701006A4F3C /* check_manager.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = check_manager.hpp; path = ../../tracks/check_manager.hpp; sourceTree = SOURCE_ROOT; };
|
||||
955DE8871004273B006A4F3C /* check_structure.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = check_structure.cpp; path = ../../tracks/check_structure.cpp; sourceTree = SOURCE_ROOT; };
|
||||
@ -2007,16 +2009,17 @@
|
||||
95C2B1DF0F296546000D3E5D /* utils */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
953EAAB50F30A4650000D57D /* translation.cpp */,
|
||||
953EAAB40F30A4650000D57D /* translation.hpp */,
|
||||
9553823910FD4FEC00737979 /* constants.cpp */,
|
||||
95C2B1E00F296546000D3E5D /* constants.hpp */,
|
||||
95C2B1E10F296546000D3E5D /* coord.hpp */,
|
||||
9540E2570FD5F8FD002985B8 /* no_copy.hpp */,
|
||||
9540E2560FD5F8FD002985B8 /* ptr_vector.hpp */,
|
||||
95C2B1E20F296546000D3E5D /* random_generator.cpp */,
|
||||
95C2B1E30F296546000D3E5D /* random_generator.hpp */,
|
||||
95C2B1E60F296546000D3E5D /* string_utils.cpp */,
|
||||
95C2B1E70F296546000D3E5D /* string_utils.hpp */,
|
||||
9540E2560FD5F8FD002985B8 /* ptr_vector.hpp */,
|
||||
9540E2570FD5F8FD002985B8 /* no_copy.hpp */,
|
||||
953EAAB50F30A4650000D57D /* translation.cpp */,
|
||||
953EAAB40F30A4650000D57D /* translation.hpp */,
|
||||
95C2B1E80F296546000D3E5D /* vec3.cpp */,
|
||||
95C2B1E90F296546000D3E5D /* vec3.hpp */,
|
||||
);
|
||||
@ -2588,6 +2591,7 @@
|
||||
95C9C97210E93456005A418D /* stars.cpp in Sources */,
|
||||
959482D310EBC0790031BADF /* track_object_manager.cpp in Sources */,
|
||||
959482D410EBC0790031BADF /* track_object.cpp in Sources */,
|
||||
9553823A10FD4FEC00737979 /* constants.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
27
src/utils/constants.cpp
Normal file
27
src/utils/constants.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
//
|
||||
// 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, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
// for code that needs to know about endianness so do a simple test.
|
||||
// 0 : little endian
|
||||
// 1 : big endian
|
||||
// I'm doing it at runtime rather than at compile-time to be friendly with
|
||||
// cross-compilation (universal binaries on mac, namely)
|
||||
static const int endianness_test = 0x01000000;
|
||||
static const char* endianness_test_ptr = (const char*)&endianness_test;
|
||||
|
||||
// in little-endian, byte 0 will be 0. in big endian, byte 0 will be 1
|
||||
bool IS_LITTLE_ENDIAN = (endianness_test_ptr[0] == 0);
|
@ -49,5 +49,7 @@
|
||||
|
||||
const int MAX_PLAYER_COUNT = 4;
|
||||
|
||||
extern int IS_LITTLE_ENDIAN;
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -37,11 +37,11 @@
|
||||
#include "irrlicht.h"
|
||||
|
||||
#include "io/file_manager.hpp"
|
||||
#include "utils/constants.hpp"
|
||||
|
||||
// set to 1 to debug i18n
|
||||
#define TRANSLATE_VERBOSE 0
|
||||
|
||||
|
||||
Translations* translations=NULL;
|
||||
bool remove_bom = false;
|
||||
|
||||
@ -62,7 +62,8 @@ Translations::Translations()
|
||||
if (sizeof(wchar_t) == 4)
|
||||
{
|
||||
// FIXME: will probably not work on PPC maccs
|
||||
bind_textdomain_codeset(PACKAGE, "UTF-32LE");
|
||||
if (IS_LITTLE_ENDIAN) bind_textdomain_codeset(PACKAGE, "UTF-32LE");
|
||||
else bind_textdomain_codeset(PACKAGE, "UTF-32BE");
|
||||
}
|
||||
else if (sizeof(wchar_t) == 2)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user