From fa4b6e00fd204998f6011420bdad60477b7a2f12 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Wed, 13 Apr 2016 08:47:41 -0400 Subject: parentheses --- Changelog | 8 + include/common.hpp | 4 +- include/config.hpp | 6 +- include/entities.hpp | 12 +- include/freetype/config/ftconfig.h | 116 +-- include/freetype/config/ftmodule.h | 40 +- include/freetype/config/ftoption.h | 14 +- include/freetype/config/ftstdlib.h | 2 +- include/freetype/freetype.h | 468 ++++++------ include/freetype/ftadvanc.h | 12 +- include/freetype/ftautoh.h | 26 +- include/freetype/ftbbox.h | 6 +- include/freetype/ftbdf.h | 12 +- include/freetype/ftbitmap.h | 30 +- include/freetype/ftbzip2.h | 6 +- include/freetype/ftcache.h | 96 +-- include/freetype/ftcffdrv.h | 18 +- include/freetype/ftcid.h | 16 +- include/freetype/fterrdef.h | 366 ++++----- include/freetype/fterrors.h | 16 +- include/freetype/ftgasp.h | 6 +- include/freetype/ftglyph.h | 74 +- include/freetype/ftgxval.h | 60 +- include/freetype/ftgzip.h | 12 +- include/freetype/ftimage.h | 74 +- include/freetype/ftincrem.h | 16 +- include/freetype/ftlcdfil.h | 12 +- include/freetype/ftlist.h | 50 +- include/freetype/ftlzw.h | 6 +- include/freetype/ftmac.h | 40 +- include/freetype/ftmm.h | 36 +- include/freetype/ftmodapi.h | 72 +- include/freetype/ftmoderr.h | 70 +- include/freetype/ftotval.h | 12 +- include/freetype/ftoutln.h | 96 +-- include/freetype/ftpfr.h | 18 +- include/freetype/ftrender.h | 50 +- include/freetype/ftsizes.h | 14 +- include/freetype/ftsnames.h | 14 +- include/freetype/ftstroke.h | 98 +-- include/freetype/ftsynth.h | 8 +- include/freetype/ftsystem.h | 18 +- include/freetype/fttrigon.h | 60 +- include/freetype/ftttdrv.h | 6 +- include/freetype/fttypes.h | 32 +- include/freetype/ftwinfnt.h | 6 +- include/freetype/ftxf86.h | 4 +- include/freetype/t1tables.h | 22 +- include/freetype/ttnameid.h | 2 +- include/freetype/tttables.h | 40 +- include/freetype/tttags.h | 136 ++-- include/freetype/ttunpat.h | 2 +- include/texture.hpp | 2 +- include/tinyxml2.h | 780 +++++++++---------- include/ui.hpp | 8 +- include/ui_menu.hpp | 2 +- include/world.hpp | 105 ++- main.cpp | 236 ++---- setup.mk | 2 +- src/common.cpp | 4 +- src/config.cpp | 8 +- src/entities.cpp | 109 +-- src/gameplay.cpp | 16 +- src/inventory.cpp | 94 +-- src/quest.cpp | 38 +- src/texture.cpp | 12 +- src/tinyxml2.cpp | 1470 ++++++++++++++++++------------------ src/ui.cpp | 218 +++--- src/ui_menu.cpp | 8 +- src/world.cpp | 867 +++++++++++---------- 70 files changed, 3188 insertions(+), 3231 deletions(-) diff --git a/Changelog b/Changelog index 18d2efe..e73cd10 100644 --- a/Changelog +++ b/Changelog @@ -910,3 +910,11 @@ - potentially fixed inventory drawing bug - moved menu library to its own file + +4/13/2016: +========== + + - began making the world great again + - adopted indent style: linuxxxx kernel + - began converting pointers to better things + - parentheses diff --git a/include/common.hpp b/include/common.hpp index a62d75a..65ac47b 100644 --- a/include/common.hpp +++ b/include/common.hpp @@ -46,7 +46,7 @@ typedef unsigned int uint; * Defines how many milliseconds each game tick will take. */ -#define MSEC_PER_TICK ( 1000 / TICKS_PER_SEC ) +#define MSEC_PER_TICK (1000 / TICKS_PER_SEC) //#define SEGFAULT @@ -192,7 +192,7 @@ extern float VOLUME_SFX; * DEBUG must be defined for this macro to function. */ -#define DEBUG_printf( message, ...) DEBUG_prints(__FILE__, __LINE__, message, __VA_ARGS__ ) +#define DEBUG_printf(message, ...) DEBUG_prints(__FILE__, __LINE__, message, __VA_ARGS__) #ifdef SEGFAULT #define C(x) std::cout << m << std::endl diff --git a/include/config.hpp b/include/config.hpp index d003c66..8bd0bc9 100644 --- a/include/config.hpp +++ b/include/config.hpp @@ -10,9 +10,9 @@ namespace config { - void read( void ); - void update( void ); - void save( void ); + void read(void); + void update(void); + void save(void); } #endif //CONFIG_H diff --git a/include/entities.hpp b/include/entities.hpp index 5ab4066..6cd5731 100644 --- a/include/entities.hpp +++ b/include/entities.hpp @@ -13,6 +13,7 @@ #define NPCp(n) ((NPC *)n) #define Structurep(n) ((Structures *)n) #define Mobp(n) ((Mob *)n) +#define Objectp(n) ((Object *)n) #define PLAYER_INV_SIZE 43 // The size of the player's inventory #define NPC_INV_SIZE 3 // Size of an NPC's inventory @@ -102,18 +103,18 @@ public: glTexCoord2f(.25*index.x, .125*index.y); glVertex2i(loc.x, loc.y + width); glEnd(); } - void update( float _gravity, float ground_y ) { + void update(float _gravity, float ground_y) { // handle ground collision - if ( loc.y < ground_y ) { + if (loc.y < ground_y) { loc.y = ground_y; - if ( bounce ) { + if (bounce) { vel.y *= -0.2f; vel.x /= 4; } else { vel.x = vel.y = 0; canMove = false; } - } else if ( gravity && vel.y > -1 ) + } else if (gravity && vel.y > -1) vel.y -= _gravity * deltaTime; } bool kill(float delta){ @@ -188,6 +189,9 @@ public: void follow(Entity *e); + bool isNear(Entity e); + bool isInside(vec2 coord) const; + virtual ~Entity(){} }; diff --git a/include/freetype/config/ftconfig.h b/include/freetype/config/ftconfig.h index 11d5d95..c35053f 100644 --- a/include/freetype/config/ftconfig.h +++ b/include/freetype/config/ftconfig.h @@ -121,7 +121,7 @@ FT_BEGIN_HEADER /* FT_UNUSED is a macro used to indicate that a given parameter is not */ /* used -- this is only used to get rid of unpleasant compiler warnings */ #ifndef FT_UNUSED -#define FT_UNUSED( arg ) ( (arg) = (arg) ) +#define FT_UNUSED(arg) ((arg) = (arg)) #endif @@ -143,7 +143,7 @@ FT_BEGIN_HEADER /* This is the only necessary change, so it is defined here instead */ /* providing a new configuration file. */ /* */ -#if defined( __APPLE__ ) || ( defined( __MWERKS__ ) && defined( macintosh ) ) +#if defined(__APPLE__) || (defined(__MWERKS__) && defined(macintosh)) /* no Carbon frameworks for 64bit 10.4.x */ /* AvailabilityMacros.h is available since Mac OS X 10.2, */ /* so guess the system version by maximum errno before inclusion */ @@ -151,12 +151,12 @@ FT_BEGIN_HEADER #ifdef ECANCELED /* defined since 10.2 */ #include "AvailabilityMacros.h" #endif -#if defined( __LP64__ ) && \ - ( MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 ) +#if defined(__LP64__) && \ + (MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4) #undef FT_MACINTOSH #endif -#elif defined( __SC__ ) || defined( __MRC__ ) +#elif defined(__SC__) || defined(__MRC__) /* Classic MacOS compilers */ #include "ConditionalMacros.h" #if TARGET_OS_MAC @@ -167,8 +167,8 @@ FT_BEGIN_HEADER /* Fix compiler warning with sgi compiler */ -#if defined( __sgi ) && !defined( __GNUC__ ) -#if defined( _COMPILER_VERSION ) && ( _COMPILER_VERSION >= 730 ) +#if defined(__sgi) && !defined(__GNUC__) +#if defined(_COMPILER_VERSION) && (_COMPILER_VERSION >= 730) #pragma set woff 3505 #endif #endif @@ -297,14 +297,14 @@ FT_BEGIN_HEADER #define FT_INT64 long #define FT_UINT64 unsigned long -#elif defined( _MSC_VER ) && _MSC_VER >= 900 /* Visual C++ (and Intel C++) */ +#elif defined(_MSC_VER) && _MSC_VER >= 900 /* Visual C++ (and Intel C++) */ /* this compiler provides the __int64 type */ #define FT_LONG64 #define FT_INT64 __int64 #define FT_UINT64 unsigned __int64 -#elif defined( __BORLANDC__ ) /* Borland C++ */ +#elif defined(__BORLANDC__) /* Borland C++ */ /* XXXX: We should probably check the value of __BORLANDC__ in order */ /* to test the compiler version. */ @@ -314,17 +314,17 @@ FT_BEGIN_HEADER #define FT_INT64 __int64 #define FT_UINT64 unsigned __int64 -#elif defined( __WATCOMC__ ) /* Watcom C++ */ +#elif defined(__WATCOMC__) /* Watcom C++ */ /* Watcom doesn't provide 64-bit data types */ -#elif defined( __MWERKS__ ) /* Metrowerks CodeWarrior */ +#elif defined(__MWERKS__) /* Metrowerks CodeWarrior */ #define FT_LONG64 #define FT_INT64 long long int #define FT_UINT64 unsigned long long int -#elif defined( __GNUC__ ) +#elif defined(__GNUC__) /* GCC provides the `long long' type */ #define FT_LONG64 @@ -341,7 +341,7 @@ FT_BEGIN_HEADER /* is defined. You can however ignore this rule by defining the */ /* FT_CONFIG_OPTION_FORCE_INT64 configuration macro. */ /* */ -#if defined( FT_LONG64 ) && !defined( FT_CONFIG_OPTION_FORCE_INT64 ) +#if defined(FT_LONG64) && !defined(FT_CONFIG_OPTION_FORCE_INT64) #ifdef __STDC__ @@ -363,7 +363,7 @@ FT_BEGIN_HEADER #define FT_BEGIN_STMNT do { -#define FT_END_STMNT } while ( 0 ) +#define FT_END_STMNT } while (0) #define FT_DUMMY_STMNT FT_BEGIN_STMNT FT_END_STMNT @@ -371,15 +371,15 @@ FT_BEGIN_HEADER /* Provide assembler fragments for performance-critical functions. */ /* These must be defined `static __inline__' with GCC. */ -#if defined( __CC_ARM ) || defined( __ARMCC__ ) /* RVCT */ +#if defined(__CC_ARM) || defined(__ARMCC__) /* RVCT */ #define FT_MULFIX_ASSEMBLER FT_MulFix_arm /* documentation is in freetype.h */ static __inline FT_Int32 - FT_MulFix_arm( FT_Int32 a, - FT_Int32 b ) + FT_MulFix_arm(FT_Int32 a, + FT_Int32 b) { register FT_Int32 t, t2; @@ -402,17 +402,17 @@ FT_BEGIN_HEADER #ifdef __GNUC__ -#if defined( __arm__ ) && \ - ( !defined( __thumb__ ) || defined( __thumb2__ ) ) && \ - !( defined( __CC_ARM ) || defined( __ARMCC__ ) ) +#if defined(__arm__) && \ + (!defined(__thumb__) || defined(__thumb2__)) && \ + !(defined(__CC_ARM) || defined(__ARMCC__)) #define FT_MULFIX_ASSEMBLER FT_MulFix_arm /* documentation is in freetype.h */ static __inline__ FT_Int32 - FT_MulFix_arm( FT_Int32 a, - FT_Int32 b ) + FT_MulFix_arm(FT_Int32 a, + FT_Int32 b) { register FT_Int32 t, t2; @@ -431,24 +431,24 @@ FT_BEGIN_HEADER "orr %0, %0, %2, lsl #16\n\t" /* %0 |= %2 << 16 */ : "=r"(a), "=&r"(t2), "=&r"(t) : "r"(a), "r"(b) - : "cc" ); + : "cc"); return a; } #endif /* __arm__ && */ - /* ( __thumb2__ || !__thumb__ ) && */ - /* !( __CC_ARM || __ARMCC__ ) */ + /* (__thumb2__ || !__thumb__) && */ + /* !(__CC_ARM || __ARMCC__) */ -#if defined( __i386__ ) +#if defined(__i386__) #define FT_MULFIX_ASSEMBLER FT_MulFix_i386 /* documentation is in freetype.h */ static __inline__ FT_Int32 - FT_MulFix_i386( FT_Int32 a, - FT_Int32 b ) + FT_MulFix_i386(FT_Int32 a, + FT_Int32 b) { register FT_Int32 result; @@ -465,7 +465,7 @@ FT_BEGIN_HEADER "addl %%edx, %%eax\n" : "=a"(result), "=d"(b) : "a"(a), "d"(b) - : "%ecx", "cc" ); + : "%ecx", "cc"); return result; } @@ -483,8 +483,8 @@ FT_BEGIN_HEADER /* documentation is in freetype.h */ static __inline FT_Int32 - FT_MulFix_i386( FT_Int32 a, - FT_Int32 b ) + FT_MulFix_i386(FT_Int32 a, + FT_Int32 b) { register FT_Int32 result; @@ -511,17 +511,17 @@ FT_BEGIN_HEADER #endif /* _MSC_VER */ -#if defined( __GNUC__ ) && defined( __x86_64__ ) +#if defined(__GNUC__) && defined(__x86_64__) #define FT_MULFIX_ASSEMBLER FT_MulFix_x86_64 static __inline__ FT_Int32 - FT_MulFix_x86_64( FT_Int32 a, - FT_Int32 b ) + FT_MulFix_x86_64(FT_Int32 a, + FT_Int32 b) { /* Temporarily disable the warning that C90 doesn't support */ /* `long long'. */ -#if ( __GNUC__ > 4 ) || ( ( __GNUC__ == 4 ) && ( __GNUC_MINOR__ >= 6 ) ) +#if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wlong-long" #endif @@ -536,7 +536,7 @@ FT_BEGIN_HEADER tmp = ret >> 63; ret += 0x8000 + tmp; - return (FT_Int32)( ret >> 16 ); + return (FT_Int32)(ret >> 16); #else /* For some reason, GCC 4.6 on Ubuntu 12.04 generates invalid machine */ @@ -558,12 +558,12 @@ FT_BEGIN_HEADER "sar $16, %0\n" : "=&r"(result), "=&r"(wide_a) : "r"(wide_b) - : "cc" ); + : "cc"); return (FT_Int32)result; #endif -#if ( __GNUC__ > 4 ) || ( ( __GNUC__ == 4 ) && ( __GNUC_MINOR__ >= 6 ) ) +#if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) #pragma GCC diagnostic pop #endif } @@ -582,31 +582,31 @@ FT_BEGIN_HEADER #ifdef FT_MAKE_OPTION_SINGLE_OBJECT -#define FT_LOCAL( x ) static x -#define FT_LOCAL_DEF( x ) static x +#define FT_LOCAL(x) static x +#define FT_LOCAL_DEF(x) static x #else #ifdef __cplusplus -#define FT_LOCAL( x ) extern "C" x -#define FT_LOCAL_DEF( x ) extern "C" x +#define FT_LOCAL(x) extern "C" x +#define FT_LOCAL_DEF(x) extern "C" x #else -#define FT_LOCAL( x ) extern x -#define FT_LOCAL_DEF( x ) x +#define FT_LOCAL(x) extern x +#define FT_LOCAL_DEF(x) x #endif #endif /* FT_MAKE_OPTION_SINGLE_OBJECT */ -#define FT_LOCAL_ARRAY( x ) extern const x -#define FT_LOCAL_ARRAY_DEF( x ) const x +#define FT_LOCAL_ARRAY(x) extern const x +#define FT_LOCAL_ARRAY_DEF(x) const x #ifndef FT_BASE #ifdef __cplusplus -#define FT_BASE( x ) extern "C" x +#define FT_BASE(x) extern "C" x #else -#define FT_BASE( x ) extern x +#define FT_BASE(x) extern x #endif #endif /* !FT_BASE */ @@ -615,9 +615,9 @@ FT_BEGIN_HEADER #ifndef FT_BASE_DEF #ifdef __cplusplus -#define FT_BASE_DEF( x ) x +#define FT_BASE_DEF(x) x #else -#define FT_BASE_DEF( x ) x +#define FT_BASE_DEF(x) x #endif #endif /* !FT_BASE_DEF */ @@ -626,9 +626,9 @@ FT_BEGIN_HEADER #ifndef FT_EXPORT #ifdef __cplusplus -#define FT_EXPORT( x ) extern "C" x +#define FT_EXPORT(x) extern "C" x #else -#define FT_EXPORT( x ) extern x +#define FT_EXPORT(x) extern x #endif #endif /* !FT_EXPORT */ @@ -637,9 +637,9 @@ FT_BEGIN_HEADER #ifndef FT_EXPORT_DEF #ifdef __cplusplus -#define FT_EXPORT_DEF( x ) extern "C" x +#define FT_EXPORT_DEF(x) extern "C" x #else -#define FT_EXPORT_DEF( x ) extern x +#define FT_EXPORT_DEF(x) extern x #endif #endif /* !FT_EXPORT_DEF */ @@ -648,9 +648,9 @@ FT_BEGIN_HEADER #ifndef FT_EXPORT_VAR #ifdef __cplusplus -#define FT_EXPORT_VAR( x ) extern "C" x +#define FT_EXPORT_VAR(x) extern "C" x #else -#define FT_EXPORT_VAR( x ) extern x +#define FT_EXPORT_VAR(x) extern x #endif #endif /* !FT_EXPORT_VAR */ @@ -680,9 +680,9 @@ FT_BEGIN_HEADER /* */ #ifndef FT_CALLBACK_DEF #ifdef __cplusplus -#define FT_CALLBACK_DEF( x ) extern "C" x +#define FT_CALLBACK_DEF(x) extern "C" x #else -#define FT_CALLBACK_DEF( x ) static x +#define FT_CALLBACK_DEF(x) static x #endif #endif /* FT_CALLBACK_DEF */ diff --git a/include/freetype/config/ftmodule.h b/include/freetype/config/ftmodule.h index d1b938b..2933775 100644 --- a/include/freetype/config/ftmodule.h +++ b/include/freetype/config/ftmodule.h @@ -1,22 +1,22 @@ /* This is a generated file. */ -FT_USE_MODULE( FT_Driver_ClassRec, tt_driver_class ) -FT_USE_MODULE( FT_Driver_ClassRec, t1_driver_class ) -FT_USE_MODULE( FT_Driver_ClassRec, cff_driver_class ) -FT_USE_MODULE( FT_Driver_ClassRec, t1cid_driver_class ) -FT_USE_MODULE( FT_Driver_ClassRec, pfr_driver_class ) -FT_USE_MODULE( FT_Driver_ClassRec, t42_driver_class ) -FT_USE_MODULE( FT_Driver_ClassRec, winfnt_driver_class ) -FT_USE_MODULE( FT_Driver_ClassRec, pcf_driver_class ) -FT_USE_MODULE( FT_Driver_ClassRec, bdf_driver_class ) -FT_USE_MODULE( FT_Module_Class, sfnt_module_class ) -FT_USE_MODULE( FT_Module_Class, autofit_module_class ) -FT_USE_MODULE( FT_Module_Class, pshinter_module_class ) -FT_USE_MODULE( FT_Renderer_Class, ft_raster1_renderer_class ) -FT_USE_MODULE( FT_Renderer_Class, ft_smooth_renderer_class ) -FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcd_renderer_class ) -FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcdv_renderer_class ) -FT_USE_MODULE( FT_Module_Class, gxv_module_class ) -FT_USE_MODULE( FT_Module_Class, otv_module_class ) -FT_USE_MODULE( FT_Module_Class, psaux_module_class ) -FT_USE_MODULE( FT_Module_Class, psnames_module_class ) +FT_USE_MODULE(FT_Driver_ClassRec, tt_driver_class) +FT_USE_MODULE(FT_Driver_ClassRec, t1_driver_class) +FT_USE_MODULE(FT_Driver_ClassRec, cff_driver_class) +FT_USE_MODULE(FT_Driver_ClassRec, t1cid_driver_class) +FT_USE_MODULE(FT_Driver_ClassRec, pfr_driver_class) +FT_USE_MODULE(FT_Driver_ClassRec, t42_driver_class) +FT_USE_MODULE(FT_Driver_ClassRec, winfnt_driver_class) +FT_USE_MODULE(FT_Driver_ClassRec, pcf_driver_class) +FT_USE_MODULE(FT_Driver_ClassRec, bdf_driver_class) +FT_USE_MODULE(FT_Module_Class, sfnt_module_class) +FT_USE_MODULE(FT_Module_Class, autofit_module_class) +FT_USE_MODULE(FT_Module_Class, pshinter_module_class) +FT_USE_MODULE(FT_Renderer_Class, ft_raster1_renderer_class) +FT_USE_MODULE(FT_Renderer_Class, ft_smooth_renderer_class) +FT_USE_MODULE(FT_Renderer_Class, ft_smooth_lcd_renderer_class) +FT_USE_MODULE(FT_Renderer_Class, ft_smooth_lcdv_renderer_class) +FT_USE_MODULE(FT_Module_Class, gxv_module_class) +FT_USE_MODULE(FT_Module_Class, otv_module_class) +FT_USE_MODULE(FT_Module_Class, psaux_module_class) +FT_USE_MODULE(FT_Module_Class, psnames_module_class) /* EOF */ diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h index 84eb8d0..87b0e1d 100644 --- a/include/freetype/config/ftoption.h +++ b/include/freetype/config/ftoption.h @@ -239,20 +239,20 @@ FT_BEGIN_HEADER /* Two macros are used within the FreeType source code to define */ /* exported library functions: FT_EXPORT and FT_EXPORT_DEF. */ /* */ - /* FT_EXPORT( return_type ) */ + /* FT_EXPORT(return_type) */ /* */ /* is used in a function declaration, as in */ /* */ - /* FT_EXPORT( FT_Error ) */ - /* FT_Init_FreeType( FT_Library* alibrary ); */ + /* FT_EXPORT(FT_Error) */ + /* FT_Init_FreeType(FT_Library* alibrary); */ /* */ /* */ - /* FT_EXPORT_DEF( return_type ) */ + /* FT_EXPORT_DEF(return_type) */ /* */ /* is used in a function definition, as in */ /* */ - /* FT_EXPORT_DEF( FT_Error ) */ - /* FT_Init_FreeType( FT_Library* alibrary ) */ + /* FT_EXPORT_DEF(FT_Error) */ + /* FT_Init_FreeType(FT_Library* alibrary) */ /* { */ /* ... some code ... */ /* return FT_Err_Ok; */ @@ -637,7 +637,7 @@ FT_BEGIN_HEADER /* open_args.num_params = 1; */ /* open_args.params = ¶meter; */ /* */ - /* error = FT_Open_Face( library, &open_args, index, &face ); */ + /* error = FT_Open_Face(library, &open_args, index, &face); */ /* ... */ /* } */ /* */ diff --git a/include/freetype/config/ftstdlib.h b/include/freetype/config/ftstdlib.h index b940efc..ae63522 100644 --- a/include/freetype/config/ftstdlib.h +++ b/include/freetype/config/ftstdlib.h @@ -159,7 +159,7 @@ /* on certain platforms */ #define ft_longjmp longjmp -#define ft_setjmp( b ) setjmp( *(ft_jmp_buf*) &(b) ) /* same thing here */ +#define ft_setjmp(b) setjmp(*(ft_jmp_buf*) &(b)) /* same thing here */ /* the following is only used for debugging purposes, i.e., if */ diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h index 39a18af..431ffb6 100644 --- a/include/freetype/freetype.h +++ b/include/freetype/freetype.h @@ -507,18 +507,18 @@ FT_BEGIN_HEADER /* this: */ /* */ /* { */ - /* #define FT_ENC_TAG( value, a, b, c, d ) value */ + /* #define FT_ENC_TAG(value, a, b, c, d) value */ /* } */ /* */ /* to get a simple enumeration without assigning special numbers. */ /* */ #ifndef FT_ENC_TAG -#define FT_ENC_TAG( value, a, b, c, d ) \ - value = ( ( (FT_UInt32)(a) << 24 ) | \ - ( (FT_UInt32)(b) << 16 ) | \ - ( (FT_UInt32)(c) << 8 ) | \ - (FT_UInt32)(d) ) +#define FT_ENC_TAG(value, a, b, c, d) \ + value = (((FT_UInt32)(a) << 24) | \ + ((FT_UInt32)(b) << 16) | \ + ((FT_UInt32)(c) << 8) | \ + (FT_UInt32)(d) ) #endif /* FT_ENC_TAG */ @@ -665,16 +665,16 @@ FT_BEGIN_HEADER /* */ typedef enum FT_Encoding_ { - FT_ENC_TAG( FT_ENCODING_NONE, 0, 0, 0, 0 ), + FT_ENC_TAG(FT_ENCODING_NONE, 0, 0, 0, 0), - FT_ENC_TAG( FT_ENCODING_MS_SYMBOL, 's', 'y', 'm', 'b' ), - FT_ENC_TAG( FT_ENCODING_UNICODE, 'u', 'n', 'i', 'c' ), + FT_ENC_TAG(FT_ENCODING_MS_SYMBOL, 's', 'y', 'm', 'b'), + FT_ENC_TAG(FT_ENCODING_UNICODE, 'u', 'n', 'i', 'c'), - FT_ENC_TAG( FT_ENCODING_SJIS, 's', 'j', 'i', 's' ), - FT_ENC_TAG( FT_ENCODING_GB2312, 'g', 'b', ' ', ' ' ), - FT_ENC_TAG( FT_ENCODING_BIG5, 'b', 'i', 'g', '5' ), - FT_ENC_TAG( FT_ENCODING_WANSUNG, 'w', 'a', 'n', 's' ), - FT_ENC_TAG( FT_ENCODING_JOHAB, 'j', 'o', 'h', 'a' ), + FT_ENC_TAG(FT_ENCODING_SJIS, 's', 'j', 'i', 's'), + FT_ENC_TAG(FT_ENCODING_GB2312, 'g', 'b', ' ', ' '), + FT_ENC_TAG(FT_ENCODING_BIG5, 'b', 'i', 'g', '5'), + FT_ENC_TAG(FT_ENCODING_WANSUNG, 'w', 'a', 'n', 's'), + FT_ENC_TAG(FT_ENCODING_JOHAB, 'j', 'o', 'h', 'a'), /* for backwards compatibility */ FT_ENCODING_MS_SJIS = FT_ENCODING_SJIS, @@ -683,14 +683,14 @@ FT_BEGIN_HEADER FT_ENCODING_MS_WANSUNG = FT_ENCODING_WANSUNG, FT_ENCODING_MS_JOHAB = FT_ENCODING_JOHAB, - FT_ENC_TAG( FT_ENCODING_ADOBE_STANDARD, 'A', 'D', 'O', 'B' ), - FT_ENC_TAG( FT_ENCODING_ADOBE_EXPERT, 'A', 'D', 'B', 'E' ), - FT_ENC_TAG( FT_ENCODING_ADOBE_CUSTOM, 'A', 'D', 'B', 'C' ), - FT_ENC_TAG( FT_ENCODING_ADOBE_LATIN_1, 'l', 'a', 't', '1' ), + FT_ENC_TAG(FT_ENCODING_ADOBE_STANDARD, 'A', 'D', 'O', 'B'), + FT_ENC_TAG(FT_ENCODING_ADOBE_EXPERT, 'A', 'D', 'B', 'E'), + FT_ENC_TAG(FT_ENCODING_ADOBE_CUSTOM, 'A', 'D', 'B', 'C'), + FT_ENC_TAG(FT_ENCODING_ADOBE_LATIN_1, 'l', 'a', 't', '1'), - FT_ENC_TAG( FT_ENCODING_OLD_LATIN_2, 'l', 'a', 't', '2' ), + FT_ENC_TAG(FT_ENCODING_OLD_LATIN_2, 'l', 'a', 't', '2'), - FT_ENC_TAG( FT_ENCODING_APPLE_ROMAN, 'a', 'r', 'm', 'n' ) + FT_ENC_TAG(FT_ENCODING_APPLE_ROMAN, 'a', 'r', 'm', 'n') } FT_Encoding; @@ -1084,27 +1084,27 @@ FT_BEGIN_HEADER /* Set if the font has color glyph tables. To access color glyphs */ /* use @FT_LOAD_COLOR. */ /* */ -#define FT_FACE_FLAG_SCALABLE ( 1L << 0 ) -#define FT_FACE_FLAG_FIXED_SIZES ( 1L << 1 ) -#define FT_FACE_FLAG_FIXED_WIDTH ( 1L << 2 ) -#define FT_FACE_FLAG_SFNT ( 1L << 3 ) -#define FT_FACE_FLAG_HORIZONTAL ( 1L << 4 ) -#define FT_FACE_FLAG_VERTICAL ( 1L << 5 ) -#define FT_FACE_FLAG_KERNING ( 1L << 6 ) -#define FT_FACE_FLAG_FAST_GLYPHS ( 1L << 7 ) -#define FT_FACE_FLAG_MULTIPLE_MASTERS ( 1L << 8 ) -#define FT_FACE_FLAG_GLYPH_NAMES ( 1L << 9 ) -#define FT_FACE_FLAG_EXTERNAL_STREAM ( 1L << 10 ) -#define FT_FACE_FLAG_HINTER ( 1L << 11 ) -#define FT_FACE_FLAG_CID_KEYED ( 1L << 12 ) -#define FT_FACE_FLAG_TRICKY ( 1L << 13 ) -#define FT_FACE_FLAG_COLOR ( 1L << 14 ) +#define FT_FACE_FLAG_SCALABLE (1L << 0) +#define FT_FACE_FLAG_FIXED_SIZES (1L << 1) +#define FT_FACE_FLAG_FIXED_WIDTH (1L << 2) +#define FT_FACE_FLAG_SFNT (1L << 3) +#define FT_FACE_FLAG_HORIZONTAL (1L << 4) +#define FT_FACE_FLAG_VERTICAL (1L << 5) +#define FT_FACE_FLAG_KERNING (1L << 6) +#define FT_FACE_FLAG_FAST_GLYPHS (1L << 7) +#define FT_FACE_FLAG_MULTIPLE_MASTERS (1L << 8) +#define FT_FACE_FLAG_GLYPH_NAMES (1L << 9) +#define FT_FACE_FLAG_EXTERNAL_STREAM (1L << 10) +#define FT_FACE_FLAG_HINTER (1L << 11) +#define FT_FACE_FLAG_CID_KEYED (1L << 12) +#define FT_FACE_FLAG_TRICKY (1L << 13) +#define FT_FACE_FLAG_COLOR (1L << 14) /************************************************************************* * * @macro: - * FT_HAS_HORIZONTAL( face ) + * FT_HAS_HORIZONTAL(face) * * @description: * A macro that returns true whenever a face object contains @@ -1114,42 +1114,42 @@ FT_BEGIN_HEADER * @FT_HAS_VERTICAL can be used to check for vertical metrics. * */ -#define FT_HAS_HORIZONTAL( face ) \ - ( face->face_flags & FT_FACE_FLAG_HORIZONTAL ) +#define FT_HAS_HORIZONTAL(face) \ + (face->face_flags & FT_FACE_FLAG_HORIZONTAL) /************************************************************************* * * @macro: - * FT_HAS_VERTICAL( face ) + * FT_HAS_VERTICAL(face) * * @description: * A macro that returns true whenever a face object contains real * vertical metrics (and not only synthesized ones). * */ -#define FT_HAS_VERTICAL( face ) \ - ( face->face_flags & FT_FACE_FLAG_VERTICAL ) +#define FT_HAS_VERTICAL(face) \ + (face->face_flags & FT_FACE_FLAG_VERTICAL) /************************************************************************* * * @macro: - * FT_HAS_KERNING( face ) + * FT_HAS_KERNING(face) * * @description: * A macro that returns true whenever a face object contains kerning * data that can be accessed with @FT_Get_Kerning. * */ -#define FT_HAS_KERNING( face ) \ - ( face->face_flags & FT_FACE_FLAG_KERNING ) +#define FT_HAS_KERNING(face) \ + (face->face_flags & FT_FACE_FLAG_KERNING) /************************************************************************* * * @macro: - * FT_IS_SCALABLE( face ) + * FT_IS_SCALABLE(face) * * @description: * A macro that returns true whenever a face object contains a scalable @@ -1157,14 +1157,14 @@ FT_BEGIN_HEADER * and PFR font formats. * */ -#define FT_IS_SCALABLE( face ) \ - ( face->face_flags & FT_FACE_FLAG_SCALABLE ) +#define FT_IS_SCALABLE(face) \ + (face->face_flags & FT_FACE_FLAG_SCALABLE) /************************************************************************* * * @macro: - * FT_IS_SFNT( face ) + * FT_IS_SFNT(face) * * @description: * A macro that returns true whenever a face object contains a font @@ -1176,14 +1176,14 @@ FT_BEGIN_HEADER * @FT_TRUETYPE_TABLES_H are available. * */ -#define FT_IS_SFNT( face ) \ - ( face->face_flags & FT_FACE_FLAG_SFNT ) +#define FT_IS_SFNT(face) \ + (face->face_flags & FT_FACE_FLAG_SFNT) /************************************************************************* * * @macro: - * FT_IS_FIXED_WIDTH( face ) + * FT_IS_FIXED_WIDTH(face) * * @description: * A macro that returns true whenever a face object contains a font face @@ -1191,14 +1191,14 @@ FT_BEGIN_HEADER * glyphs. * */ -#define FT_IS_FIXED_WIDTH( face ) \ - ( face->face_flags & FT_FACE_FLAG_FIXED_WIDTH ) +#define FT_IS_FIXED_WIDTH(face) \ + (face->face_flags & FT_FACE_FLAG_FIXED_WIDTH) /************************************************************************* * * @macro: - * FT_HAS_FIXED_SIZES( face ) + * FT_HAS_FIXED_SIZES(face) * * @description: * A macro that returns true whenever a face object contains some @@ -1206,40 +1206,40 @@ FT_BEGIN_HEADER * @FT_FaceRec structure. * */ -#define FT_HAS_FIXED_SIZES( face ) \ - ( face->face_flags & FT_FACE_FLAG_FIXED_SIZES ) +#define FT_HAS_FIXED_SIZES(face) \ + (face->face_flags & FT_FACE_FLAG_FIXED_SIZES) /************************************************************************* * * @macro: - * FT_HAS_FAST_GLYPHS( face ) + * FT_HAS_FAST_GLYPHS(face) * * @description: * Deprecated. * */ -#define FT_HAS_FAST_GLYPHS( face ) 0 +#define FT_HAS_FAST_GLYPHS(face) 0 /************************************************************************* * * @macro: - * FT_HAS_GLYPH_NAMES( face ) + * FT_HAS_GLYPH_NAMES(face) * * @description: * A macro that returns true whenever a face object contains some glyph * names that can be accessed through @FT_Get_Glyph_Name. * */ -#define FT_HAS_GLYPH_NAMES( face ) \ - ( face->face_flags & FT_FACE_FLAG_GLYPH_NAMES ) +#define FT_HAS_GLYPH_NAMES(face) \ + (face->face_flags & FT_FACE_FLAG_GLYPH_NAMES) /************************************************************************* * * @macro: - * FT_HAS_MULTIPLE_MASTERS( face ) + * FT_HAS_MULTIPLE_MASTERS(face) * * @description: * A macro that returns true whenever a face object contains some @@ -1247,14 +1247,14 @@ FT_BEGIN_HEADER * are then available to choose the exact design you want. * */ -#define FT_HAS_MULTIPLE_MASTERS( face ) \ - ( face->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS ) +#define FT_HAS_MULTIPLE_MASTERS(face) \ + (face->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS) /************************************************************************* * * @macro: - * FT_IS_CID_KEYED( face ) + * FT_IS_CID_KEYED(face) * * @description: * A macro that returns true whenever a face object contains a CID-keyed @@ -1265,36 +1265,36 @@ FT_BEGIN_HEADER * available. * */ -#define FT_IS_CID_KEYED( face ) \ - ( face->face_flags & FT_FACE_FLAG_CID_KEYED ) +#define FT_IS_CID_KEYED(face) \ + (face->face_flags & FT_FACE_FLAG_CID_KEYED) /************************************************************************* * * @macro: - * FT_IS_TRICKY( face ) + * FT_IS_TRICKY(face) * * @description: * A macro that returns true whenever a face represents a `tricky' font. * See the discussion of @FT_FACE_FLAG_TRICKY for more details. * */ -#define FT_IS_TRICKY( face ) \ - ( face->face_flags & FT_FACE_FLAG_TRICKY ) +#define FT_IS_TRICKY(face) \ + (face->face_flags & FT_FACE_FLAG_TRICKY) /************************************************************************* * * @macro: - * FT_HAS_COLOR( face ) + * FT_HAS_COLOR(face) * * @description: * A macro that returns true whenever a face object contains * tables for color glyphs. * */ -#define FT_HAS_COLOR( face ) \ - ( face->face_flags & FT_FACE_FLAG_COLOR ) +#define FT_HAS_COLOR(face) \ + (face->face_flags & FT_FACE_FLAG_COLOR) /*************************************************************************/ @@ -1319,8 +1319,8 @@ FT_BEGIN_HEADER /* (for example, by analyzing various fields of the `OS/2' table in */ /* SFNT based fonts). */ /* */ -#define FT_STYLE_FLAG_ITALIC ( 1 << 0 ) -#define FT_STYLE_FLAG_BOLD ( 1 << 1 ) +#define FT_STYLE_FLAG_ITALIC (1 << 0) +#define FT_STYLE_FLAG_BOLD (1 << 1) /*************************************************************************/ @@ -1622,9 +1622,9 @@ FT_BEGIN_HEADER /* */ /* */ /* */ - /* if ( prev_rsb_delta - face->glyph->lsb_delta >= 32 ) */ + /* if (prev_rsb_delta - face->glyph->lsb_delta >= 32) */ /* origin_x -= 64; */ - /* else if ( prev_rsb_delta - face->glyph->lsb_delta < -32 ) */ + /* else if (prev_rsb_delta - face->glyph->lsb_delta < -32) */ /* origin_x += 64; */ /* */ /* prev_rsb_delta = face->glyph->rsb_delta; */ @@ -1707,8 +1707,8 @@ FT_BEGIN_HEADER /* If you need reference-counting (cf. @FT_Reference_Library), use */ /* @FT_New_Library and @FT_Done_Library. */ /* */ - FT_EXPORT( FT_Error ) - FT_Init_FreeType( FT_Library *alibrary ); + FT_EXPORT(FT_Error) + FT_Init_FreeType(FT_Library *alibrary); /*************************************************************************/ @@ -1726,8 +1726,8 @@ FT_BEGIN_HEADER /* */ /* FreeType error code. 0~means success. */ /* */ - FT_EXPORT( FT_Error ) - FT_Done_FreeType( FT_Library library ); + FT_EXPORT(FT_Error) + FT_Done_FreeType(FT_Library library); /*************************************************************************/ @@ -1905,11 +1905,11 @@ FT_BEGIN_HEADER /* Use @FT_Done_Face to destroy the created @FT_Face object (along */ /* with its slot and sizes). */ /* */ - FT_EXPORT( FT_Error ) - FT_New_Face( FT_Library library, + FT_EXPORT(FT_Error) + FT_New_Face(FT_Library library, const char* filepathname, FT_Long face_index, - FT_Face *aface ); + FT_Face *aface); /*************************************************************************/ @@ -1943,12 +1943,12 @@ FT_BEGIN_HEADER /* */ /* You must not deallocate the memory before calling @FT_Done_Face. */ /* */ - FT_EXPORT( FT_Error ) - FT_New_Memory_Face( FT_Library library, + FT_EXPORT(FT_Error) + FT_New_Memory_Face(FT_Library library, const FT_Byte* file_base, FT_Long file_size, FT_Long face_index, - FT_Face *aface ); + FT_Face *aface); /*************************************************************************/ @@ -2003,11 +2003,11 @@ FT_BEGIN_HEADER /* See the discussion of reference counters in the description of */ /* @FT_Reference_Face. */ /* */ - FT_EXPORT( FT_Error ) - FT_Open_Face( FT_Library library, + FT_EXPORT(FT_Error) + FT_Open_Face(FT_Library library, const FT_Open_Args* args, FT_Long face_index, - FT_Face *aface ); + FT_Face *aface); /*************************************************************************/ @@ -2027,9 +2027,9 @@ FT_BEGIN_HEADER /* */ /* FreeType error code. 0~means success. */ /* */ - FT_EXPORT( FT_Error ) - FT_Attach_File( FT_Face face, - const char* filepathname ); + FT_EXPORT(FT_Error) + FT_Attach_File(FT_Face face, + const char* filepathname); /*************************************************************************/ @@ -2062,9 +2062,9 @@ FT_BEGIN_HEADER /* when invoking this function. Most drivers simply do not implement */ /* file attachments. */ /* */ - FT_EXPORT( FT_Error ) - FT_Attach_Stream( FT_Face face, - FT_Open_Args* parameters ); + FT_EXPORT(FT_Error) + FT_Attach_Stream(FT_Face face, + FT_Open_Args* parameters); /*************************************************************************/ @@ -2090,8 +2090,8 @@ FT_BEGIN_HEADER /* */ /* 2.4.2 */ /* */ - FT_EXPORT( FT_Error ) - FT_Reference_Face( FT_Face face ); + FT_EXPORT(FT_Error) + FT_Reference_Face(FT_Face face); /*************************************************************************/ @@ -2113,8 +2113,8 @@ FT_BEGIN_HEADER /* See the discussion of reference counters in the description of */ /* @FT_Reference_Face. */ /* */ - FT_EXPORT( FT_Error ) - FT_Done_Face( FT_Face face ); + FT_EXPORT(FT_Error) + FT_Done_Face(FT_Face face); /*************************************************************************/ @@ -2135,9 +2135,9 @@ FT_BEGIN_HEADER /* */ /* FreeType error code. 0~means success. */ /* */ - FT_EXPORT( FT_Error ) - FT_Select_Size( FT_Face face, - FT_Int strike_index ); + FT_EXPORT(FT_Error) + FT_Select_Size(FT_Face face, + FT_Int strike_index); /*************************************************************************/ @@ -2273,9 +2273,9 @@ FT_BEGIN_HEADER /* glyph relative to this size. For more information refer to */ /* `http://www.freetype.org/freetype2/docs/glyphs/glyphs-2.html' */ /* */ - FT_EXPORT( FT_Error ) - FT_Request_Size( FT_Face face, - FT_Size_Request req ); + FT_EXPORT(FT_Error) + FT_Request_Size(FT_Face face, + FT_Size_Request req); /*************************************************************************/ @@ -2314,12 +2314,12 @@ FT_BEGIN_HEADER /* */ /* Don't use this function if you are using the FreeType cache API. */ /* */ - FT_EXPORT( FT_Error ) - FT_Set_Char_Size( FT_Face face, + FT_EXPORT(FT_Error) + FT_Set_Char_Size(FT_Face face, FT_F26Dot6 char_width, FT_F26Dot6 char_height, FT_UInt horz_resolution, - FT_UInt vert_resolution ); + FT_UInt vert_resolution); /*************************************************************************/ @@ -2347,10 +2347,10 @@ FT_BEGIN_HEADER /* constrained, to this pixel size. Refer to @FT_Request_Size to */ /* understand how requested sizes relate to actual sizes. */ /* */ - FT_EXPORT( FT_Error ) - FT_Set_Pixel_Sizes( FT_Face face, + FT_EXPORT(FT_Error) + FT_Set_Pixel_Sizes(FT_Face face, FT_UInt pixel_width, - FT_UInt pixel_height ); + FT_UInt pixel_height); /*************************************************************************/ @@ -2389,10 +2389,10 @@ FT_BEGIN_HEADER /* don't have a corresponding glyph in the font). See the discussion */ /* of the @FT_FACE_FLAG_CID_KEYED flag for more details. */ /* */ - FT_EXPORT( FT_Error ) - FT_Load_Glyph( FT_Face face, + FT_EXPORT(FT_Error) + FT_Load_Glyph(FT_Face face, FT_UInt glyph_index, - FT_Int32 load_flags ); + FT_Int32 load_flags); /*************************************************************************/ @@ -2424,10 +2424,10 @@ FT_BEGIN_HEADER /* */ /* This function simply calls @FT_Get_Char_Index and @FT_Load_Glyph. */ /* */ - FT_EXPORT( FT_Error ) - FT_Load_Char( FT_Face face, + FT_EXPORT(FT_Error) + FT_Load_Char(FT_Face face, FT_ULong char_code, - FT_Int32 load_flags ); + FT_Int32 load_flags); /************************************************************************* @@ -2587,28 +2587,28 @@ FT_BEGIN_HEADER * */ #define FT_LOAD_DEFAULT 0x0 -#define FT_LOAD_NO_SCALE ( 1L << 0 ) -#define FT_LOAD_NO_HINTING ( 1L << 1 ) -#define FT_LOAD_RENDER ( 1L << 2 ) -#define FT_LOAD_NO_BITMAP ( 1L << 3 ) -#define FT_LOAD_VERTICAL_LAYOUT ( 1L << 4 ) -#define FT_LOAD_FORCE_AUTOHINT ( 1L << 5 ) -#define FT_LOAD_CROP_BITMAP ( 1L << 6 ) -#define FT_LOAD_PEDANTIC ( 1L << 7 ) -#define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ( 1L << 9 ) -#define FT_LOAD_NO_RECURSE ( 1L << 10 ) -#define FT_LOAD_IGNORE_TRANSFORM ( 1L << 11 ) -#define FT_LOAD_MONOCHROME ( 1L << 12 ) -#define FT_LOAD_LINEAR_DESIGN ( 1L << 13 ) -#define FT_LOAD_NO_AUTOHINT ( 1L << 15 ) +#define FT_LOAD_NO_SCALE (1L << 0) +#define FT_LOAD_NO_HINTING (1L << 1) +#define FT_LOAD_RENDER (1L << 2) +#define FT_LOAD_NO_BITMAP (1L << 3) +#define FT_LOAD_VERTICAL_LAYOUT (1L << 4) +#define FT_LOAD_FORCE_AUTOHINT (1L << 5) +#define FT_LOAD_CROP_BITMAP (1L << 6) +#define FT_LOAD_PEDANTIC (1L << 7) +#define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH (1L << 9) +#define FT_LOAD_NO_RECURSE (1L << 10) +#define FT_LOAD_IGNORE_TRANSFORM (1L << 11) +#define FT_LOAD_MONOCHROME (1L << 12) +#define FT_LOAD_LINEAR_DESIGN (1L << 13) +#define FT_LOAD_NO_AUTOHINT (1L << 15) /* Bits 16..19 are used by `FT_LOAD_TARGET_' */ -#define FT_LOAD_COLOR ( 1L << 20 ) +#define FT_LOAD_COLOR (1L << 20) /* */ /* used internally only by certain font drivers! */ -#define FT_LOAD_ADVANCE_ONLY ( 1L << 8 ) -#define FT_LOAD_SBITS_ONLY ( 1L << 14 ) +#define FT_LOAD_ADVANCE_ONLY (1L << 8) +#define FT_LOAD_SBITS_ONLY (1L << 14) /************************************************************************** @@ -2669,20 +2669,20 @@ FT_BEGIN_HEADER * pixel mode, with code like * * { - * FT_Load_Glyph( face, glyph_index, - * load_flags | FT_LOAD_TARGET_LIGHT ); + * FT_Load_Glyph(face, glyph_index, + * load_flags | FT_LOAD_TARGET_LIGHT); * - * FT_Render_Glyph( face->glyph, FT_RENDER_MODE_LCD ); + * FT_Render_Glyph(face->glyph, FT_RENDER_MODE_LCD); * } * */ -#define FT_LOAD_TARGET_( x ) ( (FT_Int32)( (x) & 15 ) << 16 ) +#define FT_LOAD_TARGET_(x) ((FT_Int32)((x) & 15) << 16) -#define FT_LOAD_TARGET_NORMAL FT_LOAD_TARGET_( FT_RENDER_MODE_NORMAL ) -#define FT_LOAD_TARGET_LIGHT FT_LOAD_TARGET_( FT_RENDER_MODE_LIGHT ) -#define FT_LOAD_TARGET_MONO FT_LOAD_TARGET_( FT_RENDER_MODE_MONO ) -#define FT_LOAD_TARGET_LCD FT_LOAD_TARGET_( FT_RENDER_MODE_LCD ) -#define FT_LOAD_TARGET_LCD_V FT_LOAD_TARGET_( FT_RENDER_MODE_LCD_V ) +#define FT_LOAD_TARGET_NORMAL FT_LOAD_TARGET_(FT_RENDER_MODE_NORMAL) +#define FT_LOAD_TARGET_LIGHT FT_LOAD_TARGET_(FT_RENDER_MODE_LIGHT) +#define FT_LOAD_TARGET_MONO FT_LOAD_TARGET_(FT_RENDER_MODE_MONO) +#define FT_LOAD_TARGET_LCD FT_LOAD_TARGET_(FT_RENDER_MODE_LCD) +#define FT_LOAD_TARGET_LCD_V FT_LOAD_TARGET_(FT_RENDER_MODE_LCD_V) /************************************************************************** @@ -2695,7 +2695,7 @@ FT_BEGIN_HEADER * @FT_LOAD_TARGET_XXX value. * */ -#define FT_LOAD_TARGET_MODE( x ) ( (FT_Render_Mode)( ( (x) >> 16 ) & 15 ) ) +#define FT_LOAD_TARGET_MODE(x) ((FT_Render_Mode)(((x) >> 16) & 15)) /*************************************************************************/ @@ -2726,10 +2726,10 @@ FT_BEGIN_HEADER /* Note that this also transforms the `face.glyph.advance' field, but */ /* *not* the values in `face.glyph.metrics'. */ /* */ - FT_EXPORT( void ) - FT_Set_Transform( FT_Face face, + FT_EXPORT(void) + FT_Set_Transform(FT_Face face, FT_Matrix* matrix, - FT_Vector* delta ); + FT_Vector* delta); /*************************************************************************/ @@ -2839,9 +2839,9 @@ FT_BEGIN_HEADER /* */ /* FreeType error code. 0~means success. */ /* */ - FT_EXPORT( FT_Error ) - FT_Render_Glyph( FT_GlyphSlot slot, - FT_Render_Mode render_mode ); + FT_EXPORT(FT_Error) + FT_Render_Glyph(FT_GlyphSlot slot, + FT_Render_Mode render_mode); /*************************************************************************/ @@ -2941,12 +2941,12 @@ FT_BEGIN_HEADER /* kernings, are out of the scope of this API function -- they can be */ /* implemented through format-specific interfaces. */ /* */ - FT_EXPORT( FT_Error ) - FT_Get_Kerning( FT_Face face, + FT_EXPORT(FT_Error) + FT_Get_Kerning(FT_Face face, FT_UInt left_glyph, FT_UInt right_glyph, FT_UInt kern_mode, - FT_Vector *akerning ); + FT_Vector *akerning); /*************************************************************************/ @@ -2982,11 +2982,11 @@ FT_BEGIN_HEADER /* Only very few AFM files come with track kerning data; please refer */ /* to the Adobe's AFM specification for more details. */ /* */ - FT_EXPORT( FT_Error ) - FT_Get_Track_Kerning( FT_Face face, + FT_EXPORT(FT_Error) + FT_Get_Track_Kerning(FT_Face face, FT_Fixed point_size, FT_Int degree, - FT_Fixed* akerning ); + FT_Fixed* akerning); /*************************************************************************/ @@ -3029,11 +3029,11 @@ FT_BEGIN_HEADER /* macro `FT_CONFIG_OPTION_NO_GLYPH_NAMES' is defined in */ /* `ftoptions.h'. */ /* */ - FT_EXPORT( FT_Error ) - FT_Get_Glyph_Name( FT_Face face, + FT_EXPORT(FT_Error) + FT_Get_Glyph_Name(FT_Face face, FT_UInt glyph_index, FT_Pointer buffer, - FT_UInt buffer_max ); + FT_UInt buffer_max); /*************************************************************************/ @@ -3055,8 +3055,8 @@ FT_BEGIN_HEADER /* The returned pointer is owned by the face and is destroyed with */ /* it. */ /* */ - FT_EXPORT( const char* ) - FT_Get_Postscript_Name( FT_Face face ); + FT_EXPORT(const char*) + FT_Get_Postscript_Name(FT_Face face); /*************************************************************************/ @@ -3087,9 +3087,9 @@ FT_BEGIN_HEADER /* preferred to a UCS-2 cmap). It is thus preferable to */ /* @FT_Set_Charmap in this case. */ /* */ - FT_EXPORT( FT_Error ) - FT_Select_Charmap( FT_Face face, - FT_Encoding encoding ); + FT_EXPORT(FT_Error) + FT_Select_Charmap(FT_Face face, + FT_Encoding encoding); /*************************************************************************/ @@ -3116,9 +3116,9 @@ FT_BEGIN_HEADER /* */ /* It also fails if a type~14 charmap is selected. */ /* */ - FT_EXPORT( FT_Error ) - FT_Set_Charmap( FT_Face face, - FT_CharMap charmap ); + FT_EXPORT(FT_Error) + FT_Set_Charmap(FT_Face face, + FT_CharMap charmap); /************************************************************************* @@ -3138,8 +3138,8 @@ FT_BEGIN_HEADER * `charmap' belongs. If an error occurs, -1 is returned. * */ - FT_EXPORT( FT_Int ) - FT_Get_Charmap_Index( FT_CharMap charmap ); + FT_EXPORT(FT_Int) + FT_Get_Charmap_Index(FT_CharMap charmap); /*************************************************************************/ @@ -3172,9 +3172,9 @@ FT_BEGIN_HEADER /* whatever was there will be moved to the last index -- Type~42 */ /* fonts are considered invalid under this condition. */ /* */ - FT_EXPORT( FT_UInt ) - FT_Get_Char_Index( FT_Face face, - FT_ULong charcode ); + FT_EXPORT(FT_UInt) + FT_Get_Char_Index(FT_Face face, + FT_ULong charcode); /*************************************************************************/ @@ -3207,12 +3207,12 @@ FT_BEGIN_HEADER /* FT_UInt gindex; */ /* */ /* */ - /* charcode = FT_Get_First_Char( face, &gindex ); */ - /* while ( gindex != 0 ) */ + /* charcode = FT_Get_First_Char(face, &gindex); */ + /* while (gindex != 0) */ /* { */ /* ... do something with (charcode,gindex) pair ... */ /* */ - /* charcode = FT_Get_Next_Char( face, charcode, &gindex ); */ + /* charcode = FT_Get_Next_Char(face, charcode, &gindex); */ /* } */ /* } */ /* */ @@ -3220,9 +3220,9 @@ FT_BEGIN_HEADER /* result itself can be~0 in two cases: if the charmap is empty or */ /* if the value~0 is the first valid character code. */ /* */ - FT_EXPORT( FT_ULong ) - FT_Get_First_Char( FT_Face face, - FT_UInt *agindex ); + FT_EXPORT(FT_ULong) + FT_Get_First_Char(FT_Face face, + FT_UInt *agindex); /*************************************************************************/ @@ -3254,10 +3254,10 @@ FT_BEGIN_HEADER /* Note that `*agindex' is set to~0 when there are no more codes in */ /* the charmap. */ /* */ - FT_EXPORT( FT_ULong ) - FT_Get_Next_Char( FT_Face face, + FT_EXPORT(FT_ULong) + FT_Get_Next_Char(FT_Face face, FT_ULong char_code, - FT_UInt *agindex ); + FT_UInt *agindex); /*************************************************************************/ @@ -3277,9 +3277,9 @@ FT_BEGIN_HEADER /* */ /* The glyph index. 0~means `undefined character code'. */ /* */ - FT_EXPORT( FT_UInt ) - FT_Get_Name_Index( FT_Face face, - FT_String* glyph_name ); + FT_EXPORT(FT_UInt) + FT_Get_Name_Index(FT_Face face, + FT_String* glyph_name); /************************************************************************* @@ -3353,14 +3353,14 @@ FT_BEGIN_HEADER * TrueType specification for details. * */ - FT_EXPORT( FT_Error ) - FT_Get_SubGlyph_Info( FT_GlyphSlot glyph, + FT_EXPORT(FT_Error) + FT_Get_SubGlyph_Info(FT_GlyphSlot glyph, FT_UInt sub_index, FT_Int *p_index, FT_UInt *p_flags, FT_Int *p_arg1, FT_Int *p_arg2, - FT_Matrix *p_transform ); + FT_Matrix *p_transform); /*************************************************************************/ @@ -3444,8 +3444,8 @@ FT_BEGIN_HEADER /* */ /* 2.3.8 */ /* */ - FT_EXPORT( FT_UShort ) - FT_Get_FSType_Flags( FT_Face face ); + FT_EXPORT(FT_UShort) + FT_Get_FSType_Flags(FT_Face face); /*************************************************************************/ @@ -3530,10 +3530,10 @@ FT_BEGIN_HEADER /* */ /* 2.3.6 */ /* */ - FT_EXPORT( FT_UInt ) - FT_Face_GetCharVariantIndex( FT_Face face, + FT_EXPORT(FT_UInt) + FT_Face_GetCharVariantIndex(FT_Face face, FT_ULong charcode, - FT_ULong variantSelector ); + FT_ULong variantSelector); /*************************************************************************/ @@ -3566,10 +3566,10 @@ FT_BEGIN_HEADER /* */ /* 2.3.6 */ /* */ - FT_EXPORT( FT_Int ) - FT_Face_GetCharVariantIsDefault( FT_Face face, + FT_EXPORT(FT_Int) + FT_Face_GetCharVariantIsDefault(FT_Face face, FT_ULong charcode, - FT_ULong variantSelector ); + FT_ULong variantSelector); /*************************************************************************/ @@ -3597,8 +3597,8 @@ FT_BEGIN_HEADER /* */ /* 2.3.6 */ /* */ - FT_EXPORT( FT_UInt32* ) - FT_Face_GetVariantSelectors( FT_Face face ); + FT_EXPORT(FT_UInt32*) + FT_Face_GetVariantSelectors(FT_Face face); /*************************************************************************/ @@ -3630,9 +3630,9 @@ FT_BEGIN_HEADER /* */ /* 2.3.6 */ /* */ - FT_EXPORT( FT_UInt32* ) - FT_Face_GetVariantsOfChar( FT_Face face, - FT_ULong charcode ); + FT_EXPORT(FT_UInt32*) + FT_Face_GetVariantsOfChar(FT_Face face, + FT_ULong charcode); /*************************************************************************/ @@ -3664,9 +3664,9 @@ FT_BEGIN_HEADER /* */ /* 2.3.6 */ /* */ - FT_EXPORT( FT_UInt32* ) - FT_Face_GetCharsOfVariant( FT_Face face, - FT_ULong variantSelector ); + FT_EXPORT(FT_UInt32*) + FT_Face_GetCharsOfVariant(FT_Face face, + FT_ULong variantSelector); /*************************************************************************/ @@ -3721,10 +3721,10 @@ FT_BEGIN_HEADER /* divide by zero; it simply returns `MaxInt' or `MinInt' depending */ /* on the signs of `a' and `b'. */ /* */ - FT_EXPORT( FT_Long ) - FT_MulDiv( FT_Long a, + FT_EXPORT(FT_Long) + FT_MulDiv(FT_Long a, FT_Long b, - FT_Long c ); + FT_Long c); /* */ @@ -3762,19 +3762,19 @@ FT_BEGIN_HEADER /* _second_ argument of this function; this can make a great */ /* difference. */ /* */ - FT_EXPORT( FT_Long ) - FT_MulFix( FT_Long a, - FT_Long b ); + FT_EXPORT(FT_Long) + FT_MulFix(FT_Long a, + FT_Long b); /* */ #endif #ifdef FT_MULFIX_INLINED -#define FT_MulFix( a, b ) FT_MULFIX_INLINED( a, b ) +#define FT_MulFix(a, b) FT_MULFIX_INLINED(a, b) #else - FT_EXPORT( FT_Long ) - FT_MulFix( FT_Long a, - FT_Long b ); + FT_EXPORT(FT_Long) + FT_MulFix(FT_Long a, + FT_Long b); #endif @@ -3801,9 +3801,9 @@ FT_BEGIN_HEADER /* 32~bits, then the division is computed directly. Otherwise, we */ /* use a specialized version of @FT_MulDiv. */ /* */ - FT_EXPORT( FT_Long ) - FT_DivFix( FT_Long a, - FT_Long b ); + FT_EXPORT(FT_Long) + FT_DivFix(FT_Long a, + FT_Long b); /*************************************************************************/ @@ -3820,8 +3820,8 @@ FT_BEGIN_HEADER /* */ /* The result of `(a + 0x8000) & -0x10000'. */ /* */ - FT_EXPORT( FT_Fixed ) - FT_RoundFix( FT_Fixed a ); + FT_EXPORT(FT_Fixed) + FT_RoundFix(FT_Fixed a); /*************************************************************************/ @@ -3839,8 +3839,8 @@ FT_BEGIN_HEADER /* */ /* The result of `(a + 0x10000 - 1) & -0x10000'. */ /* */ - FT_EXPORT( FT_Fixed ) - FT_CeilFix( FT_Fixed a ); + FT_EXPORT(FT_Fixed) + FT_CeilFix(FT_Fixed a); /*************************************************************************/ @@ -3858,8 +3858,8 @@ FT_BEGIN_HEADER /* */ /* The result of `a & -0x10000'. */ /* */ - FT_EXPORT( FT_Fixed ) - FT_FloorFix( FT_Fixed a ); + FT_EXPORT(FT_Fixed) + FT_FloorFix(FT_Fixed a); /*************************************************************************/ @@ -3879,9 +3879,9 @@ FT_BEGIN_HEADER /* */ /* The result is undefined if either `vector' or `matrix' is invalid. */ /* */ - FT_EXPORT( void ) - FT_Vector_Transform( FT_Vector* vec, - const FT_Matrix* matrix ); + FT_EXPORT(void) + FT_Vector_Transform(FT_Vector* vec, + const FT_Matrix* matrix); /*************************************************************************/ @@ -3957,11 +3957,11 @@ FT_BEGIN_HEADER /* In such cases, the library version might not be available before */ /* the library object has been created. */ /* */ - FT_EXPORT( void ) - FT_Library_Version( FT_Library library, + FT_EXPORT(void) + FT_Library_Version(FT_Library library, FT_Int *amajor, FT_Int *aminor, - FT_Int *apatch ); + FT_Int *apatch); /*************************************************************************/ @@ -3991,8 +3991,8 @@ FT_BEGIN_HEADER /* */ /* 2.3.5 */ /* */ - FT_EXPORT( FT_Bool ) - FT_Face_CheckTrueTypePatents( FT_Face face ); + FT_EXPORT(FT_Bool) + FT_Face_CheckTrueTypePatents(FT_Face face); /*************************************************************************/ @@ -4021,9 +4021,9 @@ FT_BEGIN_HEADER /* */ /* 2.3.5 */ /* */ - FT_EXPORT( FT_Bool ) - FT_Face_SetUnpatentedHinting( FT_Face face, - FT_Bool value ); + FT_EXPORT(FT_Bool) + FT_Face_SetUnpatentedHinting(FT_Face face, + FT_Bool value); /* */ diff --git a/include/freetype/ftadvanc.h b/include/freetype/ftadvanc.h index 8f7e2fc..6e3b0b5 100644 --- a/include/freetype/ftadvanc.h +++ b/include/freetype/ftadvanc.h @@ -113,11 +113,11 @@ FT_BEGIN_HEADER /* A scaled advance is returned in 16.16 format but isn't transformed */ /* by the affine transformation specified by @FT_Set_Transform. */ /* */ - FT_EXPORT( FT_Error ) - FT_Get_Advance( FT_Face face, + FT_EXPORT(FT_Error) + FT_Get_Advance(FT_Face face, FT_UInt gindex, FT_Int32 load_flags, - FT_Fixed *padvance ); + FT_Fixed *padvance); /*************************************************************************/ @@ -164,12 +164,12 @@ FT_BEGIN_HEADER /* transformed by the affine transformation specified by */ /* @FT_Set_Transform. */ /* */ - FT_EXPORT( FT_Error ) - FT_Get_Advances( FT_Face face, + FT_EXPORT(FT_Error) + FT_Get_Advances(FT_Face face, FT_UInt start, FT_UInt count, FT_Int32 load_flags, - FT_Fixed *padvances ); + FT_Fixed *padvances); /* */ diff --git a/include/freetype/ftautoh.h b/include/freetype/ftautoh.h index bf97b3f..08ae597 100644 --- a/include/freetype/ftautoh.h +++ b/include/freetype/ftautoh.h @@ -93,17 +93,17 @@ FT_BEGIN_HEADER * FT_Prop_GlyphToScriptMap prop; * * - * FT_Init_FreeType( &library ); - * FT_New_Face( library, "foo.ttf", 0, &face ); + * FT_Init_FreeType(&library); + * FT_New_Face(library, "foo.ttf", 0, &face); * * prop.face = face; * - * FT_Property_Get( library, "autofitter", - * "glyph-to-script-map", &prop ); + * FT_Property_Get(library, "autofitter", + * "glyph-to-script-map", &prop); * * // adjust `prop.map' as needed right here * - * FT_Load_Glyph( face, ..., FT_LOAD_FORCE_AUTOHINT ); + * FT_Load_Glyph(face, ..., FT_LOAD_FORCE_AUTOHINT); * } * */ @@ -272,10 +272,10 @@ FT_BEGIN_HEADER * FT_UInt fallback_script = FT_AUTOHINTER_SCRIPT_NONE; * * - * FT_Init_FreeType( &library ); + * FT_Init_FreeType(&library); * - * FT_Property_Set( library, "autofitter", - * "fallback-script", &fallback_script ); + * FT_Property_Set(library, "autofitter", + * "fallback-script", &fallback_script); * } * * @note: @@ -310,15 +310,15 @@ FT_BEGIN_HEADER * FT_Prop_IncreaseXHeight prop; * * - * FT_Init_FreeType( &library ); - * FT_New_Face( library, "foo.ttf", 0, &face ); - * FT_Set_Char_Size( face, 10 * 64, 0, 72, 0 ); + * FT_Init_FreeType(&library); + * FT_New_Face(library, "foo.ttf", 0, &face); + * FT_Set_Char_Size(face, 10 * 64, 0, 72, 0); * * prop.face = face; * prop.limit = 14; * - * FT_Property_Set( library, "autofitter", - * "increase-x-height", &prop ); + * FT_Property_Set(library, "autofitter", + * "increase-x-height", &prop); * } * * @note: diff --git a/include/freetype/ftbbox.h b/include/freetype/ftbbox.h index 8938841..2ff25ea 100644 --- a/include/freetype/ftbbox.h +++ b/include/freetype/ftbbox.h @@ -81,9 +81,9 @@ FT_BEGIN_HEADER /* properly shift and scale the subglyphs), then extracting the BBox, */ /* which can be eventually converted back to font units. */ /* */ - FT_EXPORT( FT_Error ) - FT_Outline_Get_BBox( FT_Outline* outline, - FT_BBox *abbox ); + FT_EXPORT(FT_Error) + FT_Outline_Get_BBox(FT_Outline* outline, + FT_BBox *abbox); /* */ diff --git a/include/freetype/ftbdf.h b/include/freetype/ftbdf.h index 4f8baf8..66c57c6 100644 --- a/include/freetype/ftbdf.h +++ b/include/freetype/ftbdf.h @@ -153,10 +153,10 @@ FT_BEGIN_HEADER * @note: * This function only works with BDF faces, returning an error otherwise. */ - FT_EXPORT( FT_Error ) - FT_Get_BDF_Charset_ID( FT_Face face, + FT_EXPORT(FT_Error) + FT_Get_BDF_Charset_ID(FT_Face face, const char* *acharset_encoding, - const char* *acharset_registry ); + const char* *acharset_registry); /********************************************************************** @@ -194,10 +194,10 @@ FT_BEGIN_HEADER * In case of error, `aproperty->type' is always set to * @BDF_PROPERTY_TYPE_NONE. */ - FT_EXPORT( FT_Error ) - FT_Get_BDF_Property( FT_Face face, + FT_EXPORT(FT_Error) + FT_Get_BDF_Property(FT_Face face, const char* prop_name, - BDF_PropertyRec *aproperty ); + BDF_PropertyRec *aproperty); /* */ diff --git a/include/freetype/ftbitmap.h b/include/freetype/ftbitmap.h index 7dbf5ba..ff7649b 100644 --- a/include/freetype/ftbitmap.h +++ b/include/freetype/ftbitmap.h @@ -61,8 +61,8 @@ FT_BEGIN_HEADER /* */ /* abitmap :: A pointer to the bitmap structure. */ /* */ - FT_EXPORT( void ) - FT_Bitmap_New( FT_Bitmap *abitmap ); + FT_EXPORT(void) + FT_Bitmap_New(FT_Bitmap *abitmap); /*************************************************************************/ @@ -84,8 +84,8 @@ FT_BEGIN_HEADER /* */ /* FreeType error code. 0~means success. */ /* */ - FT_EXPORT( FT_Error ) - FT_Bitmap_Copy( FT_Library library, + FT_EXPORT(FT_Error) + FT_Bitmap_Copy(FT_Library library, const FT_Bitmap *source, FT_Bitmap *target); @@ -122,11 +122,11 @@ FT_BEGIN_HEADER /* If you want to embolden the bitmap owned by a @FT_GlyphSlotRec, */ /* you should call @FT_GlyphSlot_Own_Bitmap on the slot first. */ /* */ - FT_EXPORT( FT_Error ) - FT_Bitmap_Embolden( FT_Library library, + FT_EXPORT(FT_Error) + FT_Bitmap_Embolden(FT_Library library, FT_Bitmap* bitmap, FT_Pos xStrength, - FT_Pos yStrength ); + FT_Pos yStrength); /*************************************************************************/ @@ -162,11 +162,11 @@ FT_BEGIN_HEADER /* The `library' argument is taken to have access to FreeType's */ /* memory handling functions. */ /* */ - FT_EXPORT( FT_Error ) - FT_Bitmap_Convert( FT_Library library, + FT_EXPORT(FT_Error) + FT_Bitmap_Convert(FT_Library library, const FT_Bitmap *source, FT_Bitmap *target, - FT_Int alignment ); + FT_Int alignment); /*************************************************************************/ @@ -187,8 +187,8 @@ FT_BEGIN_HEADER /* This function is to be used in combination with */ /* @FT_Bitmap_Embolden. */ /* */ - FT_EXPORT( FT_Error ) - FT_GlyphSlot_Own_Bitmap( FT_GlyphSlot slot ); + FT_EXPORT(FT_Error) + FT_GlyphSlot_Own_Bitmap(FT_GlyphSlot slot); /*************************************************************************/ @@ -211,9 +211,9 @@ FT_BEGIN_HEADER /* The `library' argument is taken to have access to FreeType's */ /* memory handling functions. */ /* */ - FT_EXPORT( FT_Error ) - FT_Bitmap_Done( FT_Library library, - FT_Bitmap *bitmap ); + FT_EXPORT(FT_Error) + FT_Bitmap_Done(FT_Library library, + FT_Bitmap *bitmap); /* */ diff --git a/include/freetype/ftbzip2.h b/include/freetype/ftbzip2.h index 1bf81b1..068c47a 100644 --- a/include/freetype/ftbzip2.h +++ b/include/freetype/ftbzip2.h @@ -87,9 +87,9 @@ FT_BEGIN_HEADER * This function may return `FT_Err_Unimplemented_Feature' if your build * of FreeType was not compiled with bzip2 support. */ - FT_EXPORT( FT_Error ) - FT_Stream_OpenBzip2( FT_Stream stream, - FT_Stream source ); + FT_EXPORT(FT_Error) + FT_Stream_OpenBzip2(FT_Stream stream, + FT_Stream source); /* */ diff --git a/include/freetype/ftcache.h b/include/freetype/ftcache.h index a5d7100..1dfdcc6 100644 --- a/include/freetype/ftcache.h +++ b/include/freetype/ftcache.h @@ -207,10 +207,10 @@ FT_BEGIN_HEADER * transformation through @FT_Set_Transform! */ typedef FT_Error - (*FTC_Face_Requester)( FTC_FaceID face_id, + (*FTC_Face_Requester)(FTC_FaceID face_id, FT_Library library, FT_Pointer request_data, - FT_Face* aface ); + FT_Face* aface); /* */ @@ -304,14 +304,14 @@ FT_BEGIN_HEADER /* */ /* FreeType error code. 0~means success. */ /* */ - FT_EXPORT( FT_Error ) - FTC_Manager_New( FT_Library library, + FT_EXPORT(FT_Error) + FTC_Manager_New(FT_Library library, FT_UInt max_faces, FT_UInt max_sizes, FT_ULong max_bytes, FTC_Face_Requester requester, FT_Pointer req_data, - FTC_Manager *amanager ); + FTC_Manager *amanager); /*************************************************************************/ @@ -326,8 +326,8 @@ FT_BEGIN_HEADER /* */ /* manager :: A handle to the manager. */ /* */ - FT_EXPORT( void ) - FTC_Manager_Reset( FTC_Manager manager ); + FT_EXPORT(void) + FTC_Manager_Reset(FTC_Manager manager); /*************************************************************************/ @@ -341,8 +341,8 @@ FT_BEGIN_HEADER /* */ /* manager :: A handle to the target cache manager object. */ /* */ - FT_EXPORT( void ) - FTC_Manager_Done( FTC_Manager manager ); + FT_EXPORT(void) + FTC_Manager_Done(FTC_Manager manager); /*************************************************************************/ @@ -385,10 +385,10 @@ FT_BEGIN_HEADER /* already been completely flushed, and still no memory was available */ /* for the operation. */ /* */ - FT_EXPORT( FT_Error ) - FTC_Manager_LookupFace( FTC_Manager manager, + FT_EXPORT(FT_Error) + FTC_Manager_LookupFace(FTC_Manager manager, FTC_FaceID face_id, - FT_Face *aface ); + FT_Face *aface); /*************************************************************************/ @@ -482,10 +482,10 @@ FT_BEGIN_HEADER /* already been completely flushed, and still no memory is available */ /* for the operation. */ /* */ - FT_EXPORT( FT_Error ) - FTC_Manager_LookupSize( FTC_Manager manager, + FT_EXPORT(FT_Error) + FTC_Manager_LookupSize(FTC_Manager manager, FTC_Scaler scaler, - FT_Size *asize ); + FT_Size *asize); /*************************************************************************/ @@ -503,9 +503,9 @@ FT_BEGIN_HEADER /* */ /* manager :: The cache manager handle. */ /* */ - FT_EXPORT( void ) - FTC_Node_Unref( FTC_Node node, - FTC_Manager manager ); + FT_EXPORT(void) + FTC_Node_Unref(FTC_Node node, + FTC_Manager manager); /************************************************************************* @@ -535,9 +535,9 @@ FT_BEGIN_HEADER * destroyed when released by all their users. * */ - FT_EXPORT( void ) - FTC_Manager_RemoveFaceID( FTC_Manager manager, - FTC_FaceID face_id ); + FT_EXPORT(void) + FTC_Manager_RemoveFaceID(FTC_Manager manager, + FTC_FaceID face_id); /*************************************************************************/ @@ -584,9 +584,9 @@ FT_BEGIN_HEADER * manager. * */ - FT_EXPORT( FT_Error ) - FTC_CMapCache_New( FTC_Manager manager, - FTC_CMapCache *acache ); + FT_EXPORT(FT_Error) + FTC_CMapCache_New(FTC_Manager manager, + FTC_CMapCache *acache); /************************************************************************ @@ -616,11 +616,11 @@ FT_BEGIN_HEADER * Glyph index. 0~means `no glyph'. * */ - FT_EXPORT( FT_UInt ) - FTC_CMapCache_Lookup( FTC_CMapCache cache, + FT_EXPORT(FT_UInt) + FTC_CMapCache_Lookup(FTC_CMapCache cache, FTC_FaceID face_id, FT_Int cmap_index, - FT_UInt32 char_code ); + FT_UInt32 char_code); /*************************************************************************/ @@ -689,10 +689,10 @@ FT_BEGIN_HEADER /* */ -#define FTC_IMAGE_TYPE_COMPARE( d1, d2 ) \ - ( (d1)->face_id == (d2)->face_id && \ +#define FTC_IMAGE_TYPE_COMPARE(d1, d2) \ + ((d1)->face_id == (d2)->face_id && \ (d1)->width == (d2)->width && \ - (d1)->flags == (d2)->flags ) + (d1)->flags == (d2)->flags) /*************************************************************************/ @@ -725,9 +725,9 @@ FT_BEGIN_HEADER /* */ /* FreeType error code. 0~means success. */ /* */ - FT_EXPORT( FT_Error ) - FTC_ImageCache_New( FTC_Manager manager, - FTC_ImageCache *acache ); + FT_EXPORT(FT_Error) + FTC_ImageCache_New(FTC_Manager manager, + FTC_ImageCache *acache); /*************************************************************************/ @@ -772,12 +772,12 @@ FT_BEGIN_HEADER /* call to one of the caching sub-system APIs. Don't assume that it */ /* is persistent! */ /* */ - FT_EXPORT( FT_Error ) - FTC_ImageCache_Lookup( FTC_ImageCache cache, + FT_EXPORT(FT_Error) + FTC_ImageCache_Lookup(FTC_ImageCache cache, FTC_ImageType type, FT_UInt gindex, FT_Glyph *aglyph, - FTC_Node *anode ); + FTC_Node *anode); /*************************************************************************/ @@ -828,13 +828,13 @@ FT_BEGIN_HEADER /* Calls to @FT_Set_Char_Size and friends have no effect on cached */ /* glyphs; you should always use the FreeType cache API instead. */ /* */ - FT_EXPORT( FT_Error ) - FTC_ImageCache_LookupScaler( FTC_ImageCache cache, + FT_EXPORT(FT_Error) + FTC_ImageCache_LookupScaler(FTC_ImageCache cache, FTC_Scaler scaler, FT_ULong load_flags, FT_UInt gindex, FT_Glyph *aglyph, - FTC_Node *anode ); + FTC_Node *anode); /*************************************************************************/ @@ -933,9 +933,9 @@ FT_BEGIN_HEADER /* */ /* FreeType error code. 0~means success. */ /* */ - FT_EXPORT( FT_Error ) - FTC_SBitCache_New( FTC_Manager manager, - FTC_SBitCache *acache ); + FT_EXPORT(FT_Error) + FTC_SBitCache_New(FTC_Manager manager, + FTC_SBitCache *acache); /*************************************************************************/ @@ -983,12 +983,12 @@ FT_BEGIN_HEADER /* call to one of the caching sub-system APIs. Don't assume that it */ /* is persistent! */ /* */ - FT_EXPORT( FT_Error ) - FTC_SBitCache_Lookup( FTC_SBitCache cache, + FT_EXPORT(FT_Error) + FTC_SBitCache_Lookup(FTC_SBitCache cache, FTC_ImageType type, FT_UInt gindex, FTC_SBit *sbit, - FTC_Node *anode ); + FTC_Node *anode); /*************************************************************************/ @@ -1038,13 +1038,13 @@ FT_BEGIN_HEADER /* call to one of the caching sub-system APIs. Don't assume that it */ /* is persistent! */ /* */ - FT_EXPORT( FT_Error ) - FTC_SBitCache_LookupScaler( FTC_SBitCache cache, + FT_EXPORT(FT_Error) + FTC_SBitCache_LookupScaler(FTC_SBitCache cache, FTC_Scaler scaler, FT_ULong load_flags, FT_UInt gindex, FTC_SBit *sbit, - FTC_Node *anode ); + FTC_Node *anode); /* */ diff --git a/include/freetype/ftcffdrv.h b/include/freetype/ftcffdrv.h index e4d039d..2f5b05c 100644 --- a/include/freetype/ftcffdrv.h +++ b/include/freetype/ftcffdrv.h @@ -133,10 +133,10 @@ FT_BEGIN_HEADER * FT_UInt hinting_engine = FT_CFF_HINTING_ADOBE; * * - * FT_Init_FreeType( &library ); + * FT_Init_FreeType(&library); * - * FT_Property_Set( library, "cff", - * "hinting-engine", &hinting_engine ); + * FT_Property_Set(library, "cff", + * "hinting-engine", &hinting_engine); * } * * @note: @@ -184,10 +184,10 @@ FT_BEGIN_HEADER * FT_Bool no_stem_darkening = TRUE; * * - * FT_Init_FreeType( &library ); + * FT_Init_FreeType(&library); * - * FT_Property_Set( library, "cff", - * "no-stem-darkening", &no_stem_darkening ); + * FT_Property_Set(library, "cff", + * "no-stem-darkening", &no_stem_darkening); * } * * @note: @@ -224,10 +224,10 @@ FT_BEGIN_HEADER * 2000, 0 }; // x4, y4 * * - * FT_Init_FreeType( &library ); + * FT_Init_FreeType(&library); * - * FT_Property_Set( library, "cff", - * "darkening-parameters", darken_params ); + * FT_Property_Set(library, "cff", + * "darkening-parameters", darken_params); * } * * The x~values give the stem width, and the y~values the darkening diff --git a/include/freetype/ftcid.h b/include/freetype/ftcid.h index 203a30c..05d7df6 100644 --- a/include/freetype/ftcid.h +++ b/include/freetype/ftcid.h @@ -82,8 +82,8 @@ FT_BEGIN_HEADER * @since: * 2.3.6 */ - FT_EXPORT( FT_Error ) - FT_Get_CID_Registry_Ordering_Supplement( FT_Face face, + FT_EXPORT(FT_Error) + FT_Get_CID_Registry_Ordering_Supplement(FT_Face face, const char* *registry, const char* *ordering, FT_Int *supplement); @@ -117,9 +117,9 @@ FT_BEGIN_HEADER * @since: * 2.3.9 */ - FT_EXPORT( FT_Error ) - FT_Get_CID_Is_Internally_CID_Keyed( FT_Face face, - FT_Bool *is_cid ); + FT_EXPORT(FT_Error) + FT_Get_CID_Is_Internally_CID_Keyed(FT_Face face, + FT_Bool *is_cid); /********************************************************************** @@ -151,10 +151,10 @@ FT_BEGIN_HEADER * @since: * 2.3.9 */ - FT_EXPORT( FT_Error ) - FT_Get_CID_From_Glyph_Index( FT_Face face, + FT_EXPORT(FT_Error) + FT_Get_CID_From_Glyph_Index(FT_Face face, FT_UInt glyph_index, - FT_UInt *cid ); + FT_UInt *cid); /* */ diff --git a/include/freetype/fterrdef.h b/include/freetype/fterrdef.h index 76c7b9e..e56ec11 100644 --- a/include/freetype/fterrdef.h +++ b/include/freetype/fterrdef.h @@ -31,219 +31,219 @@ /* generic errors */ - FT_NOERRORDEF_( Ok, 0x00, \ - "no error" ) - - FT_ERRORDEF_( Cannot_Open_Resource, 0x01, \ - "cannot open resource" ) - FT_ERRORDEF_( Unknown_File_Format, 0x02, \ - "unknown file format" ) - FT_ERRORDEF_( Invalid_File_Format, 0x03, \ - "broken file" ) - FT_ERRORDEF_( Invalid_Version, 0x04, \ - "invalid FreeType version" ) - FT_ERRORDEF_( Lower_Module_Version, 0x05, \ - "module version is too low" ) - FT_ERRORDEF_( Invalid_Argument, 0x06, \ - "invalid argument" ) - FT_ERRORDEF_( Unimplemented_Feature, 0x07, \ - "unimplemented feature" ) - FT_ERRORDEF_( Invalid_Table, 0x08, \ - "broken table" ) - FT_ERRORDEF_( Invalid_Offset, 0x09, \ - "broken offset within table" ) - FT_ERRORDEF_( Array_Too_Large, 0x0A, \ - "array allocation size too large" ) - FT_ERRORDEF_( Missing_Module, 0x0B, \ - "missing module" ) - FT_ERRORDEF_( Missing_Property, 0x0C, \ - "missing property" ) + FT_NOERRORDEF_(Ok, 0x00, \ + "no error") + + FT_ERRORDEF_(Cannot_Open_Resource, 0x01, \ + "cannot open resource") + FT_ERRORDEF_(Unknown_File_Format, 0x02, \ + "unknown file format") + FT_ERRORDEF_(Invalid_File_Format, 0x03, \ + "broken file") + FT_ERRORDEF_(Invalid_Version, 0x04, \ + "invalid FreeType version") + FT_ERRORDEF_(Lower_Module_Version, 0x05, \ + "module version is too low") + FT_ERRORDEF_(Invalid_Argument, 0x06, \ + "invalid argument") + FT_ERRORDEF_(Unimplemented_Feature, 0x07, \ + "unimplemented feature") + FT_ERRORDEF_(Invalid_Table, 0x08, \ + "broken table") + FT_ERRORDEF_(Invalid_Offset, 0x09, \ + "broken offset within table") + FT_ERRORDEF_(Array_Too_Large, 0x0A, \ + "array allocation size too large") + FT_ERRORDEF_(Missing_Module, 0x0B, \ + "missing module") + FT_ERRORDEF_(Missing_Property, 0x0C, \ + "missing property") /* glyph/character errors */ - FT_ERRORDEF_( Invalid_Glyph_Index, 0x10, \ - "invalid glyph index" ) - FT_ERRORDEF_( Invalid_Character_Code, 0x11, \ - "invalid character code" ) - FT_ERRORDEF_( Invalid_Glyph_Format, 0x12, \ - "unsupported glyph image format" ) - FT_ERRORDEF_( Cannot_Render_Glyph, 0x13, \ - "cannot render this glyph format" ) - FT_ERRORDEF_( Invalid_Outline, 0x14, \ - "invalid outline" ) - FT_ERRORDEF_( Invalid_Composite, 0x15, \ - "invalid composite glyph" ) - FT_ERRORDEF_( Too_Many_Hints, 0x16, \ - "too many hints" ) - FT_ERRORDEF_( Invalid_Pixel_Size, 0x17, \ - "invalid pixel size" ) + FT_ERRORDEF_(Invalid_Glyph_Index, 0x10, \ + "invalid glyph index") + FT_ERRORDEF_(Invalid_Character_Code, 0x11, \ + "invalid character code") + FT_ERRORDEF_(Invalid_Glyph_Format, 0x12, \ + "unsupported glyph image format") + FT_ERRORDEF_(Cannot_Render_Glyph, 0x13, \ + "cannot render this glyph format") + FT_ERRORDEF_(Invalid_Outline, 0x14, \ + "invalid outline") + FT_ERRORDEF_(Invalid_Composite, 0x15, \ + "invalid composite glyph") + FT_ERRORDEF_(Too_Many_Hints, 0x16, \ + "too many hints") + FT_ERRORDEF_(Invalid_Pixel_Size, 0x17, \ + "invalid pixel size") /* handle errors */ - FT_ERRORDEF_( Invalid_Handle, 0x20, \ - "invalid object handle" ) - FT_ERRORDEF_( Invalid_Library_Handle, 0x21, \ - "invalid library handle" ) - FT_ERRORDEF_( Invalid_Driver_Handle, 0x22, \ - "invalid module handle" ) - FT_ERRORDEF_( Invalid_Face_Handle, 0x23, \ - "invalid face handle" ) - FT_ERRORDEF_( Invalid_Size_Handle, 0x24, \ - "invalid size handle" ) - FT_ERRORDEF_( Invalid_Slot_Handle, 0x25, \ - "invalid glyph slot handle" ) - FT_ERRORDEF_( Invalid_CharMap_Handle, 0x26, \ - "invalid charmap handle" ) - FT_ERRORDEF_( Invalid_Cache_Handle, 0x27, \ - "invalid cache manager handle" ) - FT_ERRORDEF_( Invalid_Stream_Handle, 0x28, \ - "invalid stream handle" ) + FT_ERRORDEF_(Invalid_Handle, 0x20, \ + "invalid object handle") + FT_ERRORDEF_(Invalid_Library_Handle, 0x21, \ + "invalid library handle") + FT_ERRORDEF_(Invalid_Driver_Handle, 0x22, \ + "invalid module handle") + FT_ERRORDEF_(Invalid_Face_Handle, 0x23, \ + "invalid face handle") + FT_ERRORDEF_(Invalid_Size_Handle, 0x24, \ + "invalid size handle") + FT_ERRORDEF_(Invalid_Slot_Handle, 0x25, \ + "invalid glyph slot handle") + FT_ERRORDEF_(Invalid_CharMap_Handle, 0x26, \ + "invalid charmap handle") + FT_ERRORDEF_(Invalid_Cache_Handle, 0x27, \ + "invalid cache manager handle") + FT_ERRORDEF_(Invalid_Stream_Handle, 0x28, \ + "invalid stream handle") /* driver errors */ - FT_ERRORDEF_( Too_Many_Drivers, 0x30, \ - "too many modules" ) - FT_ERRORDEF_( Too_Many_Extensions, 0x31, \ - "too many extensions" ) + FT_ERRORDEF_(Too_Many_Drivers, 0x30, \ + "too many modules") + FT_ERRORDEF_(Too_Many_Extensions, 0x31, \ + "too many extensions") /* memory errors */ - FT_ERRORDEF_( Out_Of_Memory, 0x40, \ - "out of memory" ) - FT_ERRORDEF_( Unlisted_Object, 0x41, \ - "unlisted object" ) + FT_ERRORDEF_(Out_Of_Memory, 0x40, \ + "out of memory") + FT_ERRORDEF_(Unlisted_Object, 0x41, \ + "unlisted object") /* stream errors */ - FT_ERRORDEF_( Cannot_Open_Stream, 0x51, \ - "cannot open stream" ) - FT_ERRORDEF_( Invalid_Stream_Seek, 0x52, \ - "invalid stream seek" ) - FT_ERRORDEF_( Invalid_Stream_Skip, 0x53, \ - "invalid stream skip" ) - FT_ERRORDEF_( Invalid_Stream_Read, 0x54, \ - "invalid stream read" ) - FT_ERRORDEF_( Invalid_Stream_Operation, 0x55, \ - "invalid stream operation" ) - FT_ERRORDEF_( Invalid_Frame_Operation, 0x56, \ - "invalid frame operation" ) - FT_ERRORDEF_( Nested_Frame_Access, 0x57, \ - "nested frame access" ) - FT_ERRORDEF_( Invalid_Frame_Read, 0x58, \ - "invalid frame read" ) + FT_ERRORDEF_(Cannot_Open_Stream, 0x51, \ + "cannot open stream") + FT_ERRORDEF_(Invalid_Stream_Seek, 0x52, \ + "invalid stream seek") + FT_ERRORDEF_(Invalid_Stream_Skip, 0x53, \ + "invalid stream skip") + FT_ERRORDEF_(Invalid_Stream_Read, 0x54, \ + "invalid stream read") + FT_ERRORDEF_(Invalid_Stream_Operation, 0x55, \ + "invalid stream operation") + FT_ERRORDEF_(Invalid_Frame_Operation, 0x56, \ + "invalid frame operation") + FT_ERRORDEF_(Nested_Frame_Access, 0x57, \ + "nested frame access") + FT_ERRORDEF_(Invalid_Frame_Read, 0x58, \ + "invalid frame read") /* raster errors */ - FT_ERRORDEF_( Raster_Uninitialized, 0x60, \ - "raster uninitialized" ) - FT_ERRORDEF_( Raster_Corrupted, 0x61, \ - "raster corrupted" ) - FT_ERRORDEF_( Raster_Overflow, 0x62, \ - "raster overflow" ) - FT_ERRORDEF_( Raster_Negative_Height, 0x63, \ - "negative height while rastering" ) + FT_ERRORDEF_(Raster_Uninitialized, 0x60, \ + "raster uninitialized") + FT_ERRORDEF_(Raster_Corrupted, 0x61, \ + "raster corrupted") + FT_ERRORDEF_(Raster_Overflow, 0x62, \ + "raster overflow") + FT_ERRORDEF_(Raster_Negative_Height, 0x63, \ + "negative height while rastering") /* cache errors */ - FT_ERRORDEF_( Too_Many_Caches, 0x70, \ - "too many registered caches" ) + FT_ERRORDEF_(Too_Many_Caches, 0x70, \ + "too many registered caches") /* TrueType and SFNT errors */ - FT_ERRORDEF_( Invalid_Opcode, 0x80, \ - "invalid opcode" ) - FT_ERRORDEF_( Too_Few_Arguments, 0x81, \ - "too few arguments" ) - FT_ERRORDEF_( Stack_Overflow, 0x82, \ - "stack overflow" ) - FT_ERRORDEF_( Code_Overflow, 0x83, \ - "code overflow" ) - FT_ERRORDEF_( Bad_Argument, 0x84, \ - "bad argument" ) - FT_ERRORDEF_( Divide_By_Zero, 0x85, \ - "division by zero" ) - FT_ERRORDEF_( Invalid_Reference, 0x86, \ - "invalid reference" ) - FT_ERRORDEF_( Debug_OpCode, 0x87, \ - "found debug opcode" ) - FT_ERRORDEF_( ENDF_In_Exec_Stream, 0x88, \ - "found ENDF opcode in execution stream" ) - FT_ERRORDEF_( Nested_DEFS, 0x89, \ - "nested DEFS" ) - FT_ERRORDEF_( Invalid_CodeRange, 0x8A, \ - "invalid code range" ) - FT_ERRORDEF_( Execution_Too_Long, 0x8B, \ - "execution context too long" ) - FT_ERRORDEF_( Too_Many_Function_Defs, 0x8C, \ - "too many function definitions" ) - FT_ERRORDEF_( Too_Many_Instruction_Defs, 0x8D, \ - "too many instruction definitions" ) - FT_ERRORDEF_( Table_Missing, 0x8E, \ - "SFNT font table missing" ) - FT_ERRORDEF_( Horiz_Header_Missing, 0x8F, \ - "horizontal header (hhea) table missing" ) - FT_ERRORDEF_( Locations_Missing, 0x90, \ - "locations (loca) table missing" ) - FT_ERRORDEF_( Name_Table_Missing, 0x91, \ - "name table missing" ) - FT_ERRORDEF_( CMap_Table_Missing, 0x92, \ - "character map (cmap) table missing" ) - FT_ERRORDEF_( Hmtx_Table_Missing, 0x93, \ - "horizontal metrics (hmtx) table missing" ) - FT_ERRORDEF_( Post_Table_Missing, 0x94, \ - "PostScript (post) table missing" ) - FT_ERRORDEF_( Invalid_Horiz_Metrics, 0x95, \ - "invalid horizontal metrics" ) - FT_ERRORDEF_( Invalid_CharMap_Format, 0x96, \ - "invalid character map (cmap) format" ) - FT_ERRORDEF_( Invalid_PPem, 0x97, \ - "invalid ppem value" ) - FT_ERRORDEF_( Invalid_Vert_Metrics, 0x98, \ - "invalid vertical metrics" ) - FT_ERRORDEF_( Could_Not_Find_Context, 0x99, \ - "could not find context" ) - FT_ERRORDEF_( Invalid_Post_Table_Format, 0x9A, \ - "invalid PostScript (post) table format" ) - FT_ERRORDEF_( Invalid_Post_Table, 0x9B, \ - "invalid PostScript (post) table" ) + FT_ERRORDEF_(Invalid_Opcode, 0x80, \ + "invalid opcode") + FT_ERRORDEF_(Too_Few_Arguments, 0x81, \ + "too few arguments") + FT_ERRORDEF_(Stack_Overflow, 0x82, \ + "stack overflow") + FT_ERRORDEF_(Code_Overflow, 0x83, \ + "code overflow") + FT_ERRORDEF_(Bad_Argument, 0x84, \ + "bad argument") + FT_ERRORDEF_(Divide_By_Zero, 0x85, \ + "division by zero") + FT_ERRORDEF_(Invalid_Reference, 0x86, \ + "invalid reference") + FT_ERRORDEF_(Debug_OpCode, 0x87, \ + "found debug opcode") + FT_ERRORDEF_(ENDF_In_Exec_Stream, 0x88, \ + "found ENDF opcode in execution stream") + FT_ERRORDEF_(Nested_DEFS, 0x89, \ + "nested DEFS") + FT_ERRORDEF_(Invalid_CodeRange, 0x8A, \ + "invalid code range") + FT_ERRORDEF_(Execution_Too_Long, 0x8B, \ + "execution context too long") + FT_ERRORDEF_(Too_Many_Function_Defs, 0x8C, \ + "too many function definitions") + FT_ERRORDEF_(Too_Many_Instruction_Defs, 0x8D, \ + "too many instruction definitions") + FT_ERRORDEF_(Table_Missing, 0x8E, \ + "SFNT font table missing") + FT_ERRORDEF_(Horiz_Header_Missing, 0x8F, \ + "horizontal header (hhea) table missing") + FT_ERRORDEF_(Locations_Missing, 0x90, \ + "locations (loca) table missing") + FT_ERRORDEF_(Name_Table_Missing, 0x91, \ + "name table missing") + FT_ERRORDEF_(CMap_Table_Missing, 0x92, \ + "character map (cmap) table missing") + FT_ERRORDEF_(Hmtx_Table_Missing, 0x93, \ + "horizontal metrics (hmtx) table missing") + FT_ERRORDEF_(Post_Table_Missing, 0x94, \ + "PostScript (post) table missing") + FT_ERRORDEF_(Invalid_Horiz_Metrics, 0x95, \ + "invalid horizontal metrics") + FT_ERRORDEF_(Invalid_CharMap_Format, 0x96, \ + "invalid character map (cmap) format") + FT_ERRORDEF_(Invalid_PPem, 0x97, \ + "invalid ppem value") + FT_ERRORDEF_(Invalid_Vert_Metrics, 0x98, \ + "invalid vertical metrics") + FT_ERRORDEF_(Could_Not_Find_Context, 0x99, \ + "could not find context") + FT_ERRORDEF_(Invalid_Post_Table_Format, 0x9A, \ + "invalid PostScript (post) table format") + FT_ERRORDEF_(Invalid_Post_Table, 0x9B, \ + "invalid PostScript (post) table") /* CFF, CID, and Type 1 errors */ - FT_ERRORDEF_( Syntax_Error, 0xA0, \ - "opcode syntax error" ) - FT_ERRORDEF_( Stack_Underflow, 0xA1, \ - "argument stack underflow" ) - FT_ERRORDEF_( Ignore, 0xA2, \ - "ignore" ) - FT_ERRORDEF_( No_Unicode_Glyph_Name, 0xA3, \ - "no Unicode glyph name found" ) - FT_ERRORDEF_( Glyph_Too_Big, 0xA4, \ - "glyph to big for hinting" ) + FT_ERRORDEF_(Syntax_Error, 0xA0, \ + "opcode syntax error") + FT_ERRORDEF_(Stack_Underflow, 0xA1, \ + "argument stack underflow") + FT_ERRORDEF_(Ignore, 0xA2, \ + "ignore") + FT_ERRORDEF_(No_Unicode_Glyph_Name, 0xA3, \ + "no Unicode glyph name found") + FT_ERRORDEF_(Glyph_Too_Big, 0xA4, \ + "glyph to big for hinting") /* BDF errors */ - FT_ERRORDEF_( Missing_Startfont_Field, 0xB0, \ - "`STARTFONT' field missing" ) - FT_ERRORDEF_( Missing_Font_Field, 0xB1, \ - "`FONT' field missing" ) - FT_ERRORDEF_( Missing_Size_Field, 0xB2, \ - "`SIZE' field missing" ) - FT_ERRORDEF_( Missing_Fontboundingbox_Field, 0xB3, \ - "`FONTBOUNDINGBOX' field missing" ) - FT_ERRORDEF_( Missing_Chars_Field, 0xB4, \ - "`CHARS' field missing" ) - FT_ERRORDEF_( Missing_Startchar_Field, 0xB5, \ - "`STARTCHAR' field missing" ) - FT_ERRORDEF_( Missing_Encoding_Field, 0xB6, \ - "`ENCODING' field missing" ) - FT_ERRORDEF_( Missing_Bbx_Field, 0xB7, \ - "`BBX' field missing" ) - FT_ERRORDEF_( Bbx_Too_Big, 0xB8, \ - "`BBX' too big" ) - FT_ERRORDEF_( Corrupted_Font_Header, 0xB9, \ - "Font header corrupted or missing fields" ) - FT_ERRORDEF_( Corrupted_Font_Glyphs, 0xBA, \ - "Font glyphs corrupted or missing fields" ) + FT_ERRORDEF_(Missing_Startfont_Field, 0xB0, \ + "`STARTFONT' field missing") + FT_ERRORDEF_(Missing_Font_Field, 0xB1, \ + "`FONT' field missing") + FT_ERRORDEF_(Missing_Size_Field, 0xB2, \ + "`SIZE' field missing") + FT_ERRORDEF_(Missing_Fontboundingbox_Field, 0xB3, \ + "`FONTBOUNDINGBOX' field missing") + FT_ERRORDEF_(Missing_Chars_Field, 0xB4, \ + "`CHARS' field missing") + FT_ERRORDEF_(Missing_Startchar_Field, 0xB5, \ + "`STARTCHAR' field missing") + FT_ERRORDEF_(Missing_Encoding_Field, 0xB6, \ + "`ENCODING' field missing") + FT_ERRORDEF_(Missing_Bbx_Field, 0xB7, \ + "`BBX' field missing") + FT_ERRORDEF_(Bbx_Too_Big, 0xB8, \ + "`BBX' too big") + FT_ERRORDEF_(Corrupted_Font_Header, 0xB9, \ + "Font header corrupted or missing fields") + FT_ERRORDEF_(Corrupted_Font_Glyphs, 0xBA, \ + "Font glyphs corrupted or missing fields") /* END */ diff --git a/include/freetype/fterrors.h b/include/freetype/fterrors.h index 0fa3e4d..0f92387 100644 --- a/include/freetype/fterrors.h +++ b/include/freetype/fterrors.h @@ -49,7 +49,7 @@ /* the error list. It is followed by several FT_ERROR_DEF calls */ /* (see below). */ /* */ - /* FT_ERROR_DEF( e, v, s ) :: */ + /* FT_ERROR_DEF(e, v, s) :: */ /* This macro is called to define one single error. */ /* `e' is the error code identifier (e.g. FT_Err_Invalid_Argument). */ /* `v' is the error numerical value. */ @@ -65,7 +65,7 @@ /* */ /* { */ /* #undef __FTERRORS_H__ */ - /* #define FT_ERRORDEF( e, v, s ) { e, s }, */ + /* #define FT_ERRORDEF(e, v, s) { e, s }, */ /* #define FT_ERROR_START_LIST { */ /* #define FT_ERROR_END_LIST { 0, 0 } }; */ /* */ @@ -130,9 +130,9 @@ /* */ #ifndef FT_ERRORDEF -#define FT_ERRORDEF( e, v, s ) e = v, +#define FT_ERRORDEF(e, v, s) e = v, #define FT_ERROR_START_LIST enum { -#define FT_ERROR_END_LIST FT_ERR_CAT( FT_ERR_PREFIX, Max ) }; +#define FT_ERROR_END_LIST FT_ERR_CAT(FT_ERR_PREFIX, Max) }; #ifdef __cplusplus #define FT_NEED_EXTERN_C @@ -143,12 +143,12 @@ /* this macro is used to define an error */ -#define FT_ERRORDEF_( e, v, s ) \ - FT_ERRORDEF( FT_ERR_CAT( FT_ERR_PREFIX, e ), v + FT_ERR_BASE, s ) +#define FT_ERRORDEF_(e, v, s) \ + FT_ERRORDEF(FT_ERR_CAT(FT_ERR_PREFIX, e), v + FT_ERR_BASE, s) /* this is only used for _Err_Ok, which must be 0! */ -#define FT_NOERRORDEF_( e, v, s ) \ - FT_ERRORDEF( FT_ERR_CAT( FT_ERR_PREFIX, e ), v, s ) +#define FT_NOERRORDEF_(e, v, s) \ + FT_ERRORDEF(FT_ERR_CAT(FT_ERR_PREFIX, e), v, s) #ifdef FT_ERROR_START_LIST diff --git a/include/freetype/ftgasp.h b/include/freetype/ftgasp.h index 453d4fa..4c49791 100644 --- a/include/freetype/ftgasp.h +++ b/include/freetype/ftgasp.h @@ -116,9 +116,9 @@ * @since: * 2.3.0 */ - FT_EXPORT( FT_Int ) - FT_Get_Gasp( FT_Face face, - FT_UInt ppem ); + FT_EXPORT(FT_Int) + FT_Get_Gasp(FT_Face face, + FT_UInt ppem); /* */ diff --git a/include/freetype/ftglyph.h b/include/freetype/ftglyph.h index 2d30ed9..35fd658 100644 --- a/include/freetype/ftglyph.h +++ b/include/freetype/ftglyph.h @@ -231,9 +231,9 @@ FT_BEGIN_HEADER /* */ /* FreeType error code. 0~means success. */ /* */ - FT_EXPORT( FT_Error ) - FT_Get_Glyph( FT_GlyphSlot slot, - FT_Glyph *aglyph ); + FT_EXPORT(FT_Error) + FT_Get_Glyph(FT_GlyphSlot slot, + FT_Glyph *aglyph); /*************************************************************************/ @@ -255,9 +255,9 @@ FT_BEGIN_HEADER /* */ /* FreeType error code. 0~means success. */ /* */ - FT_EXPORT( FT_Error ) - FT_Glyph_Copy( FT_Glyph source, - FT_Glyph *target ); + FT_EXPORT(FT_Error) + FT_Glyph_Copy(FT_Glyph source, + FT_Glyph *target); /*************************************************************************/ @@ -284,10 +284,10 @@ FT_BEGIN_HEADER /* The 2x2 transformation matrix is also applied to the glyph's */ /* advance vector. */ /* */ - FT_EXPORT( FT_Error ) - FT_Glyph_Transform( FT_Glyph glyph, + FT_EXPORT(FT_Error) + FT_Glyph_Transform(FT_Glyph glyph, FT_Matrix* matrix, - FT_Vector* delta ); + FT_Vector* delta); /*************************************************************************/ @@ -417,10 +417,10 @@ FT_BEGIN_HEADER /* To get the bbox in grid-fitted pixel coordinates, set `bbox_mode' */ /* to @FT_GLYPH_BBOX_PIXELS. */ /* */ - FT_EXPORT( void ) - FT_Glyph_Get_CBox( FT_Glyph glyph, + FT_EXPORT(void) + FT_Glyph_Get_CBox(FT_Glyph glyph, FT_UInt bbox_mode, - FT_BBox *acbox ); + FT_BBox *acbox); /*************************************************************************/ @@ -467,17 +467,17 @@ FT_BEGIN_HEADER /* */ /* */ /* // load glyph */ - /* error = FT_Load_Char( face, glyph_index, FT_LOAD_DEFAUT ); */ + /* error = FT_Load_Char(face, glyph_index, FT_LOAD_DEFAUT); */ /* */ /* // extract glyph image */ - /* error = FT_Get_Glyph( face->glyph, &glyph ); */ + /* error = FT_Get_Glyph(face->glyph, &glyph); */ /* */ /* // convert to a bitmap (default render mode + destroying old) */ - /* if ( glyph->format != FT_GLYPH_FORMAT_BITMAP ) */ + /* if (glyph->format != FT_GLYPH_FORMAT_BITMAP) */ /* { */ - /* error = FT_Glyph_To_Bitmap( &glyph, FT_RENDER_MODE_NORMAL, */ - /* 0, 1 ); */ - /* if ( error ) // `glyph' unchanged */ + /* error = FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, */ + /* 0, 1); */ + /* if (error) // `glyph' unchanged */ /* ... */ /* } */ /* */ @@ -488,7 +488,7 @@ FT_BEGIN_HEADER /* ... */ /* */ /* // discard glyph image (bitmap or not) */ - /* FT_Done_Glyph( glyph ); */ + /* FT_Done_Glyph(glyph); */ /* } */ /* */ /* */ @@ -501,13 +501,13 @@ FT_BEGIN_HEADER /* */ /* ... */ /* */ - /* for ( idx = 0; i < MAX_GLYPHS; i++ ) */ - /* error = FT_Load_Glyph( face, idx, FT_LOAD_DEFAULT ) || */ - /* FT_Get_Glyph ( face->glyph, &glyph[idx] ); */ + /* for (idx = 0; i < MAX_GLYPHS; i++) */ + /* error = FT_Load_Glyph(face, idx, FT_LOAD_DEFAULT) || */ + /* FT_Get_Glyph (face->glyph, &glyph[idx]); */ /* */ /* ... */ /* */ - /* for ( idx = 0; i < MAX_GLYPHS; i++ ) */ + /* for (idx = 0; i < MAX_GLYPHS; i++) */ /* { */ /* FT_Glyph bitmap = glyphs[idx]; */ /* */ @@ -516,24 +516,24 @@ FT_BEGIN_HEADER /* */ /* // after this call, `bitmap' no longer points into */ /* // the `glyphs' array (and the old value isn't destroyed) */ - /* FT_Glyph_To_Bitmap( &bitmap, FT_RENDER_MODE_MONO, 0, 0 ); */ + /* FT_Glyph_To_Bitmap(&bitmap, FT_RENDER_MODE_MONO, 0, 0); */ /* */ /* ... */ /* */ - /* FT_Done_Glyph( bitmap ); */ + /* FT_Done_Glyph(bitmap); */ /* } */ /* */ /* ... */ /* */ - /* for ( idx = 0; i < MAX_GLYPHS; i++ ) */ - /* FT_Done_Glyph( glyphs[idx] ); */ + /* for (idx = 0; i < MAX_GLYPHS; i++) */ + /* FT_Done_Glyph(glyphs[idx]); */ /* } */ /* */ - FT_EXPORT( FT_Error ) - FT_Glyph_To_Bitmap( FT_Glyph* the_glyph, + FT_EXPORT(FT_Error) + FT_Glyph_To_Bitmap(FT_Glyph* the_glyph, FT_Render_Mode render_mode, FT_Vector* origin, - FT_Bool destroy ); + FT_Bool destroy); /*************************************************************************/ @@ -547,8 +547,8 @@ FT_BEGIN_HEADER /* */ /* glyph :: A handle to the target glyph object. */ /* */ - FT_EXPORT( void ) - FT_Done_Glyph( FT_Glyph glyph ); + FT_EXPORT(void) + FT_Done_Glyph(FT_Glyph glyph); /* */ @@ -580,9 +580,9 @@ FT_BEGIN_HEADER /* */ /* The result is undefined if either `a' or `b' is zero. */ /* */ - FT_EXPORT( void ) - FT_Matrix_Multiply( const FT_Matrix* a, - FT_Matrix* b ); + FT_EXPORT(void) + FT_Matrix_Multiply(const FT_Matrix* a, + FT_Matrix* b); /*************************************************************************/ @@ -600,8 +600,8 @@ FT_BEGIN_HEADER /* */ /* FreeType error code. 0~means success. */ /* */ - FT_EXPORT( FT_Error ) - FT_Matrix_Invert( FT_Matrix* matrix ); + FT_EXPORT(FT_Error) + FT_Matrix_Invert(FT_Matrix* matrix); /* */ diff --git a/include/freetype/ftgxval.h b/include/freetype/ftgxval.h index 6d38e32..588e4e1 100644 --- a/include/freetype/ftgxval.h +++ b/include/freetype/ftgxval.h @@ -98,8 +98,8 @@ FT_BEGIN_HEADER /* Up to 0x1000 is used by otvalid. Ox2xxx is reserved for feature OT extension. */ #define FT_VALIDATE_GX_START 0x4000 -#define FT_VALIDATE_GX_BITFIELD( tag ) \ - ( FT_VALIDATE_GX_START << FT_VALIDATE_##tag##_INDEX ) +#define FT_VALIDATE_GX_BITFIELD(tag) \ + (FT_VALIDATE_GX_START << FT_VALIDATE_##tag##_INDEX) /********************************************************************** @@ -148,18 +148,18 @@ FT_BEGIN_HEADER * */ -#define FT_VALIDATE_feat FT_VALIDATE_GX_BITFIELD( feat ) -#define FT_VALIDATE_mort FT_VALIDATE_GX_BITFIELD( mort ) -#define FT_VALIDATE_morx FT_VALIDATE_GX_BITFIELD( morx ) -#define FT_VALIDATE_bsln FT_VALIDATE_GX_BITFIELD( bsln ) -#define FT_VALIDATE_just FT_VALIDATE_GX_BITFIELD( just ) -#define FT_VALIDATE_kern FT_VALIDATE_GX_BITFIELD( kern ) -#define FT_VALIDATE_opbd FT_VALIDATE_GX_BITFIELD( opbd ) -#define FT_VALIDATE_trak FT_VALIDATE_GX_BITFIELD( trak ) -#define FT_VALIDATE_prop FT_VALIDATE_GX_BITFIELD( prop ) -#define FT_VALIDATE_lcar FT_VALIDATE_GX_BITFIELD( lcar ) - -#define FT_VALIDATE_GX ( FT_VALIDATE_feat | \ +#define FT_VALIDATE_feat FT_VALIDATE_GX_BITFIELD(feat) +#define FT_VALIDATE_mort FT_VALIDATE_GX_BITFIELD(mort) +#define FT_VALIDATE_morx FT_VALIDATE_GX_BITFIELD(morx) +#define FT_VALIDATE_bsln FT_VALIDATE_GX_BITFIELD(bsln) +#define FT_VALIDATE_just FT_VALIDATE_GX_BITFIELD(just) +#define FT_VALIDATE_kern FT_VALIDATE_GX_BITFIELD(kern) +#define FT_VALIDATE_opbd FT_VALIDATE_GX_BITFIELD(opbd) +#define FT_VALIDATE_trak FT_VALIDATE_GX_BITFIELD(trak) +#define FT_VALIDATE_prop FT_VALIDATE_GX_BITFIELD(prop) +#define FT_VALIDATE_lcar FT_VALIDATE_GX_BITFIELD(lcar) + +#define FT_VALIDATE_GX (FT_VALIDATE_feat | \ FT_VALIDATE_mort | \ FT_VALIDATE_morx | \ FT_VALIDATE_bsln | \ @@ -168,7 +168,7 @@ FT_BEGIN_HEADER FT_VALIDATE_opbd | \ FT_VALIDATE_trak | \ FT_VALIDATE_prop | \ - FT_VALIDATE_lcar ) + FT_VALIDATE_lcar) /* */ @@ -214,11 +214,11 @@ FT_BEGIN_HEADER * application hasn't asked for validation, or the validator doesn't have * the ability to validate the sfnt table. */ - FT_EXPORT( FT_Error ) - FT_TrueTypeGX_Validate( FT_Face face, + FT_EXPORT(FT_Error) + FT_TrueTypeGX_Validate(FT_Face face, FT_UInt validation_flags, FT_Bytes tables[FT_VALIDATE_GX_LENGTH], - FT_UInt table_length ); + FT_UInt table_length); /* */ @@ -243,9 +243,9 @@ FT_BEGIN_HEADER * This function must be used to free the buffer allocated by * @FT_TrueTypeGX_Validate only. */ - FT_EXPORT( void ) - FT_TrueTypeGX_Free( FT_Face face, - FT_Bytes table ); + FT_EXPORT(void) + FT_TrueTypeGX_Free(FT_Face face, + FT_Bytes table); /* */ @@ -271,10 +271,10 @@ FT_BEGIN_HEADER * FT_VALIDATE_CKERN :: * Handle the `kern' as either classic Apple or Microsoft kern table. */ -#define FT_VALIDATE_MS ( FT_VALIDATE_GX_START << 0 ) -#define FT_VALIDATE_APPLE ( FT_VALIDATE_GX_START << 1 ) +#define FT_VALIDATE_MS (FT_VALIDATE_GX_START << 0) +#define FT_VALIDATE_APPLE (FT_VALIDATE_GX_START << 1) -#define FT_VALIDATE_CKERN ( FT_VALIDATE_MS | FT_VALIDATE_APPLE ) +#define FT_VALIDATE_CKERN (FT_VALIDATE_MS | FT_VALIDATE_APPLE) /* */ @@ -314,10 +314,10 @@ FT_BEGIN_HEADER * `ckern_table', by calling @FT_ClassicKern_Free. A NULL value * indicates that the table doesn't exist in the font. */ - FT_EXPORT( FT_Error ) - FT_ClassicKern_Validate( FT_Face face, + FT_EXPORT(FT_Error) + FT_ClassicKern_Validate(FT_Face face, FT_UInt validation_flags, - FT_Bytes *ckern_table ); + FT_Bytes *ckern_table); /* */ @@ -342,9 +342,9 @@ FT_BEGIN_HEADER * This function must be used to free the buffer allocated by * @FT_ClassicKern_Validate only. */ - FT_EXPORT( void ) - FT_ClassicKern_Free( FT_Face face, - FT_Bytes table ); + FT_EXPORT(void) + FT_ClassicKern_Free(FT_Face face, + FT_Bytes table); /* */ diff --git a/include/freetype/ftgzip.h b/include/freetype/ftgzip.h index 78e7269..faae844 100644 --- a/include/freetype/ftgzip.h +++ b/include/freetype/ftgzip.h @@ -87,9 +87,9 @@ FT_BEGIN_HEADER * This function may return `FT_Err_Unimplemented_Feature' if your build * of FreeType was not compiled with zlib support. */ - FT_EXPORT( FT_Error ) - FT_Stream_OpenGzip( FT_Stream stream, - FT_Stream source ); + FT_EXPORT(FT_Error) + FT_Stream_OpenGzip(FT_Stream stream, + FT_Stream source); /************************************************************************ @@ -130,12 +130,12 @@ FT_BEGIN_HEADER * This function may return `FT_Err_Unimplemented_Feature' if your build * of FreeType was not compiled with zlib support. */ - FT_EXPORT( FT_Error ) - FT_Gzip_Uncompress( FT_Memory memory, + FT_EXPORT(FT_Error) + FT_Gzip_Uncompress(FT_Memory memory, FT_Byte* output, FT_ULong* output_len, const FT_Byte* input, - FT_ULong input_len ); + FT_ULong input_len); /* */ diff --git a/include/freetype/ftimage.h b/include/freetype/ftimage.h index b66f036..27184c1 100644 --- a/include/freetype/ftimage.h +++ b/include/freetype/ftimage.h @@ -520,7 +520,7 @@ FT_BEGIN_HEADER /* */ -#define FT_CURVE_TAG( flag ) ( flag & 3 ) +#define FT_CURVE_TAG(flag) (flag & 3) #define FT_CURVE_TAG_ON 1 #define FT_CURVE_TAG_CONIC 0 @@ -531,8 +531,8 @@ FT_BEGIN_HEADER #define FT_CURVE_TAG_TOUCH_X 8 /* reserved for the TrueType hinter */ #define FT_CURVE_TAG_TOUCH_Y 16 /* reserved for the TrueType hinter */ -#define FT_CURVE_TAG_TOUCH_BOTH ( FT_CURVE_TAG_TOUCH_X | \ - FT_CURVE_TAG_TOUCH_Y ) +#define FT_CURVE_TAG_TOUCH_BOTH (FT_CURVE_TAG_TOUCH_X | \ + FT_CURVE_TAG_TOUCH_Y) #define FT_Curve_Tag_On FT_CURVE_TAG_ON #define FT_Curve_Tag_Conic FT_CURVE_TAG_CONIC @@ -562,8 +562,8 @@ FT_BEGIN_HEADER /* Error code. 0~means success. */ /* */ typedef int - (*FT_Outline_MoveToFunc)( const FT_Vector* to, - void* user ); + (*FT_Outline_MoveToFunc)(const FT_Vector* to, + void* user); #define FT_Outline_MoveTo_Func FT_Outline_MoveToFunc @@ -589,8 +589,8 @@ FT_BEGIN_HEADER /* Error code. 0~means success. */ /* */ typedef int - (*FT_Outline_LineToFunc)( const FT_Vector* to, - void* user ); + (*FT_Outline_LineToFunc)(const FT_Vector* to, + void* user); #define FT_Outline_LineTo_Func FT_Outline_LineToFunc @@ -620,9 +620,9 @@ FT_BEGIN_HEADER /* Error code. 0~means success. */ /* */ typedef int - (*FT_Outline_ConicToFunc)( const FT_Vector* control, + (*FT_Outline_ConicToFunc)(const FT_Vector* control, const FT_Vector* to, - void* user ); + void* user); #define FT_Outline_ConicTo_Func FT_Outline_ConicToFunc @@ -652,10 +652,10 @@ FT_BEGIN_HEADER /* Error code. 0~means success. */ /* */ typedef int - (*FT_Outline_CubicToFunc)( const FT_Vector* control1, + (*FT_Outline_CubicToFunc)(const FT_Vector* control1, const FT_Vector* control2, const FT_Vector* to, - void* user ); + void* user); #define FT_Outline_CubicTo_Func FT_Outline_CubicToFunc @@ -732,17 +732,17 @@ FT_BEGIN_HEADER /* this: */ /* */ /* { */ - /* #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) value */ + /* #define FT_IMAGE_TAG(value, _x1, _x2, _x3, _x4) value */ /* } */ /* */ /* to get a simple enumeration without assigning special numbers. */ /* */ #ifndef FT_IMAGE_TAG -#define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) \ - value = ( ( (unsigned long)_x1 << 24 ) | \ - ( (unsigned long)_x2 << 16 ) | \ - ( (unsigned long)_x3 << 8 ) | \ - (unsigned long)_x4 ) +#define FT_IMAGE_TAG(value, _x1, _x2, _x3, _x4) \ + value = (((unsigned long)_x1 << 24) | \ + ((unsigned long)_x2 << 16) | \ + ((unsigned long)_x3 << 8) | \ + (unsigned long)_x4 ) #endif /* FT_IMAGE_TAG */ @@ -786,12 +786,12 @@ FT_BEGIN_HEADER /* */ typedef enum FT_Glyph_Format_ { - FT_IMAGE_TAG( FT_GLYPH_FORMAT_NONE, 0, 0, 0, 0 ), + FT_IMAGE_TAG(FT_GLYPH_FORMAT_NONE, 0, 0, 0, 0), - FT_IMAGE_TAG( FT_GLYPH_FORMAT_COMPOSITE, 'c', 'o', 'm', 'p' ), - FT_IMAGE_TAG( FT_GLYPH_FORMAT_BITMAP, 'b', 'i', 't', 's' ), - FT_IMAGE_TAG( FT_GLYPH_FORMAT_OUTLINE, 'o', 'u', 't', 'l' ), - FT_IMAGE_TAG( FT_GLYPH_FORMAT_PLOTTER, 'p', 'l', 'o', 't' ) + FT_IMAGE_TAG(FT_GLYPH_FORMAT_COMPOSITE, 'c', 'o', 'm', 'p'), + FT_IMAGE_TAG(FT_GLYPH_FORMAT_BITMAP, 'b', 'i', 't', 's'), + FT_IMAGE_TAG(FT_GLYPH_FORMAT_OUTLINE, 'o', 'u', 't', 'l'), + FT_IMAGE_TAG(FT_GLYPH_FORMAT_PLOTTER, 'p', 'l', 'o', 't') } FT_Glyph_Format; @@ -943,10 +943,10 @@ FT_BEGIN_HEADER /* only for those scanlines that do have `gray' pixels on them. */ /* */ typedef void - (*FT_SpanFunc)( int y, + (*FT_SpanFunc)(int y, int count, const FT_Span* spans, - void* user ); + void* user); #define FT_Raster_Span_Func FT_SpanFunc @@ -975,9 +975,9 @@ FT_BEGIN_HEADER /* 1~if the pixel is `set', 0~otherwise. */ /* */ typedef int - (*FT_Raster_BitTest_Func)( int y, + (*FT_Raster_BitTest_Func)(int y, int x, - void* user ); + void* user); /*************************************************************************/ @@ -1003,9 +1003,9 @@ FT_BEGIN_HEADER /* 1~if the pixel is `set', 0~otherwise. */ /* */ typedef void - (*FT_Raster_BitSet_Func)( int y, + (*FT_Raster_BitSet_Func)(int y, int x, - void* user ); + void* user); /*************************************************************************/ @@ -1150,8 +1150,8 @@ FT_BEGIN_HEADER /* completely ignored by a given raster implementation. */ /* */ typedef int - (*FT_Raster_NewFunc)( void* memory, - FT_Raster* raster ); + (*FT_Raster_NewFunc)(void* memory, + FT_Raster* raster); #define FT_Raster_New_Func FT_Raster_NewFunc @@ -1168,7 +1168,7 @@ FT_BEGIN_HEADER /* raster :: A handle to the raster object. */ /* */ typedef void - (*FT_Raster_DoneFunc)( FT_Raster raster ); + (*FT_Raster_DoneFunc)(FT_Raster raster); #define FT_Raster_Done_Func FT_Raster_DoneFunc @@ -1201,9 +1201,9 @@ FT_BEGIN_HEADER /* recommended for efficiency purposes. */ /* */ typedef void - (*FT_Raster_ResetFunc)( FT_Raster raster, + (*FT_Raster_ResetFunc)(FT_Raster raster, unsigned char* pool_base, - unsigned long pool_size ); + unsigned long pool_size); #define FT_Raster_Reset_Func FT_Raster_ResetFunc @@ -1227,9 +1227,9 @@ FT_BEGIN_HEADER /* args :: A pointer to the new mode/property to use. */ /* */ typedef int - (*FT_Raster_SetModeFunc)( FT_Raster raster, + (*FT_Raster_SetModeFunc)(FT_Raster raster, unsigned long mode, - void* args ); + void* args); #define FT_Raster_Set_Mode_Func FT_Raster_SetModeFunc @@ -1269,8 +1269,8 @@ FT_BEGIN_HEADER /* composition). */ /* */ typedef int - (*FT_Raster_RenderFunc)( FT_Raster raster, - const FT_Raster_Params* params ); + (*FT_Raster_RenderFunc)(FT_Raster raster, + const FT_Raster_Params* params); #define FT_Raster_Render_Func FT_Raster_RenderFunc diff --git a/include/freetype/ftincrem.h b/include/freetype/ftincrem.h index aaf689f..ced4891 100644 --- a/include/freetype/ftincrem.h +++ b/include/freetype/ftincrem.h @@ -176,9 +176,9 @@ FT_BEGIN_HEADER * */ typedef FT_Error - (*FT_Incremental_GetGlyphDataFunc)( FT_Incremental incremental, + (*FT_Incremental_GetGlyphDataFunc)(FT_Incremental incremental, FT_UInt glyph_index, - FT_Data* adata ); + FT_Data* adata); /*************************************************************************** @@ -201,8 +201,8 @@ FT_BEGIN_HEADER * */ typedef void - (*FT_Incremental_FreeGlyphDataFunc)( FT_Incremental incremental, - FT_Data* data ); + (*FT_Incremental_FreeGlyphDataFunc)(FT_Incremental incremental, + FT_Data* data); /*************************************************************************** @@ -239,10 +239,10 @@ FT_BEGIN_HEADER */ typedef FT_Error (*FT_Incremental_GetGlyphMetricsFunc) - ( FT_Incremental incremental, + (FT_Incremental incremental, FT_UInt glyph_index, FT_Bool vertical, - FT_Incremental_MetricsRec *ametrics ); + FT_Incremental_MetricsRec *ametrics); /************************************************************************** @@ -306,7 +306,7 @@ FT_BEGIN_HEADER * open_args.params = ¶meter; // we use one optional argument * * // open the font - * error = FT_Open_Face( library, &open_args, index, &face ); + * error = FT_Open_Face(library, &open_args, index, &face); * ... * } * @@ -341,7 +341,7 @@ FT_BEGIN_HEADER * an incremental loading object to be used by FreeType. * */ -#define FT_PARAM_TAG_INCREMENTAL FT_MAKE_TAG( 'i', 'n', 'c', 'r' ) +#define FT_PARAM_TAG_INCREMENTAL FT_MAKE_TAG('i', 'n', 'c', 'r') /* */ diff --git a/include/freetype/ftlcdfil.h b/include/freetype/ftlcdfil.h index 39206f0..9a42d6e 100644 --- a/include/freetype/ftlcdfil.h +++ b/include/freetype/ftlcdfil.h @@ -195,9 +195,9 @@ FT_BEGIN_HEADER * @since: * 2.3.0 */ - FT_EXPORT( FT_Error ) - FT_Library_SetLcdFilter( FT_Library library, - FT_LcdFilter filter ); + FT_EXPORT(FT_Error) + FT_Library_SetLcdFilter(FT_Library library, + FT_LcdFilter filter); /************************************************************************** @@ -236,9 +236,9 @@ FT_BEGIN_HEADER * @since: * 2.4.0 */ - FT_EXPORT( FT_Error ) - FT_Library_SetLcdFilterWeights( FT_Library library, - unsigned char *weights ); + FT_EXPORT(FT_Error) + FT_Library_SetLcdFilterWeights(FT_Library library, + unsigned char *weights); /* */ diff --git a/include/freetype/ftlist.h b/include/freetype/ftlist.h index 241e21e..4153ecc 100644 --- a/include/freetype/ftlist.h +++ b/include/freetype/ftlist.h @@ -90,9 +90,9 @@ FT_BEGIN_HEADER /* */ /* List node. NULL if it wasn't found. */ /* */ - FT_EXPORT( FT_ListNode ) - FT_List_Find( FT_List list, - void* data ); + FT_EXPORT(FT_ListNode) + FT_List_Find(FT_List list, + void* data); /*************************************************************************/ @@ -107,9 +107,9 @@ FT_BEGIN_HEADER /* list :: A pointer to the parent list. */ /* node :: The node to append. */ /* */ - FT_EXPORT( void ) - FT_List_Add( FT_List list, - FT_ListNode node ); + FT_EXPORT(void) + FT_List_Add(FT_List list, + FT_ListNode node); /*************************************************************************/ @@ -124,9 +124,9 @@ FT_BEGIN_HEADER /* list :: A pointer to parent list. */ /* node :: The node to insert. */ /* */ - FT_EXPORT( void ) - FT_List_Insert( FT_List list, - FT_ListNode node ); + FT_EXPORT(void) + FT_List_Insert(FT_List list, + FT_ListNode node); /*************************************************************************/ @@ -144,9 +144,9 @@ FT_BEGIN_HEADER /* */ /* list :: A pointer to the parent list. */ /* */ - FT_EXPORT( void ) - FT_List_Remove( FT_List list, - FT_ListNode node ); + FT_EXPORT(void) + FT_List_Remove(FT_List list, + FT_ListNode node); /*************************************************************************/ @@ -162,9 +162,9 @@ FT_BEGIN_HEADER /* list :: A pointer to the parent list. */ /* node :: The node to move. */ /* */ - FT_EXPORT( void ) - FT_List_Up( FT_List list, - FT_ListNode node ); + FT_EXPORT(void) + FT_List_Up(FT_List list, + FT_ListNode node); /*************************************************************************/ @@ -183,8 +183,8 @@ FT_BEGIN_HEADER /* Can be used to point to the iteration's state. */ /* */ typedef FT_Error - (*FT_List_Iterator)( FT_ListNode node, - void* user ); + (*FT_List_Iterator)(FT_ListNode node, + void* user); /*************************************************************************/ @@ -206,10 +206,10 @@ FT_BEGIN_HEADER /* */ /* The result (a FreeType error code) of the last iterator call. */ /* */ - FT_EXPORT( FT_Error ) - FT_List_Iterate( FT_List list, + FT_EXPORT(FT_Error) + FT_List_Iterate(FT_List list, FT_List_Iterator iterator, - void* user ); + void* user); /*************************************************************************/ @@ -231,9 +231,9 @@ FT_BEGIN_HEADER /* be used to point to the iteration's state. */ /* */ typedef void - (*FT_List_Destructor)( FT_Memory memory, + (*FT_List_Destructor)(FT_Memory memory, void* data, - void* user ); + void* user); /*************************************************************************/ @@ -259,11 +259,11 @@ FT_BEGIN_HEADER /* This function expects that all nodes added by @FT_List_Add or */ /* @FT_List_Insert have been dynamically allocated. */ /* */ - FT_EXPORT( void ) - FT_List_Finalize( FT_List list, + FT_EXPORT(void) + FT_List_Finalize(FT_List list, FT_List_Destructor destroy, FT_Memory memory, - void* user ); + void* user); /* */ diff --git a/include/freetype/ftlzw.h b/include/freetype/ftlzw.h index 00d4016..3ea5077 100644 --- a/include/freetype/ftlzw.h +++ b/include/freetype/ftlzw.h @@ -84,9 +84,9 @@ FT_BEGIN_HEADER * This function may return `FT_Err_Unimplemented_Feature' if your build * of FreeType was not compiled with LZW support. */ - FT_EXPORT( FT_Error ) - FT_Stream_OpenLZW( FT_Stream stream, - FT_Stream source ); + FT_EXPORT(FT_Error) + FT_Stream_OpenLZW(FT_Stream stream, + FT_Stream source); /* */ diff --git a/include/freetype/ftmac.h b/include/freetype/ftmac.h index 42874fe..8376e41 100644 --- a/include/freetype/ftmac.h +++ b/include/freetype/ftmac.h @@ -92,15 +92,15 @@ FT_BEGIN_HEADER /* that are installed in the system as follows. */ /* */ /* { */ - /* fond = GetResource( 'FOND', fontName ); */ - /* error = FT_New_Face_From_FOND( library, fond, 0, &face ); */ + /* fond = GetResource('FOND', fontName); */ + /* error = FT_New_Face_From_FOND(library, fond, 0, &face); */ /* } */ /* */ - FT_EXPORT( FT_Error ) - FT_New_Face_From_FOND( FT_Library library, + FT_EXPORT(FT_Error) + FT_New_Face_From_FOND(FT_Library library, Handle fond, FT_Long face_index, - FT_Face *aface ) + FT_Face *aface) FT_DEPRECATED_ATTRIBUTE; @@ -126,10 +126,10 @@ FT_BEGIN_HEADER /* */ /* FreeType error code. 0~means success. */ /* */ - FT_EXPORT( FT_Error ) - FT_GetFile_From_Mac_Name( const char* fontName, + FT_EXPORT(FT_Error) + FT_GetFile_From_Mac_Name(const char* fontName, FSSpec* pathSpec, - FT_Long* face_index ) + FT_Long* face_index) FT_DEPRECATED_ATTRIBUTE; @@ -154,10 +154,10 @@ FT_BEGIN_HEADER /* */ /* FreeType error code. 0~means success. */ /* */ - FT_EXPORT( FT_Error ) - FT_GetFile_From_Mac_ATS_Name( const char* fontName, + FT_EXPORT(FT_Error) + FT_GetFile_From_Mac_ATS_Name(const char* fontName, FSSpec* pathSpec, - FT_Long* face_index ) + FT_Long* face_index) FT_DEPRECATED_ATTRIBUTE; @@ -185,11 +185,11 @@ FT_BEGIN_HEADER /* */ /* FreeType error code. 0~means success. */ /* */ - FT_EXPORT( FT_Error ) - FT_GetFilePath_From_Mac_ATS_Name( const char* fontName, + FT_EXPORT(FT_Error) + FT_GetFilePath_From_Mac_ATS_Name(const char* fontName, UInt8* path, UInt32 maxPathSize, - FT_Long* face_index ) + FT_Long* face_index) FT_DEPRECATED_ATTRIBUTE; @@ -220,11 +220,11 @@ FT_BEGIN_HEADER /* @FT_New_Face_From_FSSpec is identical to @FT_New_Face except */ /* it accepts an FSSpec instead of a path. */ /* */ - FT_EXPORT( FT_Error ) - FT_New_Face_From_FSSpec( FT_Library library, + FT_EXPORT(FT_Error) + FT_New_Face_From_FSSpec(FT_Library library, const FSSpec *spec, FT_Long face_index, - FT_Face *aface ) + FT_Face *aface) FT_DEPRECATED_ATTRIBUTE; @@ -255,11 +255,11 @@ FT_BEGIN_HEADER /* @FT_New_Face_From_FSRef is identical to @FT_New_Face except */ /* it accepts an FSRef instead of a path. */ /* */ - FT_EXPORT( FT_Error ) - FT_New_Face_From_FSRef( FT_Library library, + FT_EXPORT(FT_Error) + FT_New_Face_From_FSRef(FT_Library library, const FSRef *ref, FT_Long face_index, - FT_Face *aface ) + FT_Face *aface) FT_DEPRECATED_ATTRIBUTE; /* */ diff --git a/include/freetype/ftmm.h b/include/freetype/ftmm.h index 837975a..0e1b274 100644 --- a/include/freetype/ftmm.h +++ b/include/freetype/ftmm.h @@ -240,9 +240,9 @@ FT_BEGIN_HEADER /* */ /* FreeType error code. 0~means success. */ /* */ - FT_EXPORT( FT_Error ) - FT_Get_Multi_Master( FT_Face face, - FT_Multi_Master *amaster ); + FT_EXPORT(FT_Error) + FT_Get_Multi_Master(FT_Face face, + FT_Multi_Master *amaster); /*************************************************************************/ @@ -263,9 +263,9 @@ FT_BEGIN_HEADER /* */ /* FreeType error code. 0~means success. */ /* */ - FT_EXPORT( FT_Error ) - FT_Get_MM_Var( FT_Face face, - FT_MM_Var* *amaster ); + FT_EXPORT(FT_Error) + FT_Get_MM_Var(FT_Face face, + FT_MM_Var* *amaster); /*************************************************************************/ @@ -291,10 +291,10 @@ FT_BEGIN_HEADER /* */ /* FreeType error code. 0~means success. */ /* */ - FT_EXPORT( FT_Error ) - FT_Set_MM_Design_Coordinates( FT_Face face, + FT_EXPORT(FT_Error) + FT_Set_MM_Design_Coordinates(FT_Face face, FT_UInt num_coords, - FT_Long* coords ); + FT_Long* coords); /*************************************************************************/ @@ -318,10 +318,10 @@ FT_BEGIN_HEADER /* */ /* FreeType error code. 0~means success. */ /* */ - FT_EXPORT( FT_Error ) - FT_Set_Var_Design_Coordinates( FT_Face face, + FT_EXPORT(FT_Error) + FT_Set_Var_Design_Coordinates(FT_Face face, FT_UInt num_coords, - FT_Fixed* coords ); + FT_Fixed* coords); /*************************************************************************/ @@ -346,10 +346,10 @@ FT_BEGIN_HEADER /* */ /* FreeType error code. 0~means success. */ /* */ - FT_EXPORT( FT_Error ) - FT_Set_MM_Blend_Coordinates( FT_Face face, + FT_EXPORT(FT_Error) + FT_Set_MM_Blend_Coordinates(FT_Face face, FT_UInt num_coords, - FT_Fixed* coords ); + FT_Fixed* coords); /*************************************************************************/ @@ -360,10 +360,10 @@ FT_BEGIN_HEADER /* */ /* This is another name of @FT_Set_MM_Blend_Coordinates. */ /* */ - FT_EXPORT( FT_Error ) - FT_Set_Var_Blend_Coordinates( FT_Face face, + FT_EXPORT(FT_Error) + FT_Set_Var_Blend_Coordinates(FT_Face face, FT_UInt num_coords, - FT_Fixed* coords ); + FT_Fixed* coords); /* */ diff --git a/include/freetype/ftmodapi.h b/include/freetype/ftmodapi.h index 22878f8..6f37f90 100644 --- a/include/freetype/ftmodapi.h +++ b/include/freetype/ftmodapi.h @@ -118,7 +118,7 @@ FT_BEGIN_HEADER /* module :: The module to initialize. */ /* */ typedef FT_Error - (*FT_Module_Constructor)( FT_Module module ); + (*FT_Module_Constructor)(FT_Module module); /*************************************************************************/ @@ -133,7 +133,7 @@ FT_BEGIN_HEADER /* module :: The module to finalize. */ /* */ typedef void - (*FT_Module_Destructor)( FT_Module module ); + (*FT_Module_Destructor)(FT_Module module); /*************************************************************************/ @@ -150,8 +150,8 @@ FT_BEGIN_HEADER /* name :: The name of the interface in the module. */ /* */ typedef FT_Module_Interface - (*FT_Module_Requester)( FT_Module module, - const char* name ); + (*FT_Module_Requester)(FT_Module module, + const char* name); /*************************************************************************/ @@ -221,9 +221,9 @@ FT_BEGIN_HEADER /* An error will be returned if a module already exists by that name, */ /* or if the module requires a version of FreeType that is too great. */ /* */ - FT_EXPORT( FT_Error ) - FT_Add_Module( FT_Library library, - const FT_Module_Class* clazz ); + FT_EXPORT(FT_Error) + FT_Add_Module(FT_Library library, + const FT_Module_Class* clazz); /*************************************************************************/ @@ -246,9 +246,9 @@ FT_BEGIN_HEADER /* FreeType's internal modules aren't documented very well, and you */ /* should look up the source code for details. */ /* */ - FT_EXPORT( FT_Module ) - FT_Get_Module( FT_Library library, - const char* module_name ); + FT_EXPORT(FT_Module) + FT_Get_Module(FT_Library library, + const char* module_name); /*************************************************************************/ @@ -271,9 +271,9 @@ FT_BEGIN_HEADER /* */ /* The module object is destroyed by the function in case of success. */ /* */ - FT_EXPORT( FT_Error ) - FT_Remove_Module( FT_Library library, - FT_Module module ); + FT_EXPORT(FT_Error) + FT_Remove_Module(FT_Library library, + FT_Module module); /********************************************************************** @@ -319,7 +319,7 @@ FT_BEGIN_HEADER * * * bar = 1; - * FT_Property_Set( library, "foo", "bar", &bar ); + * FT_Property_Set(library, "foo", "bar", &bar); * } * * Note that the FreeType Cache sub-system doesn't recognize module @@ -336,11 +336,11 @@ FT_BEGIN_HEADER * 2.4.11 * */ - FT_EXPORT( FT_Error ) - FT_Property_Set( FT_Library library, + FT_EXPORT(FT_Error) + FT_Property_Set(FT_Library library, const FT_String* module_name, const FT_String* property_name, - const void* value ); + const void* value); /********************************************************************** @@ -390,7 +390,7 @@ FT_BEGIN_HEADER * range baz; * * - * FT_Property_Get( library, "foo", "baz", &baz ); + * FT_Property_Get(library, "foo", "baz", &baz); * } * * It is not possible to retrieve properties of the FreeType Cache @@ -400,11 +400,11 @@ FT_BEGIN_HEADER * 2.4.11 * */ - FT_EXPORT( FT_Error ) - FT_Property_Get( FT_Library library, + FT_EXPORT(FT_Error) + FT_Property_Get(FT_Library library, const FT_String* module_name, const FT_String* property_name, - void* value ); + void* value); /*************************************************************************/ @@ -430,8 +430,8 @@ FT_BEGIN_HEADER /* */ /* 2.4.2 */ /* */ - FT_EXPORT( FT_Error ) - FT_Reference_Library( FT_Library library ); + FT_EXPORT(FT_Error) + FT_Reference_Library(FT_Library library); /*************************************************************************/ @@ -464,9 +464,9 @@ FT_BEGIN_HEADER /* See the discussion of reference counters in the description of */ /* @FT_Reference_Library. */ /* */ - FT_EXPORT( FT_Error ) - FT_New_Library( FT_Memory memory, - FT_Library *alibrary ); + FT_EXPORT(FT_Error) + FT_New_Library(FT_Memory memory, + FT_Library *alibrary); /*************************************************************************/ @@ -488,13 +488,13 @@ FT_BEGIN_HEADER /* See the discussion of reference counters in the description of */ /* @FT_Reference_Library. */ /* */ - FT_EXPORT( FT_Error ) - FT_Done_Library( FT_Library library ); + FT_EXPORT(FT_Error) + FT_Done_Library(FT_Library library); /* */ typedef void - (*FT_DebugHook_Func)( void* arg ); + (*FT_DebugHook_Func)(void* arg); /*************************************************************************/ @@ -524,10 +524,10 @@ FT_BEGIN_HEADER /* the symbol `FT_DEBUG_HOOK_TRUETYPE' isn't available publicly. */ /* This is a bug and will be fixed in a forthcoming release. */ /* */ - FT_EXPORT( void ) - FT_Set_Debug_Hook( FT_Library library, + FT_EXPORT(void) + FT_Set_Debug_Hook(FT_Library library, FT_UInt hook_index, - FT_DebugHook_Func debug_hook ); + FT_DebugHook_Func debug_hook); /*************************************************************************/ @@ -543,8 +543,8 @@ FT_BEGIN_HEADER /* */ /* library :: A handle to a new library object. */ /* */ - FT_EXPORT( void ) - FT_Add_Default_Modules( FT_Library library ); + FT_EXPORT(void) + FT_Add_Default_Modules(FT_Library library); @@ -626,8 +626,8 @@ FT_BEGIN_HEADER * 2.2 * */ - FT_EXPORT( FT_TrueTypeEngineType ) - FT_Get_TrueType_Engine_Type( FT_Library library ); + FT_EXPORT(FT_TrueTypeEngineType) + FT_Get_TrueType_Engine_Type(FT_Library library); /* */ diff --git a/include/freetype/ftmoderr.h b/include/freetype/ftmoderr.h index 5a27db1..75470b7 100644 --- a/include/freetype/ftmoderr.h +++ b/include/freetype/ftmoderr.h @@ -36,37 +36,37 @@ /* To hide the various `XXX_Err_' prefixes in the source code, FreeType */ /* provides some macros in `fttypes.h'. */ /* */ - /* FT_ERR( err ) */ + /* FT_ERR(err) */ /* Add current error module prefix (as defined with the */ /* `FT_ERR_PREFIX' macro) to `err'. For example, in the BDF module */ /* the line */ /* */ - /* error = FT_ERR( Invalid_Outline ); */ + /* error = FT_ERR(Invalid_Outline); */ /* */ /* expands to */ /* */ /* error = BDF_Err_Invalid_Outline; */ /* */ /* For simplicity, you can always use `FT_Err_Ok' directly instead */ - /* of `FT_ERR( Ok )'. */ + /* of `FT_ERR(Ok)'. */ /* */ - /* FT_ERR_EQ( errcode, err ) */ - /* FT_ERR_NEQ( errcode, err ) */ + /* FT_ERR_EQ(errcode, err) */ + /* FT_ERR_NEQ(errcode, err) */ /* Compare error code `errcode' with the error `err' for equality */ /* and inequality, respectively. Example: */ /* */ - /* if ( FT_ERR_EQ( error, Invalid_Outline ) ) */ + /* if (FT_ERR_EQ(error, Invalid_Outline)) */ /* ... */ /* */ /* Using this macro you don't have to think about error prefixes. */ /* Of course, if module errors are not active, the above example is */ /* the same as */ /* */ - /* if ( error == FT_Err_Invalid_Outline ) */ + /* if (error == FT_Err_Invalid_Outline) */ /* ... */ /* */ - /* FT_ERROR_BASE( errcode ) */ - /* FT_ERROR_MODULE( errcode ) */ + /* FT_ERROR_BASE(errcode) */ + /* FT_ERROR_MODULE(errcode) */ /* Get base error and module error code, respectively. */ /* */ /* */ @@ -75,7 +75,7 @@ /* */ /* { */ /* #undef __FTMODERR_H__ */ - /* #define FT_MODERRDEF( e, v, s ) { FT_Mod_Err_ ## e, s }, */ + /* #define FT_MODERRDEF(e, v, s) { FT_Mod_Err_ ## e, s }, */ /* #define FT_MODERR_START_LIST { */ /* #define FT_MODERR_END_LIST { 0, 0 } }; */ /* */ @@ -109,9 +109,9 @@ #ifndef FT_MODERRDEF #ifdef FT_CONFIG_OPTION_USE_MODULE_ERRORS -#define FT_MODERRDEF( e, v, s ) FT_Mod_Err_ ## e = v, +#define FT_MODERRDEF(e, v, s) FT_Mod_Err_ ## e = v, #else -#define FT_MODERRDEF( e, v, s ) FT_Mod_Err_ ## e = 0, +#define FT_MODERRDEF(e, v, s) FT_Mod_Err_ ## e = 0, #endif #define FT_MODERR_START_LIST enum { @@ -139,29 +139,29 @@ #endif - FT_MODERRDEF( Base, 0x000, "base module" ) - FT_MODERRDEF( Autofit, 0x100, "autofitter module" ) - FT_MODERRDEF( BDF, 0x200, "BDF module" ) - FT_MODERRDEF( Bzip2, 0x300, "Bzip2 module" ) - FT_MODERRDEF( Cache, 0x400, "cache module" ) - FT_MODERRDEF( CFF, 0x500, "CFF module" ) - FT_MODERRDEF( CID, 0x600, "CID module" ) - FT_MODERRDEF( Gzip, 0x700, "Gzip module" ) - FT_MODERRDEF( LZW, 0x800, "LZW module" ) - FT_MODERRDEF( OTvalid, 0x900, "OpenType validation module" ) - FT_MODERRDEF( PCF, 0xA00, "PCF module" ) - FT_MODERRDEF( PFR, 0xB00, "PFR module" ) - FT_MODERRDEF( PSaux, 0xC00, "PS auxiliary module" ) - FT_MODERRDEF( PShinter, 0xD00, "PS hinter module" ) - FT_MODERRDEF( PSnames, 0xE00, "PS names module" ) - FT_MODERRDEF( Raster, 0xF00, "raster module" ) - FT_MODERRDEF( SFNT, 0x1000, "SFNT module" ) - FT_MODERRDEF( Smooth, 0x1100, "smooth raster module" ) - FT_MODERRDEF( TrueType, 0x1200, "TrueType module" ) - FT_MODERRDEF( Type1, 0x1300, "Type 1 module" ) - FT_MODERRDEF( Type42, 0x1400, "Type 42 module" ) - FT_MODERRDEF( Winfonts, 0x1500, "Windows FON/FNT module" ) - FT_MODERRDEF( GXvalid, 0x1600, "GX validation module" ) + FT_MODERRDEF(Base, 0x000, "base module") + FT_MODERRDEF(Autofit, 0x100, "autofitter module") + FT_MODERRDEF(BDF, 0x200, "BDF module") + FT_MODERRDEF(Bzip2, 0x300, "Bzip2 module") + FT_MODERRDEF(Cache, 0x400, "cache module") + FT_MODERRDEF(CFF, 0x500, "CFF module") + FT_MODERRDEF(CID, 0x600, "CID module") + FT_MODERRDEF(Gzip, 0x700, "Gzip module") + FT_MODERRDEF(LZW, 0x800, "LZW module") + FT_MODERRDEF(OTvalid, 0x900, "OpenType validation module") + FT_MODERRDEF(PCF, 0xA00, "PCF module") + FT_MODERRDEF(PFR, 0xB00, "PFR module") + FT_MODERRDEF(PSaux, 0xC00, "PS auxiliary module") + FT_MODERRDEF(PShinter, 0xD00, "PS hinter module") + FT_MODERRDEF(PSnames, 0xE00, "PS names module") + FT_MODERRDEF(Raster, 0xF00, "raster module") + FT_MODERRDEF(SFNT, 0x1000, "SFNT module") + FT_MODERRDEF(Smooth, 0x1100, "smooth raster module") + FT_MODERRDEF(TrueType, 0x1200, "TrueType module") + FT_MODERRDEF(Type1, 0x1300, "Type 1 module") + FT_MODERRDEF(Type42, 0x1400, "Type 42 module") + FT_MODERRDEF(Winfonts, 0x1500, "Windows FON/FNT module") + FT_MODERRDEF(GXvalid, 0x1600, "GX validation module") #ifdef FT_MODERR_END_LIST diff --git a/include/freetype/ftotval.h b/include/freetype/ftotval.h index bb52dc4..9fe3bc6 100644 --- a/include/freetype/ftotval.h +++ b/include/freetype/ftotval.h @@ -156,14 +156,14 @@ FT_BEGIN_HEADER * doesn't exist in the font, or the application hasn't asked for * validation. */ - FT_EXPORT( FT_Error ) - FT_OpenType_Validate( FT_Face face, + FT_EXPORT(FT_Error) + FT_OpenType_Validate(FT_Face face, FT_UInt validation_flags, FT_Bytes *BASE_table, FT_Bytes *GDEF_table, FT_Bytes *GPOS_table, FT_Bytes *GSUB_table, - FT_Bytes *JSTF_table ); + FT_Bytes *JSTF_table); /* */ @@ -187,9 +187,9 @@ FT_BEGIN_HEADER * This function must be used to free the buffer allocated by * @FT_OpenType_Validate only. */ - FT_EXPORT( void ) - FT_OpenType_Free( FT_Face face, - FT_Bytes table ); + FT_EXPORT(void) + FT_OpenType_Free(FT_Face face, + FT_Bytes table); /* */ diff --git a/include/freetype/ftoutln.h b/include/freetype/ftoutln.h index 8c7c57d..0fbfbc7 100644 --- a/include/freetype/ftoutln.h +++ b/include/freetype/ftoutln.h @@ -112,10 +112,10 @@ FT_BEGIN_HEADER /* outline for stroking purposes (otherwise it would result in a */ /* visible dot when round caps are used). */ /* */ - FT_EXPORT( FT_Error ) - FT_Outline_Decompose( FT_Outline* outline, + FT_EXPORT(FT_Error) + FT_Outline_Decompose(FT_Outline* outline, const FT_Outline_Funcs* func_interface, - void* user ); + void* user); /*************************************************************************/ @@ -148,18 +148,18 @@ FT_BEGIN_HEADER /* The reason why this function takes a `library' parameter is simply */ /* to use the library's memory allocator. */ /* */ - FT_EXPORT( FT_Error ) - FT_Outline_New( FT_Library library, + FT_EXPORT(FT_Error) + FT_Outline_New(FT_Library library, FT_UInt numPoints, FT_Int numContours, - FT_Outline *anoutline ); + FT_Outline *anoutline); - FT_EXPORT( FT_Error ) - FT_Outline_New_Internal( FT_Memory memory, + FT_EXPORT(FT_Error) + FT_Outline_New_Internal(FT_Memory memory, FT_UInt numPoints, FT_Int numContours, - FT_Outline *anoutline ); + FT_Outline *anoutline); /*************************************************************************/ @@ -186,14 +186,14 @@ FT_BEGIN_HEADER /* The reason why this function takes an `library' parameter is */ /* simply to use ft_mem_free(). */ /* */ - FT_EXPORT( FT_Error ) - FT_Outline_Done( FT_Library library, - FT_Outline* outline ); + FT_EXPORT(FT_Error) + FT_Outline_Done(FT_Library library, + FT_Outline* outline); - FT_EXPORT( FT_Error ) - FT_Outline_Done_Internal( FT_Memory memory, - FT_Outline* outline ); + FT_EXPORT(FT_Error) + FT_Outline_Done_Internal(FT_Memory memory, + FT_Outline* outline); /*************************************************************************/ @@ -210,8 +210,8 @@ FT_BEGIN_HEADER /* */ /* FreeType error code. 0~means success. */ /* */ - FT_EXPORT( FT_Error ) - FT_Outline_Check( FT_Outline* outline ); + FT_EXPORT(FT_Error) + FT_Outline_Check(FT_Outline* outline); /*************************************************************************/ @@ -240,9 +240,9 @@ FT_BEGIN_HEADER /* */ /* See @FT_Glyph_Get_CBox for a discussion of tricky fonts. */ /* */ - FT_EXPORT( void ) - FT_Outline_Get_CBox( const FT_Outline* outline, - FT_BBox *acbox ); + FT_EXPORT(void) + FT_Outline_Get_CBox(const FT_Outline* outline, + FT_BBox *acbox); /*************************************************************************/ @@ -261,10 +261,10 @@ FT_BEGIN_HEADER /* */ /* yOffset :: The vertical offset. */ /* */ - FT_EXPORT( void ) - FT_Outline_Translate( const FT_Outline* outline, + FT_EXPORT(void) + FT_Outline_Translate(const FT_Outline* outline, FT_Pos xOffset, - FT_Pos yOffset ); + FT_Pos yOffset); /*************************************************************************/ @@ -286,9 +286,9 @@ FT_BEGIN_HEADER /* */ /* FreeType error code. 0~means success. */ /* */ - FT_EXPORT( FT_Error ) - FT_Outline_Copy( const FT_Outline* source, - FT_Outline *target ); + FT_EXPORT(FT_Error) + FT_Outline_Copy(const FT_Outline* source, + FT_Outline *target); /*************************************************************************/ @@ -310,9 +310,9 @@ FT_BEGIN_HEADER /* You can use @FT_Outline_Translate if you need to translate the */ /* outline's points. */ /* */ - FT_EXPORT( void ) - FT_Outline_Transform( const FT_Outline* outline, - const FT_Matrix* matrix ); + FT_EXPORT(void) + FT_Outline_Transform(const FT_Outline* outline, + const FT_Matrix* matrix); /*************************************************************************/ @@ -350,14 +350,14 @@ FT_BEGIN_HEADER /* Example call: */ /* */ /* { */ - /* FT_Load_Glyph( face, index, FT_LOAD_DEFAULT ); */ - /* if ( face->slot->format == FT_GLYPH_FORMAT_OUTLINE ) */ - /* FT_Outline_Embolden( &face->slot->outline, strength ); */ + /* FT_Load_Glyph(face, index, FT_LOAD_DEFAULT); */ + /* if (face->slot->format == FT_GLYPH_FORMAT_OUTLINE) */ + /* FT_Outline_Embolden(&face->slot->outline, strength); */ /* } */ /* */ - FT_EXPORT( FT_Error ) - FT_Outline_Embolden( FT_Outline* outline, - FT_Pos strength ); + FT_EXPORT(FT_Error) + FT_Outline_Embolden(FT_Outline* outline, + FT_Pos strength); /*************************************************************************/ @@ -371,10 +371,10 @@ FT_BEGIN_HEADER /* @FT_Outline_Embolden, which uses the same strength in both */ /* directions. */ /* */ - FT_EXPORT( FT_Error ) - FT_Outline_EmboldenXY( FT_Outline* outline, + FT_EXPORT(FT_Error) + FT_Outline_EmboldenXY(FT_Outline* outline, FT_Pos xstrength, - FT_Pos ystrength ); + FT_Pos ystrength); /*************************************************************************/ @@ -396,8 +396,8 @@ FT_BEGIN_HEADER /* It shouldn't be used by a normal client application, unless it */ /* knows what it is doing. */ /* */ - FT_EXPORT( void ) - FT_Outline_Reverse( FT_Outline* outline ); + FT_EXPORT(void) + FT_Outline_Reverse(FT_Outline* outline); /*************************************************************************/ @@ -431,10 +431,10 @@ FT_BEGIN_HEADER /* you select the gray-level rasterizer, and you want less than 256 */ /* gray levels, you have to use @FT_Outline_Render directly. */ /* */ - FT_EXPORT( FT_Error ) - FT_Outline_Get_Bitmap( FT_Library library, + FT_EXPORT(FT_Error) + FT_Outline_Get_Bitmap(FT_Library library, FT_Outline* outline, - const FT_Bitmap *abitmap ); + const FT_Bitmap *abitmap); /*************************************************************************/ @@ -473,10 +473,10 @@ FT_BEGIN_HEADER /* See the @FT_RASTER_FLAG_DIRECT value of the `flags' field in the */ /* @FT_Raster_Params structure for more details. */ /* */ - FT_EXPORT( FT_Error ) - FT_Outline_Render( FT_Library library, + FT_EXPORT(FT_Error) + FT_Outline_Render(FT_Library library, FT_Outline* outline, - FT_Raster_Params* params ); + FT_Raster_Params* params); /************************************************************************** @@ -549,8 +549,8 @@ FT_BEGIN_HEADER * The orientation. * */ - FT_EXPORT( FT_Orientation ) - FT_Outline_Get_Orientation( FT_Outline* outline ); + FT_EXPORT(FT_Orientation) + FT_Outline_Get_Orientation(FT_Outline* outline); /* */ diff --git a/include/freetype/ftpfr.h b/include/freetype/ftpfr.h index 0b7b7d4..0b3e81d 100644 --- a/include/freetype/ftpfr.h +++ b/include/freetype/ftpfr.h @@ -86,12 +86,12 @@ FT_BEGIN_HEADER * If the input face is not a PFR, this function will return an error. * However, in all cases, it will return valid values. */ - FT_EXPORT( FT_Error ) - FT_Get_PFR_Metrics( FT_Face face, + FT_EXPORT(FT_Error) + FT_Get_PFR_Metrics(FT_Face face, FT_UInt *aoutline_resolution, FT_UInt *ametrics_resolution, FT_Fixed *ametrics_x_scale, - FT_Fixed *ametrics_y_scale ); + FT_Fixed *ametrics_y_scale); /********************************************************************** @@ -125,11 +125,11 @@ FT_BEGIN_HEADER * You can use the value of the `x_scale' and `y_scale' parameters * returned by @FT_Get_PFR_Metrics to scale these to device sub-pixels. */ - FT_EXPORT( FT_Error ) - FT_Get_PFR_Kerning( FT_Face face, + FT_EXPORT(FT_Error) + FT_Get_PFR_Kerning(FT_Face face, FT_UInt left, FT_UInt right, - FT_Vector *avector ); + FT_Vector *avector); /********************************************************************** @@ -156,10 +156,10 @@ FT_BEGIN_HEADER * You can use the `x_scale' or `y_scale' results of @FT_Get_PFR_Metrics * to convert the advance to device sub-pixels (i.e., 1/64th of pixels). */ - FT_EXPORT( FT_Error ) - FT_Get_PFR_Advance( FT_Face face, + FT_EXPORT(FT_Error) + FT_Get_PFR_Advance(FT_Face face, FT_UInt gindex, - FT_Pos *aadvance ); + FT_Pos *aadvance); /* */ diff --git a/include/freetype/ftrender.h b/include/freetype/ftrender.h index dd0229b..3569c63 100644 --- a/include/freetype/ftrender.h +++ b/include/freetype/ftrender.h @@ -38,29 +38,29 @@ FT_BEGIN_HEADER /* create a new glyph object */ typedef FT_Error - (*FT_Glyph_InitFunc)( FT_Glyph glyph, - FT_GlyphSlot slot ); + (*FT_Glyph_InitFunc)(FT_Glyph glyph, + FT_GlyphSlot slot); /* destroys a given glyph object */ typedef void - (*FT_Glyph_DoneFunc)( FT_Glyph glyph ); + (*FT_Glyph_DoneFunc)(FT_Glyph glyph); typedef void - (*FT_Glyph_TransformFunc)( FT_Glyph glyph, + (*FT_Glyph_TransformFunc)(FT_Glyph glyph, const FT_Matrix* matrix, - const FT_Vector* delta ); + const FT_Vector* delta); typedef void - (*FT_Glyph_GetBBoxFunc)( FT_Glyph glyph, - FT_BBox* abbox ); + (*FT_Glyph_GetBBoxFunc)(FT_Glyph glyph, + FT_BBox* abbox); typedef FT_Error - (*FT_Glyph_CopyFunc)( FT_Glyph source, - FT_Glyph target ); + (*FT_Glyph_CopyFunc)(FT_Glyph source, + FT_Glyph target); typedef FT_Error - (*FT_Glyph_PrepareFunc)( FT_Glyph glyph, - FT_GlyphSlot slot ); + (*FT_Glyph_PrepareFunc)(FT_Glyph glyph, + FT_GlyphSlot slot); /* deprecated */ #define FT_Glyph_Init_Func FT_Glyph_InitFunc @@ -85,28 +85,28 @@ FT_BEGIN_HEADER typedef FT_Error - (*FT_Renderer_RenderFunc)( FT_Renderer renderer, + (*FT_Renderer_RenderFunc)(FT_Renderer renderer, FT_GlyphSlot slot, FT_UInt mode, - const FT_Vector* origin ); + const FT_Vector* origin); typedef FT_Error - (*FT_Renderer_TransformFunc)( FT_Renderer renderer, + (*FT_Renderer_TransformFunc)(FT_Renderer renderer, FT_GlyphSlot slot, const FT_Matrix* matrix, - const FT_Vector* delta ); + const FT_Vector* delta); typedef void - (*FT_Renderer_GetCBoxFunc)( FT_Renderer renderer, + (*FT_Renderer_GetCBoxFunc)(FT_Renderer renderer, FT_GlyphSlot slot, - FT_BBox* cbox ); + FT_BBox* cbox); typedef FT_Error - (*FT_Renderer_SetModeFunc)( FT_Renderer renderer, + (*FT_Renderer_SetModeFunc)(FT_Renderer renderer, FT_ULong mode_tag, - FT_Pointer mode_ptr ); + FT_Pointer mode_ptr); /* deprecated identifiers */ #define FTRenderer_render FT_Renderer_RenderFunc @@ -180,9 +180,9 @@ FT_BEGIN_HEADER /* To add a new renderer, simply use @FT_Add_Module. To retrieve a */ /* renderer by its name, use @FT_Get_Module. */ /* */ - FT_EXPORT( FT_Renderer ) - FT_Get_Renderer( FT_Library library, - FT_Glyph_Format format ); + FT_EXPORT(FT_Renderer) + FT_Get_Renderer(FT_Library library, + FT_Glyph_Format format); /*************************************************************************/ @@ -220,11 +220,11 @@ FT_BEGIN_HEADER /* 5~elements. Consequently, the third and fourth argument are zero */ /* normally. */ /* */ - FT_EXPORT( FT_Error ) - FT_Set_Renderer( FT_Library library, + FT_EXPORT(FT_Error) + FT_Set_Renderer(FT_Library library, FT_Renderer renderer, FT_UInt num_params, - FT_Parameter* parameters ); + FT_Parameter* parameters); /* */ diff --git a/include/freetype/ftsizes.h b/include/freetype/ftsizes.h index 4167045..d7f879c 100644 --- a/include/freetype/ftsizes.h +++ b/include/freetype/ftsizes.h @@ -96,9 +96,9 @@ FT_BEGIN_HEADER /* for upcoming calls to @FT_Set_Pixel_Sizes, @FT_Set_Char_Size, */ /* @FT_Load_Glyph, @FT_Load_Char, etc. */ /* */ - FT_EXPORT( FT_Error ) - FT_New_Size( FT_Face face, - FT_Size* size ); + FT_EXPORT(FT_Error) + FT_New_Size(FT_Face face, + FT_Size* size); /*************************************************************************/ @@ -117,8 +117,8 @@ FT_BEGIN_HEADER /* */ /* FreeType error code. 0~means success. */ /* */ - FT_EXPORT( FT_Error ) - FT_Done_Size( FT_Size size ); + FT_EXPORT(FT_Error) + FT_Done_Size(FT_Size size); /*************************************************************************/ @@ -145,8 +145,8 @@ FT_BEGIN_HEADER /* If `face' is the size's parent face object, this function changes */ /* the value of `face->size' to the input size handle. */ /* */ - FT_EXPORT( FT_Error ) - FT_Activate_Size( FT_Size size ); + FT_EXPORT(FT_Error) + FT_Activate_Size(FT_Size size); /* */ diff --git a/include/freetype/ftsnames.h b/include/freetype/ftsnames.h index 88af440..d0fb76e 100644 --- a/include/freetype/ftsnames.h +++ b/include/freetype/ftsnames.h @@ -122,8 +122,8 @@ FT_BEGIN_HEADER /* */ /* The number of strings in the `name' table. */ /* */ - FT_EXPORT( FT_UInt ) - FT_Get_Sfnt_Name_Count( FT_Face face ); + FT_EXPORT(FT_UInt) + FT_Get_Sfnt_Name_Count(FT_Face face); /*************************************************************************/ @@ -154,10 +154,10 @@ FT_BEGIN_HEADER /* `name' table entries, then do a loop until you get the right */ /* platform, encoding, and name ID. */ /* */ - FT_EXPORT( FT_Error ) - FT_Get_Sfnt_Name( FT_Face face, + FT_EXPORT(FT_Error) + FT_Get_Sfnt_Name(FT_Face face, FT_UInt idx, - FT_SfntName *aname ); + FT_SfntName *aname); /*************************************************************************** @@ -172,7 +172,7 @@ FT_BEGIN_HEADER * legacy systems that have a 4-face-per-family restriction. * */ -#define FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY FT_MAKE_TAG( 'i', 'g', 'p', 'f' ) +#define FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY FT_MAKE_TAG('i', 'g', 'p', 'f') /*************************************************************************** @@ -187,7 +187,7 @@ FT_BEGIN_HEADER * systems that have a 4-face-per-family restriction. * */ -#define FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY FT_MAKE_TAG( 'i', 'g', 'p', 's' ) +#define FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY FT_MAKE_TAG('i', 'g', 'p', 's') /* */ diff --git a/include/freetype/ftstroke.h b/include/freetype/ftstroke.h index a498e4a..f0de716 100644 --- a/include/freetype/ftstroke.h +++ b/include/freetype/ftstroke.h @@ -198,8 +198,8 @@ FT_BEGIN_HEADER * The border index. @FT_STROKER_BORDER_RIGHT for empty or invalid * outlines. */ - FT_EXPORT( FT_StrokerBorder ) - FT_Outline_GetInsideBorder( FT_Outline* outline ); + FT_EXPORT(FT_StrokerBorder) + FT_Outline_GetInsideBorder(FT_Outline* outline); /************************************************************** @@ -219,8 +219,8 @@ FT_BEGIN_HEADER * The border index. @FT_STROKER_BORDER_LEFT for empty or invalid * outlines. */ - FT_EXPORT( FT_StrokerBorder ) - FT_Outline_GetOutsideBorder( FT_Outline* outline ); + FT_EXPORT(FT_StrokerBorder) + FT_Outline_GetOutsideBorder(FT_Outline* outline); /************************************************************** @@ -242,9 +242,9 @@ FT_BEGIN_HEADER * @return: * FreeType error code. 0~means success. */ - FT_EXPORT( FT_Error ) - FT_Stroker_New( FT_Library library, - FT_Stroker *astroker ); + FT_EXPORT(FT_Error) + FT_Stroker_New(FT_Library library, + FT_Stroker *astroker); /************************************************************** @@ -277,12 +277,12 @@ FT_BEGIN_HEADER * The radius is expressed in the same units as the outline * coordinates. */ - FT_EXPORT( void ) - FT_Stroker_Set( FT_Stroker stroker, + FT_EXPORT(void) + FT_Stroker_Set(FT_Stroker stroker, FT_Fixed radius, FT_Stroker_LineCap line_cap, FT_Stroker_LineJoin line_join, - FT_Fixed miter_limit ); + FT_Fixed miter_limit); /************************************************************** @@ -300,8 +300,8 @@ FT_BEGIN_HEADER * stroker :: * The target stroker handle. */ - FT_EXPORT( void ) - FT_Stroker_Rewind( FT_Stroker stroker ); + FT_EXPORT(void) + FT_Stroker_Rewind(FT_Stroker stroker); /************************************************************** @@ -337,10 +337,10 @@ FT_BEGIN_HEADER * * This function calls @FT_Stroker_Rewind automatically. */ - FT_EXPORT( FT_Error ) - FT_Stroker_ParseOutline( FT_Stroker stroker, + FT_EXPORT(FT_Error) + FT_Stroker_ParseOutline(FT_Stroker stroker, FT_Outline* outline, - FT_Bool opened ); + FT_Bool opened); /************************************************************** @@ -368,10 +368,10 @@ FT_BEGIN_HEADER * This function is useful when you need to stroke a path that is * not stored as an @FT_Outline object. */ - FT_EXPORT( FT_Error ) - FT_Stroker_BeginSubPath( FT_Stroker stroker, + FT_EXPORT(FT_Error) + FT_Stroker_BeginSubPath(FT_Stroker stroker, FT_Vector* to, - FT_Bool open ); + FT_Bool open); /************************************************************** @@ -394,8 +394,8 @@ FT_BEGIN_HEADER * If the subpath was not `opened', this function `draws' a * single line segment to the start position when needed. */ - FT_EXPORT( FT_Error ) - FT_Stroker_EndSubPath( FT_Stroker stroker ); + FT_EXPORT(FT_Error) + FT_Stroker_EndSubPath(FT_Stroker stroker); /************************************************************** @@ -421,9 +421,9 @@ FT_BEGIN_HEADER * You should call this function between @FT_Stroker_BeginSubPath and * @FT_Stroker_EndSubPath. */ - FT_EXPORT( FT_Error ) - FT_Stroker_LineTo( FT_Stroker stroker, - FT_Vector* to ); + FT_EXPORT(FT_Error) + FT_Stroker_LineTo(FT_Stroker stroker, + FT_Vector* to); /************************************************************** @@ -452,10 +452,10 @@ FT_BEGIN_HEADER * You should call this function between @FT_Stroker_BeginSubPath and * @FT_Stroker_EndSubPath. */ - FT_EXPORT( FT_Error ) - FT_Stroker_ConicTo( FT_Stroker stroker, + FT_EXPORT(FT_Error) + FT_Stroker_ConicTo(FT_Stroker stroker, FT_Vector* control, - FT_Vector* to ); + FT_Vector* to); /************************************************************** @@ -487,11 +487,11 @@ FT_BEGIN_HEADER * You should call this function between @FT_Stroker_BeginSubPath and * @FT_Stroker_EndSubPath. */ - FT_EXPORT( FT_Error ) - FT_Stroker_CubicTo( FT_Stroker stroker, + FT_EXPORT(FT_Error) + FT_Stroker_CubicTo(FT_Stroker stroker, FT_Vector* control1, FT_Vector* control2, - FT_Vector* to ); + FT_Vector* to); /************************************************************** @@ -533,11 +533,11 @@ FT_BEGIN_HEADER * Use the function @FT_Stroker_GetCounts instead if you want to * retrieve the counts associated to both borders. */ - FT_EXPORT( FT_Error ) - FT_Stroker_GetBorderCounts( FT_Stroker stroker, + FT_EXPORT(FT_Error) + FT_Stroker_GetBorderCounts(FT_Stroker stroker, FT_StrokerBorder border, FT_UInt *anum_points, - FT_UInt *anum_contours ); + FT_UInt *anum_contours); /************************************************************** @@ -579,10 +579,10 @@ FT_BEGIN_HEADER * Use the function @FT_Stroker_Export instead if you want to * retrieve all borders at once. */ - FT_EXPORT( void ) - FT_Stroker_ExportBorder( FT_Stroker stroker, + FT_EXPORT(void) + FT_Stroker_ExportBorder(FT_Stroker stroker, FT_StrokerBorder border, - FT_Outline* outline ); + FT_Outline* outline); /************************************************************** @@ -610,10 +610,10 @@ FT_BEGIN_HEADER * @return: * FreeType error code. 0~means success. */ - FT_EXPORT( FT_Error ) - FT_Stroker_GetCounts( FT_Stroker stroker, + FT_EXPORT(FT_Error) + FT_Stroker_GetCounts(FT_Stroker stroker, FT_UInt *anum_points, - FT_UInt *anum_contours ); + FT_UInt *anum_contours); /************************************************************** @@ -636,9 +636,9 @@ FT_BEGIN_HEADER * outline :: * The target outline handle. */ - FT_EXPORT( void ) - FT_Stroker_Export( FT_Stroker stroker, - FT_Outline* outline ); + FT_EXPORT(void) + FT_Stroker_Export(FT_Stroker stroker, + FT_Outline* outline); /************************************************************** @@ -653,8 +653,8 @@ FT_BEGIN_HEADER * stroker :: * A stroker handle. Can be NULL. */ - FT_EXPORT( void ) - FT_Stroker_Done( FT_Stroker stroker ); + FT_EXPORT(void) + FT_Stroker_Done(FT_Stroker stroker); /************************************************************** @@ -688,10 +688,10 @@ FT_BEGIN_HEADER * may need to manually adjust horizontal and vertical advance amounts * to account for this added size. */ - FT_EXPORT( FT_Error ) - FT_Glyph_Stroke( FT_Glyph *pglyph, + FT_EXPORT(FT_Error) + FT_Glyph_Stroke(FT_Glyph *pglyph, FT_Stroker stroker, - FT_Bool destroy ); + FT_Bool destroy); /************************************************************** @@ -730,11 +730,11 @@ FT_BEGIN_HEADER * may need to manually adjust horizontal and vertical advance amounts * to account for this added size. */ - FT_EXPORT( FT_Error ) - FT_Glyph_StrokeBorder( FT_Glyph *pglyph, + FT_EXPORT(FT_Error) + FT_Glyph_StrokeBorder(FT_Glyph *pglyph, FT_Stroker stroker, FT_Bool inside, - FT_Bool destroy ); + FT_Bool destroy); /* */ diff --git a/include/freetype/ftsynth.h b/include/freetype/ftsynth.h index 839ab5e..03c82ba 100644 --- a/include/freetype/ftsynth.h +++ b/include/freetype/ftsynth.h @@ -64,12 +64,12 @@ FT_BEGIN_HEADER /* For emboldened outlines the height, width, and advance metrics are */ /* increased by the strength of the emboldening. You can also call */ /* @FT_Outline_Get_CBox to get precise values. */ - FT_EXPORT( void ) - FT_GlyphSlot_Embolden( FT_GlyphSlot slot ); + FT_EXPORT(void) + FT_GlyphSlot_Embolden(FT_GlyphSlot slot); /* Slant an outline glyph to the right by about 12 degrees. */ - FT_EXPORT( void ) - FT_GlyphSlot_Oblique( FT_GlyphSlot slot ); + FT_EXPORT(void) + FT_GlyphSlot_Oblique(FT_GlyphSlot slot); /* */ diff --git a/include/freetype/ftsystem.h b/include/freetype/ftsystem.h index e07460c..da6a3b3 100644 --- a/include/freetype/ftsystem.h +++ b/include/freetype/ftsystem.h @@ -86,8 +86,8 @@ FT_BEGIN_HEADER * */ typedef void* - (*FT_Alloc_Func)( FT_Memory memory, - long size ); + (*FT_Alloc_Func)(FT_Memory memory, + long size); /************************************************************************* @@ -107,8 +107,8 @@ FT_BEGIN_HEADER * */ typedef void - (*FT_Free_Func)( FT_Memory memory, - void* block ); + (*FT_Free_Func)(FT_Memory memory, + void* block); /************************************************************************* @@ -140,10 +140,10 @@ FT_BEGIN_HEADER * */ typedef void* - (*FT_Realloc_Func)( FT_Memory memory, + (*FT_Realloc_Func)(FT_Memory memory, long cur_size, long new_size, - void* block ); + void* block); /************************************************************************* @@ -245,10 +245,10 @@ FT_BEGIN_HEADER * */ typedef unsigned long - (*FT_Stream_IoFunc)( FT_Stream stream, + (*FT_Stream_IoFunc)(FT_Stream stream, unsigned long offset, unsigned char* buffer, - unsigned long count ); + unsigned long count); /************************************************************************* @@ -265,7 +265,7 @@ FT_BEGIN_HEADER * */ typedef void - (*FT_Stream_CloseFunc)( FT_Stream stream ); + (*FT_Stream_CloseFunc)(FT_Stream stream); /************************************************************************* diff --git a/include/freetype/fttrigon.h b/include/freetype/fttrigon.h index 65143cb..33cfd3b 100644 --- a/include/freetype/fttrigon.h +++ b/include/freetype/fttrigon.h @@ -61,7 +61,7 @@ FT_BEGIN_HEADER * The angle pi expressed in @FT_Angle units. * */ -#define FT_ANGLE_PI ( 180L << 16 ) +#define FT_ANGLE_PI (180L << 16) /************************************************************************* @@ -73,7 +73,7 @@ FT_BEGIN_HEADER * The angle 2*pi expressed in @FT_Angle units. * */ -#define FT_ANGLE_2PI ( FT_ANGLE_PI * 2 ) +#define FT_ANGLE_2PI (FT_ANGLE_PI * 2) /************************************************************************* @@ -85,7 +85,7 @@ FT_BEGIN_HEADER * The angle pi/2 expressed in @FT_Angle units. * */ -#define FT_ANGLE_PI2 ( FT_ANGLE_PI / 2 ) +#define FT_ANGLE_PI2 (FT_ANGLE_PI / 2) /************************************************************************* @@ -97,7 +97,7 @@ FT_BEGIN_HEADER * The angle pi/4 expressed in @FT_Angle units. * */ -#define FT_ANGLE_PI4 ( FT_ANGLE_PI / 4 ) +#define FT_ANGLE_PI4 (FT_ANGLE_PI / 4) /************************************************************************* @@ -120,8 +120,8 @@ FT_BEGIN_HEADER * function @FT_Vector_Unit. * */ - FT_EXPORT( FT_Fixed ) - FT_Sin( FT_Angle angle ); + FT_EXPORT(FT_Fixed) + FT_Sin(FT_Angle angle); /************************************************************************* @@ -144,8 +144,8 @@ FT_BEGIN_HEADER * function @FT_Vector_Unit. * */ - FT_EXPORT( FT_Fixed ) - FT_Cos( FT_Angle angle ); + FT_EXPORT(FT_Fixed) + FT_Cos(FT_Angle angle); /************************************************************************* @@ -164,8 +164,8 @@ FT_BEGIN_HEADER * The tangent value. * */ - FT_EXPORT( FT_Fixed ) - FT_Tan( FT_Angle angle ); + FT_EXPORT(FT_Fixed) + FT_Tan(FT_Angle angle); /************************************************************************* @@ -188,9 +188,9 @@ FT_BEGIN_HEADER * The arc-tangent value (i.e. angle). * */ - FT_EXPORT( FT_Angle ) - FT_Atan2( FT_Fixed x, - FT_Fixed y ); + FT_EXPORT(FT_Angle) + FT_Atan2(FT_Fixed x, + FT_Fixed y); /************************************************************************* @@ -213,9 +213,9 @@ FT_BEGIN_HEADER * Constrained value of `value2-value1'. * */ - FT_EXPORT( FT_Angle ) - FT_Angle_Diff( FT_Angle angle1, - FT_Angle angle2 ); + FT_EXPORT(FT_Angle) + FT_Angle_Diff(FT_Angle angle1, + FT_Angle angle2); /************************************************************************* @@ -240,9 +240,9 @@ FT_BEGIN_HEADER * The address of angle. * */ - FT_EXPORT( void ) - FT_Vector_Unit( FT_Vector* vec, - FT_Angle angle ); + FT_EXPORT(void) + FT_Vector_Unit(FT_Vector* vec, + FT_Angle angle); /************************************************************************* @@ -262,9 +262,9 @@ FT_BEGIN_HEADER * The address of angle. * */ - FT_EXPORT( void ) - FT_Vector_Rotate( FT_Vector* vec, - FT_Angle angle ); + FT_EXPORT(void) + FT_Vector_Rotate(FT_Vector* vec, + FT_Angle angle); /************************************************************************* @@ -284,8 +284,8 @@ FT_BEGIN_HEADER * vector coordinates. * */ - FT_EXPORT( FT_Fixed ) - FT_Vector_Length( FT_Vector* vec ); + FT_EXPORT(FT_Fixed) + FT_Vector_Length(FT_Vector* vec); /************************************************************************* @@ -308,10 +308,10 @@ FT_BEGIN_HEADER * The vector angle. * */ - FT_EXPORT( void ) - FT_Vector_Polarize( FT_Vector* vec, + FT_EXPORT(void) + FT_Vector_Polarize(FT_Vector* vec, FT_Fixed *length, - FT_Angle *angle ); + FT_Angle *angle); /************************************************************************* @@ -334,10 +334,10 @@ FT_BEGIN_HEADER * The vector angle. * */ - FT_EXPORT( void ) - FT_Vector_From_Polar( FT_Vector* vec, + FT_EXPORT(void) + FT_Vector_From_Polar(FT_Vector* vec, FT_Fixed length, - FT_Angle angle ); + FT_Angle angle); /* */ diff --git a/include/freetype/ftttdrv.h b/include/freetype/ftttdrv.h index 70ad3d5..13f0480 100644 --- a/include/freetype/ftttdrv.h +++ b/include/freetype/ftttdrv.h @@ -88,11 +88,11 @@ FT_BEGIN_HEADER * FT_UInt interpreter_version = TT_INTERPRETER_VERSION_38; * * - * FT_Init_FreeType( &library ); + * FT_Init_FreeType(&library); * - * FT_Property_Set( library, "truetype", + * FT_Property_Set(library, "truetype", * "interpreter-version", - * &interpreter_version ); + * &interpreter_version); * } * * @note: diff --git a/include/freetype/fttypes.h b/include/freetype/fttypes.h index bd944a4..9f10b27 100644 --- a/include/freetype/fttypes.h +++ b/include/freetype/fttypes.h @@ -473,12 +473,12 @@ FT_BEGIN_HEADER /* The produced values *must* be 32-bit integers. Don't redefine */ /* this macro. */ /* */ -#define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \ +#define FT_MAKE_TAG(_x1, _x2, _x3, _x4) \ (FT_Tag) \ - ( ( (FT_ULong)_x1 << 24 ) | \ - ( (FT_ULong)_x2 << 16 ) | \ - ( (FT_ULong)_x3 << 8 ) | \ - (FT_ULong)_x4 ) + (((FT_ULong)_x1 << 24) | \ + ((FT_ULong)_x2 << 16) | \ + ((FT_ULong)_x3 << 8) | \ + (FT_ULong)_x4 ) /*************************************************************************/ @@ -570,24 +570,24 @@ FT_BEGIN_HEADER /* */ -#define FT_IS_EMPTY( list ) ( (list).head == 0 ) -#define FT_BOOL( x ) ( (FT_Bool)( x ) ) +#define FT_IS_EMPTY(list) ((list).head == 0) +#define FT_BOOL(x) ((FT_Bool)(x)) /* concatenate C tokens */ -#define FT_ERR_XCAT( x, y ) x ## y -#define FT_ERR_CAT( x, y ) FT_ERR_XCAT( x, y ) +#define FT_ERR_XCAT(x, y) x ## y +#define FT_ERR_CAT(x, y) FT_ERR_XCAT(x, y) /* see `ftmoderr.h' for descriptions of the following macros */ -#define FT_ERR( e ) FT_ERR_CAT( FT_ERR_PREFIX, e ) +#define FT_ERR(e) FT_ERR_CAT(FT_ERR_PREFIX, e) -#define FT_ERROR_BASE( x ) ( (x) & 0xFF ) -#define FT_ERROR_MODULE( x ) ( (x) & 0xFF00U ) +#define FT_ERROR_BASE(x) ((x) & 0xFF) +#define FT_ERROR_MODULE(x) ((x) & 0xFF00U) -#define FT_ERR_EQ( x, e ) \ - ( FT_ERROR_BASE( x ) == FT_ERROR_BASE( FT_ERR( e ) ) ) -#define FT_ERR_NEQ( x, e ) \ - ( FT_ERROR_BASE( x ) != FT_ERROR_BASE( FT_ERR( e ) ) ) +#define FT_ERR_EQ(x, e) \ + (FT_ERROR_BASE(x) == FT_ERROR_BASE(FT_ERR(e))) +#define FT_ERR_NEQ(x, e) \ + (FT_ERROR_BASE(x) != FT_ERROR_BASE(FT_ERR(e))) FT_END_HEADER diff --git a/include/freetype/ftwinfnt.h b/include/freetype/ftwinfnt.h index 0b67351..cc5f7db 100644 --- a/include/freetype/ftwinfnt.h +++ b/include/freetype/ftwinfnt.h @@ -255,9 +255,9 @@ FT_BEGIN_HEADER * This function only works with Windows FNT faces, returning an error * otherwise. */ - FT_EXPORT( FT_Error ) - FT_Get_WinFNT_Header( FT_Face face, - FT_WinFNT_HeaderRec *aheader ); + FT_EXPORT(FT_Error) + FT_Get_WinFNT_Header(FT_Face face, + FT_WinFNT_HeaderRec *aheader); /* */ diff --git a/include/freetype/ftxf86.h b/include/freetype/ftxf86.h index 493cccd..0ede2da 100644 --- a/include/freetype/ftxf86.h +++ b/include/freetype/ftxf86.h @@ -73,8 +73,8 @@ FT_BEGIN_HEADER /* */ /* Font format string. NULL in case of error. */ /* */ - FT_EXPORT( const char* ) - FT_Get_X11_Font_Format( FT_Face face ); + FT_EXPORT(const char*) + FT_Get_X11_Font_Format(FT_Face face); /* */ diff --git a/include/freetype/t1tables.h b/include/freetype/t1tables.h index a14255e..ed4235c 100644 --- a/include/freetype/t1tables.h +++ b/include/freetype/t1tables.h @@ -424,8 +424,8 @@ FT_BEGIN_HEADER * Boolean. True if glyph names are reliable. * */ - FT_EXPORT( FT_Int ) - FT_Has_PS_Glyph_Names( FT_Face face ); + FT_EXPORT(FT_Int) + FT_Has_PS_Glyph_Names(FT_Face face); /************************************************************************ @@ -456,9 +456,9 @@ FT_BEGIN_HEADER * return the `FT_Err_Invalid_Argument' error code. * */ - FT_EXPORT( FT_Error ) - FT_Get_PS_Font_Info( FT_Face face, - PS_FontInfo afont_info ); + FT_EXPORT(FT_Error) + FT_Get_PS_Font_Info(FT_Face face, + PS_FontInfo afont_info); /************************************************************************ @@ -489,9 +489,9 @@ FT_BEGIN_HEADER * the `FT_Err_Invalid_Argument' error code. * */ - FT_EXPORT( FT_Error ) - FT_Get_PS_Font_Private( FT_Face face, - PS_Private afont_private ); + FT_EXPORT(FT_Error) + FT_Get_PS_Font_Private(FT_Face face, + PS_Private afont_private); /*************************************************************************/ @@ -645,12 +645,12 @@ FT_BEGIN_HEADER * the `FT_Err_Invalid_Argument' error code. * */ - FT_EXPORT( FT_Long ) - FT_Get_PS_Font_Value( FT_Face face, + FT_EXPORT(FT_Long) + FT_Get_PS_Font_Value(FT_Face face, PS_Dict_Keys key, FT_UInt idx, void *value, - FT_Long value_len ); + FT_Long value_len); /* */ diff --git a/include/freetype/ttnameid.h b/include/freetype/ttnameid.h index 9711d1d..ee890e7 100644 --- a/include/freetype/ttnameid.h +++ b/include/freetype/ttnameid.h @@ -1196,7 +1196,7 @@ FT_BEGIN_HEADER /* */ /* Some compilers have a very limited length of identifiers. */ /* */ -#if defined( __TURBOC__ ) && __TURBOC__ < 0x0410 || defined( __PACIFIC__ ) +#if defined(__TURBOC__) && __TURBOC__ < 0x0410 || defined(__PACIFIC__) #define HAVE_LIMIT_ON_IDENTS #endif diff --git a/include/freetype/tttables.h b/include/freetype/tttables.h index bb49dc0..babe228 100644 --- a/include/freetype/tttables.h +++ b/include/freetype/tttables.h @@ -611,12 +611,12 @@ FT_BEGIN_HEADER /* */ /* */ /* vert_header = */ - /* (TT_VertHeader*)FT_Get_Sfnt_Table( face, ft_sfnt_vhea ); */ + /* (TT_VertHeader*)FT_Get_Sfnt_Table(face, ft_sfnt_vhea); */ /* } */ /* */ - FT_EXPORT( void* ) - FT_Get_Sfnt_Table( FT_Face face, - FT_Sfnt_Tag tag ); + FT_EXPORT(void*) + FT_Get_Sfnt_Table(FT_Face face, + FT_Sfnt_Tag tag); /************************************************************************** @@ -667,14 +667,14 @@ FT_BEGIN_HEADER * FT_ULong length = 0; * * - * error = FT_Load_Sfnt_Table( face, tag, 0, NULL, &length ); - * if ( error ) { ... table does not exist ... } + * error = FT_Load_Sfnt_Table(face, tag, 0, NULL, &length); + * if (error) { ... table does not exist ... } * - * buffer = malloc( length ); - * if ( buffer == NULL ) { ... not enough memory ... } + * buffer = malloc(length); + * if (buffer == NULL) { ... not enough memory ... } * - * error = FT_Load_Sfnt_Table( face, tag, 0, buffer, &length ); - * if ( error ) { ... could not load table ... } + * error = FT_Load_Sfnt_Table(face, tag, 0, buffer, &length); + * if (error) { ... could not load table ... } * } * * Note that structures like @TT_Header or @TT_OS2 can't be used with @@ -683,12 +683,12 @@ FT_BEGIN_HEADER * size (e.g. 32bit vs. 64bit) or order (big endian vs. little endian). * */ - FT_EXPORT( FT_Error ) - FT_Load_Sfnt_Table( FT_Face face, + FT_EXPORT(FT_Error) + FT_Load_Sfnt_Table(FT_Face face, FT_ULong tag, FT_Long offset, FT_Byte* buffer, - FT_ULong* length ); + FT_ULong* length); /************************************************************************** @@ -726,11 +726,11 @@ FT_BEGIN_HEADER * missing. * */ - FT_EXPORT( FT_Error ) - FT_Sfnt_Table_Info( FT_Face face, + FT_EXPORT(FT_Error) + FT_Sfnt_Table_Info(FT_Face face, FT_UInt table_index, FT_ULong *tag, - FT_ULong *length ); + FT_ULong *length); /*************************************************************************/ @@ -753,8 +753,8 @@ FT_BEGIN_HEADER /* For a format~14 cmap (to access Unicode IVS), the return value is */ /* 0xFFFFFFFF. */ /* */ - FT_EXPORT( FT_ULong ) - FT_Get_CMap_Language_ID( FT_CharMap charmap ); + FT_EXPORT(FT_ULong) + FT_Get_CMap_Language_ID(FT_CharMap charmap); /*************************************************************************/ @@ -773,8 +773,8 @@ FT_BEGIN_HEADER /* The format of `charmap'. If `charmap' doesn't belong to a */ /* TrueType/sfnt face, return -1. */ /* */ - FT_EXPORT( FT_Long ) - FT_Get_CMap_Format( FT_CharMap charmap ); + FT_EXPORT(FT_Long) + FT_Get_CMap_Format(FT_CharMap charmap); /* */ diff --git a/include/freetype/tttags.h b/include/freetype/tttags.h index d59aa19..b7a81b5 100644 --- a/include/freetype/tttags.h +++ b/include/freetype/tttags.h @@ -33,74 +33,74 @@ FT_BEGIN_HEADER -#define TTAG_avar FT_MAKE_TAG( 'a', 'v', 'a', 'r' ) -#define TTAG_BASE FT_MAKE_TAG( 'B', 'A', 'S', 'E' ) -#define TTAG_bdat FT_MAKE_TAG( 'b', 'd', 'a', 't' ) -#define TTAG_BDF FT_MAKE_TAG( 'B', 'D', 'F', ' ' ) -#define TTAG_bhed FT_MAKE_TAG( 'b', 'h', 'e', 'd' ) -#define TTAG_bloc FT_MAKE_TAG( 'b', 'l', 'o', 'c' ) -#define TTAG_bsln FT_MAKE_TAG( 'b', 's', 'l', 'n' ) -#define TTAG_CBDT FT_MAKE_TAG( 'C', 'B', 'D', 'T' ) -#define TTAG_CBLC FT_MAKE_TAG( 'C', 'B', 'L', 'C' ) -#define TTAG_CFF FT_MAKE_TAG( 'C', 'F', 'F', ' ' ) -#define TTAG_CID FT_MAKE_TAG( 'C', 'I', 'D', ' ' ) -#define TTAG_cmap FT_MAKE_TAG( 'c', 'm', 'a', 'p' ) -#define TTAG_cvar FT_MAKE_TAG( 'c', 'v', 'a', 'r' ) -#define TTAG_cvt FT_MAKE_TAG( 'c', 'v', 't', ' ' ) -#define TTAG_DSIG FT_MAKE_TAG( 'D', 'S', 'I', 'G' ) -#define TTAG_EBDT FT_MAKE_TAG( 'E', 'B', 'D', 'T' ) -#define TTAG_EBLC FT_MAKE_TAG( 'E', 'B', 'L', 'C' ) -#define TTAG_EBSC FT_MAKE_TAG( 'E', 'B', 'S', 'C' ) -#define TTAG_feat FT_MAKE_TAG( 'f', 'e', 'a', 't' ) -#define TTAG_FOND FT_MAKE_TAG( 'F', 'O', 'N', 'D' ) -#define TTAG_fpgm FT_MAKE_TAG( 'f', 'p', 'g', 'm' ) -#define TTAG_fvar FT_MAKE_TAG( 'f', 'v', 'a', 'r' ) -#define TTAG_gasp FT_MAKE_TAG( 'g', 'a', 's', 'p' ) -#define TTAG_GDEF FT_MAKE_TAG( 'G', 'D', 'E', 'F' ) -#define TTAG_glyf FT_MAKE_TAG( 'g', 'l', 'y', 'f' ) -#define TTAG_GPOS FT_MAKE_TAG( 'G', 'P', 'O', 'S' ) -#define TTAG_GSUB FT_MAKE_TAG( 'G', 'S', 'U', 'B' ) -#define TTAG_gvar FT_MAKE_TAG( 'g', 'v', 'a', 'r' ) -#define TTAG_hdmx FT_MAKE_TAG( 'h', 'd', 'm', 'x' ) -#define TTAG_head FT_MAKE_TAG( 'h', 'e', 'a', 'd' ) -#define TTAG_hhea FT_MAKE_TAG( 'h', 'h', 'e', 'a' ) -#define TTAG_hmtx FT_MAKE_TAG( 'h', 'm', 't', 'x' ) -#define TTAG_JSTF FT_MAKE_TAG( 'J', 'S', 'T', 'F' ) -#define TTAG_just FT_MAKE_TAG( 'j', 'u', 's', 't' ) -#define TTAG_kern FT_MAKE_TAG( 'k', 'e', 'r', 'n' ) -#define TTAG_lcar FT_MAKE_TAG( 'l', 'c', 'a', 'r' ) -#define TTAG_loca FT_MAKE_TAG( 'l', 'o', 'c', 'a' ) -#define TTAG_LTSH FT_MAKE_TAG( 'L', 'T', 'S', 'H' ) -#define TTAG_LWFN FT_MAKE_TAG( 'L', 'W', 'F', 'N' ) -#define TTAG_MATH FT_MAKE_TAG( 'M', 'A', 'T', 'H' ) -#define TTAG_maxp FT_MAKE_TAG( 'm', 'a', 'x', 'p' ) -#define TTAG_META FT_MAKE_TAG( 'M', 'E', 'T', 'A' ) -#define TTAG_MMFX FT_MAKE_TAG( 'M', 'M', 'F', 'X' ) -#define TTAG_MMSD FT_MAKE_TAG( 'M', 'M', 'S', 'D' ) -#define TTAG_mort FT_MAKE_TAG( 'm', 'o', 'r', 't' ) -#define TTAG_morx FT_MAKE_TAG( 'm', 'o', 'r', 'x' ) -#define TTAG_name FT_MAKE_TAG( 'n', 'a', 'm', 'e' ) -#define TTAG_opbd FT_MAKE_TAG( 'o', 'p', 'b', 'd' ) -#define TTAG_OS2 FT_MAKE_TAG( 'O', 'S', '/', '2' ) -#define TTAG_OTTO FT_MAKE_TAG( 'O', 'T', 'T', 'O' ) -#define TTAG_PCLT FT_MAKE_TAG( 'P', 'C', 'L', 'T' ) -#define TTAG_POST FT_MAKE_TAG( 'P', 'O', 'S', 'T' ) -#define TTAG_post FT_MAKE_TAG( 'p', 'o', 's', 't' ) -#define TTAG_prep FT_MAKE_TAG( 'p', 'r', 'e', 'p' ) -#define TTAG_prop FT_MAKE_TAG( 'p', 'r', 'o', 'p' ) -#define TTAG_sbix FT_MAKE_TAG( 's', 'b', 'i', 'x' ) -#define TTAG_sfnt FT_MAKE_TAG( 's', 'f', 'n', 't' ) -#define TTAG_SING FT_MAKE_TAG( 'S', 'I', 'N', 'G' ) -#define TTAG_trak FT_MAKE_TAG( 't', 'r', 'a', 'k' ) -#define TTAG_true FT_MAKE_TAG( 't', 'r', 'u', 'e' ) -#define TTAG_ttc FT_MAKE_TAG( 't', 't', 'c', ' ' ) -#define TTAG_ttcf FT_MAKE_TAG( 't', 't', 'c', 'f' ) -#define TTAG_TYP1 FT_MAKE_TAG( 'T', 'Y', 'P', '1' ) -#define TTAG_typ1 FT_MAKE_TAG( 't', 'y', 'p', '1' ) -#define TTAG_VDMX FT_MAKE_TAG( 'V', 'D', 'M', 'X' ) -#define TTAG_vhea FT_MAKE_TAG( 'v', 'h', 'e', 'a' ) -#define TTAG_vmtx FT_MAKE_TAG( 'v', 'm', 't', 'x' ) -#define TTAG_wOFF FT_MAKE_TAG( 'w', 'O', 'F', 'F' ) +#define TTAG_avar FT_MAKE_TAG('a', 'v', 'a', 'r') +#define TTAG_BASE FT_MAKE_TAG('B', 'A', 'S', 'E') +#define TTAG_bdat FT_MAKE_TAG('b', 'd', 'a', 't') +#define TTAG_BDF FT_MAKE_TAG('B', 'D', 'F', ' ') +#define TTAG_bhed FT_MAKE_TAG('b', 'h', 'e', 'd') +#define TTAG_bloc FT_MAKE_TAG('b', 'l', 'o', 'c') +#define TTAG_bsln FT_MAKE_TAG('b', 's', 'l', 'n') +#define TTAG_CBDT FT_MAKE_TAG('C', 'B', 'D', 'T') +#define TTAG_CBLC FT_MAKE_TAG('C', 'B', 'L', 'C') +#define TTAG_CFF FT_MAKE_TAG('C', 'F', 'F', ' ') +#define TTAG_CID FT_MAKE_TAG('C', 'I', 'D', ' ') +#define TTAG_cmap FT_MAKE_TAG('c', 'm', 'a', 'p') +#define TTAG_cvar FT_MAKE_TAG('c', 'v', 'a', 'r') +#define TTAG_cvt FT_MAKE_TAG('c', 'v', 't', ' ') +#define TTAG_DSIG FT_MAKE_TAG('D', 'S', 'I', 'G') +#define TTAG_EBDT FT_MAKE_TAG('E', 'B', 'D', 'T') +#define TTAG_EBLC FT_MAKE_TAG('E', 'B', 'L', 'C') +#define TTAG_EBSC FT_MAKE_TAG('E', 'B', 'S', 'C') +#define TTAG_feat FT_MAKE_TAG('f', 'e', 'a', 't') +#define TTAG_FOND FT_MAKE_TAG('F', 'O', 'N', 'D') +#define TTAG_fpgm FT_MAKE_TAG('f', 'p', 'g', 'm') +#define TTAG_fvar FT_MAKE_TAG('f', 'v', 'a', 'r') +#define TTAG_gasp FT_MAKE_TAG('g', 'a', 's', 'p') +#define TTAG_GDEF FT_MAKE_TAG('G', 'D', 'E', 'F') +#define TTAG_glyf FT_MAKE_TAG('g', 'l', 'y', 'f') +#define TTAG_GPOS FT_MAKE_TAG('G', 'P', 'O', 'S') +#define TTAG_GSUB FT_MAKE_TAG('G', 'S', 'U', 'B') +#define TTAG_gvar FT_MAKE_TAG('g', 'v', 'a', 'r') +#define TTAG_hdmx FT_MAKE_TAG('h', 'd', 'm', 'x') +#define TTAG_head FT_MAKE_TAG('h', 'e', 'a', 'd') +#define TTAG_hhea FT_MAKE_TAG('h', 'h', 'e', 'a') +#define TTAG_hmtx FT_MAKE_TAG('h', 'm', 't', 'x') +#define TTAG_JSTF FT_MAKE_TAG('J', 'S', 'T', 'F') +#define TTAG_just FT_MAKE_TAG('j', 'u', 's', 't') +#define TTAG_kern FT_MAKE_TAG('k', 'e', 'r', 'n') +#define TTAG_lcar FT_MAKE_TAG('l', 'c', 'a', 'r') +#define TTAG_loca FT_MAKE_TAG('l', 'o', 'c', 'a') +#define TTAG_LTSH FT_MAKE_TAG('L', 'T', 'S', 'H') +#define TTAG_LWFN FT_MAKE_TAG('L', 'W', 'F', 'N') +#define TTAG_MATH FT_MAKE_TAG('M', 'A', 'T', 'H') +#define TTAG_maxp FT_MAKE_TAG('m', 'a', 'x', 'p') +#define TTAG_META FT_MAKE_TAG('M', 'E', 'T', 'A') +#define TTAG_MMFX FT_MAKE_TAG('M', 'M', 'F', 'X') +#define TTAG_MMSD FT_MAKE_TAG('M', 'M', 'S', 'D') +#define TTAG_mort FT_MAKE_TAG('m', 'o', 'r', 't') +#define TTAG_morx FT_MAKE_TAG('m', 'o', 'r', 'x') +#define TTAG_name FT_MAKE_TAG('n', 'a', 'm', 'e') +#define TTAG_opbd FT_MAKE_TAG('o', 'p', 'b', 'd') +#define TTAG_OS2 FT_MAKE_TAG('O', 'S', '/', '2') +#define TTAG_OTTO FT_MAKE_TAG('O', 'T', 'T', 'O') +#define TTAG_PCLT FT_MAKE_TAG('P', 'C', 'L', 'T') +#define TTAG_POST FT_MAKE_TAG('P', 'O', 'S', 'T') +#define TTAG_post FT_MAKE_TAG('p', 'o', 's', 't') +#define TTAG_prep FT_MAKE_TAG('p', 'r', 'e', 'p') +#define TTAG_prop FT_MAKE_TAG('p', 'r', 'o', 'p') +#define TTAG_sbix FT_MAKE_TAG('s', 'b', 'i', 'x') +#define TTAG_sfnt FT_MAKE_TAG('s', 'f', 'n', 't') +#define TTAG_SING FT_MAKE_TAG('S', 'I', 'N', 'G') +#define TTAG_trak FT_MAKE_TAG('t', 'r', 'a', 'k') +#define TTAG_true FT_MAKE_TAG('t', 'r', 'u', 'e') +#define TTAG_ttc FT_MAKE_TAG('t', 't', 'c', ' ') +#define TTAG_ttcf FT_MAKE_TAG('t', 't', 'c', 'f') +#define TTAG_TYP1 FT_MAKE_TAG('T', 'Y', 'P', '1') +#define TTAG_typ1 FT_MAKE_TAG('t', 'y', 'p', '1') +#define TTAG_VDMX FT_MAKE_TAG('V', 'D', 'M', 'X') +#define TTAG_vhea FT_MAKE_TAG('v', 'h', 'e', 'a') +#define TTAG_vmtx FT_MAKE_TAG('v', 'm', 't', 'x') +#define TTAG_wOFF FT_MAKE_TAG('w', 'O', 'F', 'F') FT_END_HEADER diff --git a/include/freetype/ttunpat.h b/include/freetype/ttunpat.h index a016275..932a17e 100644 --- a/include/freetype/ttunpat.h +++ b/include/freetype/ttunpat.h @@ -46,7 +46,7 @@ FT_BEGIN_HEADER * interpreter for a typeface opened by @FT_Open_Face. * */ -#define FT_PARAM_TAG_UNPATENTED_HINTING FT_MAKE_TAG( 'u', 'n', 'p', 'a' ) +#define FT_PARAM_TAG_UNPATENTED_HINTING FT_MAKE_TAG('u', 'n', 'p', 'a') /* */ diff --git a/include/texture.hpp b/include/texture.hpp index 4202043..0611ded 100644 --- a/include/texture.hpp +++ b/include/texture.hpp @@ -73,7 +73,7 @@ public: Texturec(uint amt,const char **paths); Texturec(std::vectorvec); - Texturec( std::initializer_list l ); + Texturec(std::initializer_list l); /** * Frees memory taken by the image array. diff --git a/include/tinyxml2.h b/include/tinyxml2.h index 4282642..8e51a6a 100755 --- a/include/tinyxml2.h +++ b/include/tinyxml2.h @@ -51,7 +51,7 @@ distribution. AStyle.exe --style=1tbs --indent-switches --break-closing-brackets --indent-preprocessor tinyxml2.cpp tinyxml2.h */ -#if defined( _DEBUG ) || defined( DEBUG ) || defined (__DEBUG__) +#if defined(_DEBUG) || defined(DEBUG) || defined (__DEBUG__) # ifndef DEBUG # define DEBUG # endif @@ -78,16 +78,16 @@ distribution. #if defined(DEBUG) # if defined(_MSC_VER) # // "(void)0," is for suppressing C4127 warning in "assert(false)", "assert(true)" and the like -# define TIXMLASSERT( x ) if ( !((void)0,(x))) { __debugbreak(); } +# define TIXMLASSERT(x) if (!((void)0,(x))) { __debugbreak(); } # elif defined (ANDROID_NDK) # include -# define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); } +# define TIXMLASSERT(x) if (!(x)) { __android_log_assert("assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__); } # else # include # define TIXMLASSERT assert # endif #else -# define TIXMLASSERT( x ) {} +# define TIXMLASSERT(x) {} #endif @@ -131,10 +131,10 @@ public: COMMENT = NEEDS_NEWLINE_NORMALIZATION }; - StrPair() : _flags( 0 ), _start( 0 ), _end( 0 ) {} + StrPair() : _flags(0), _start(0), _end(0) {} ~StrPair(); - void Set( char* start, char* end, int flags ) { + void Set(char* start, char* end, int flags) { Reset(); _start = start; _end = end; @@ -147,17 +147,17 @@ public: return _start == _end; } - void SetInternedStr( const char* str ) { + void SetInternedStr(const char* str) { Reset(); _start = const_cast(str); } - void SetStr( const char* str, int flags=0 ); + void SetStr(const char* str, int flags=0); - char* ParseText( char* in, const char* endTag, int strFlags ); - char* ParseName( char* in ); + char* ParseText(char* in, const char* endTag, int strFlags); + char* ParseName(char* in); - void TransferTo( StrPair* other ); + void TransferTo(StrPair* other); private: void Reset(); @@ -172,8 +172,8 @@ private: char* _start; char* _end; - StrPair( const StrPair& other ); // not supported - void operator=( StrPair& other ); // not supported, use TransferTo() + StrPair(const StrPair& other); // not supported + void operator=(StrPair& other); // not supported, use TransferTo() }; @@ -193,7 +193,7 @@ public: } ~DynArray() { - if ( _mem != _pool ) { + if (_mem != _pool) { delete [] _mem; } } @@ -202,28 +202,28 @@ public: _size = 0; } - void Push( T t ) { - TIXMLASSERT( _size < INT_MAX ); - EnsureCapacity( _size+1 ); + void Push(T t) { + TIXMLASSERT(_size < INT_MAX); + EnsureCapacity(_size+1); _mem[_size++] = t; } - T* PushArr( int count ) { - TIXMLASSERT( count >= 0 ); - TIXMLASSERT( _size <= INT_MAX - count ); - EnsureCapacity( _size+count ); + T* PushArr(int count) { + TIXMLASSERT(count >= 0); + TIXMLASSERT(_size <= INT_MAX - count); + EnsureCapacity(_size+count); T* ret = &_mem[_size]; _size += count; return ret; } T Pop() { - TIXMLASSERT( _size > 0 ); + TIXMLASSERT(_size > 0); return _mem[--_size]; } - void PopArr( int count ) { - TIXMLASSERT( _size >= count ); + void PopArr(int count) { + TIXMLASSERT(_size >= count); _size -= count; } @@ -232,52 +232,52 @@ public: } T& operator[](int i) { - TIXMLASSERT( i>= 0 && i < _size ); + TIXMLASSERT(i>= 0 && i < _size); return _mem[i]; } const T& operator[](int i) const { - TIXMLASSERT( i>= 0 && i < _size ); + TIXMLASSERT(i>= 0 && i < _size); return _mem[i]; } const T& PeekTop() const { - TIXMLASSERT( _size > 0 ); + TIXMLASSERT(_size > 0); return _mem[ _size - 1]; } int Size() const { - TIXMLASSERT( _size >= 0 ); + TIXMLASSERT(_size >= 0); return _size; } int Capacity() const { - TIXMLASSERT( _allocated >= INITIAL_SIZE ); + TIXMLASSERT(_allocated >= INITIAL_SIZE); return _allocated; } const T* Mem() const { - TIXMLASSERT( _mem ); + TIXMLASSERT(_mem); return _mem; } T* Mem() { - TIXMLASSERT( _mem ); + TIXMLASSERT(_mem); return _mem; } private: - DynArray( const DynArray& ); // not supported - void operator=( const DynArray& ); // not supported + DynArray(const DynArray&); // not supported + void operator=(const DynArray&); // not supported - void EnsureCapacity( int cap ) { - TIXMLASSERT( cap > 0 ); - if ( cap > _allocated ) { - TIXMLASSERT( cap <= INT_MAX / 2 ); + void EnsureCapacity(int cap) { + TIXMLASSERT(cap > 0); + if (cap > _allocated) { + TIXMLASSERT(cap <= INT_MAX / 2); int newAllocated = cap * 2; T* newMem = new T[newAllocated]; - memcpy( newMem, _mem, sizeof(T)*_size ); // warning: not using constructors, only works for PODs - if ( _mem != _pool ) { + memcpy(newMem, _mem, sizeof(T)*_size); // warning: not using constructors, only works for PODs + if (_mem != _pool) { delete [] _mem; } _mem = newMem; @@ -304,7 +304,7 @@ public: virtual int ItemSize() const = 0; virtual void* Alloc() = 0; - virtual void Free( void* ) = 0; + virtual void Free(void*) = 0; virtual void SetTracked() = 0; virtual void Clear() = 0; }; @@ -324,7 +324,7 @@ public: void Clear() { // Delete the blocks. - while( !_blockPtrs.Empty()) { + while(!_blockPtrs.Empty()) { Block* b = _blockPtrs.Pop(); delete b; } @@ -343,12 +343,12 @@ public: } virtual void* Alloc() { - if ( !_root ) { + if (!_root) { // Need a new block. Block* block = new Block(); - _blockPtrs.Push( block ); + _blockPtrs.Push(block); - for( int i=0; ichunk[i].next = &block->chunk[i+1]; } block->chunk[COUNT-1].next = 0; @@ -358,7 +358,7 @@ public: _root = _root->next; ++_currentAllocs; - if ( _currentAllocs > _maxAllocs ) { + if (_currentAllocs > _maxAllocs) { _maxAllocs = _currentAllocs; } _nAllocs++; @@ -366,21 +366,21 @@ public: return result; } - virtual void Free( void* mem ) { - if ( !mem ) { + virtual void Free(void* mem) { + if (!mem) { return; } --_currentAllocs; - Chunk* chunk = static_cast( mem ); + Chunk* chunk = static_cast(mem); #ifdef DEBUG - memset( chunk, 0xfe, sizeof(Chunk) ); + memset(chunk, 0xfe, sizeof(Chunk)); #endif chunk->next = _root; _root = chunk; } - void Trace( const char* name ) { - printf( "Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n", - name, _maxAllocs, _maxAllocs*SIZE/1024, _currentAllocs, SIZE, _nAllocs, _blockPtrs.Size() ); + void Trace(const char* name) { + printf("Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n", + name, _maxAllocs, _maxAllocs*SIZE/1024, _currentAllocs, SIZE, _nAllocs, _blockPtrs.Size()); } void SetTracked() { @@ -403,8 +403,8 @@ public: enum { COUNT = (4*1024)/SIZE }; // Some compilers do not accept to use COUNT in private part if COUNT is private private: - MemPoolT( const MemPoolT& ); // not supported - void operator=( const MemPoolT& ); // not supported + MemPoolT(const MemPoolT&); // not supported + void operator=(const MemPoolT&); // not supported union Chunk { Chunk* next; @@ -449,37 +449,37 @@ public: virtual ~XMLVisitor() {} /// Visit a document. - virtual bool VisitEnter( const XMLDocument& /*doc*/ ) { + virtual bool VisitEnter(const XMLDocument& /*doc*/) { return true; } /// Visit a document. - virtual bool VisitExit( const XMLDocument& /*doc*/ ) { + virtual bool VisitExit(const XMLDocument& /*doc*/) { return true; } /// Visit an element. - virtual bool VisitEnter( const XMLElement& /*element*/, const XMLAttribute* /*firstAttribute*/ ) { + virtual bool VisitEnter(const XMLElement& /*element*/, const XMLAttribute* /*firstAttribute*/) { return true; } /// Visit an element. - virtual bool VisitExit( const XMLElement& /*element*/ ) { + virtual bool VisitExit(const XMLElement& /*element*/) { return true; } /// Visit a declaration. - virtual bool Visit( const XMLDeclaration& /*declaration*/ ) { + virtual bool Visit(const XMLDeclaration& /*declaration*/) { return true; } /// Visit a text node. - virtual bool Visit( const XMLText& /*text*/ ) { + virtual bool Visit(const XMLText& /*text*/) { return true; } /// Visit a comment node. - virtual bool Visit( const XMLComment& /*comment*/ ) { + virtual bool Visit(const XMLComment& /*comment*/) { return true; } /// Visit an unknown node. - virtual bool Visit( const XMLUnknown& /*unknown*/ ) { + virtual bool Visit(const XMLUnknown& /*unknown*/) { return true; } }; @@ -518,72 +518,72 @@ enum XMLError { class XMLUtil { public: - static const char* SkipWhiteSpace( const char* p ) { - TIXMLASSERT( p ); - while( IsWhiteSpace(*p) ) { + static const char* SkipWhiteSpace(const char* p) { + TIXMLASSERT(p); + while(IsWhiteSpace(*p)) { ++p; } - TIXMLASSERT( p ); + TIXMLASSERT(p); return p; } - static char* SkipWhiteSpace( char* p ) { - return const_cast( SkipWhiteSpace( const_cast(p) ) ); + static char* SkipWhiteSpace(char* p) { + return const_cast(SkipWhiteSpace(const_cast(p))); } // Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't // correct, but simple, and usually works. - static bool IsWhiteSpace( char p ) { - return !IsUTF8Continuation(p) && isspace( static_cast(p) ); + static bool IsWhiteSpace(char p) { + return !IsUTF8Continuation(p) && isspace(static_cast(p)); } - inline static bool IsNameStartChar( unsigned char ch ) { - if ( ch >= 128 ) { + inline static bool IsNameStartChar(unsigned char ch) { + if (ch >= 128) { // This is a heuristic guess in attempt to not implement Unicode-aware isalpha() return true; } - if ( isalpha( ch ) ) { + if (isalpha(ch)) { return true; } return ch == ':' || ch == '_'; } - inline static bool IsNameChar( unsigned char ch ) { - return IsNameStartChar( ch ) - || isdigit( ch ) + inline static bool IsNameChar(unsigned char ch) { + return IsNameStartChar(ch) + || isdigit(ch) || ch == '.' || ch == '-'; } - inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) { - if ( p == q ) { + inline static bool StringEqual(const char* p, const char* q, int nChar=INT_MAX) { + if (p == q) { return true; } - return strncmp( p, q, nChar ) == 0; + return strncmp(p, q, nChar) == 0; } - inline static bool IsUTF8Continuation( char p ) { - return ( p & 0x80 ) != 0; + inline static bool IsUTF8Continuation(char p) { + return (p & 0x80) != 0; } - static const char* ReadBOM( const char* p, bool* hasBOM ); + static const char* ReadBOM(const char* p, bool* hasBOM); // p is the starting location, // the UTF-8 value of the entity will be placed in value, and length filled in. - static const char* GetCharacterRef( const char* p, char* value, int* length ); - static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ); + static const char* GetCharacterRef(const char* p, char* value, int* length); + static void ConvertUTF32ToUTF8(unsigned long input, char* output, int* length); // converts primitive types to strings - static void ToStr( int v, char* buffer, int bufferSize ); - static void ToStr( unsigned v, char* buffer, int bufferSize ); - static void ToStr( bool v, char* buffer, int bufferSize ); - static void ToStr( float v, char* buffer, int bufferSize ); - static void ToStr( double v, char* buffer, int bufferSize ); + static void ToStr(int v, char* buffer, int bufferSize); + static void ToStr(unsigned v, char* buffer, int bufferSize); + static void ToStr(bool v, char* buffer, int bufferSize); + static void ToStr(float v, char* buffer, int bufferSize); + static void ToStr(double v, char* buffer, int bufferSize); // converts strings to primitive types - static bool ToInt( const char* str, int* value ); - static bool ToUnsigned( const char* str, unsigned* value ); - static bool ToBool( const char* str, bool* value ); - static bool ToFloat( const char* str, float* value ); - static bool ToDouble( const char* str, double* value ); + static bool ToInt(const char* str, int* value); + static bool ToUnsigned(const char* str, unsigned* value); + static bool ToBool(const char* str, bool* value); + static bool ToFloat(const char* str, float* value); + static bool ToDouble(const char* str, double* value); }; @@ -602,7 +602,7 @@ public: A Document can contain: Element (container or leaf) Comment (leaf) Unknown (leaf) - Declaration( leaf ) + Declaration(leaf) An Element can contain: Element (container or leaf) Text (leaf) @@ -620,12 +620,12 @@ public: /// Get the XMLDocument that owns this XMLNode. const XMLDocument* GetDocument() const { - TIXMLASSERT( _document ); + TIXMLASSERT(_document); return _document; } /// Get the XMLDocument that owns this XMLNode. XMLDocument* GetDocument() { - TIXMLASSERT( _document ); + TIXMLASSERT(_document); return _document; } @@ -687,7 +687,7 @@ public: /** Set the Value of an XML node. @sa Value() */ - void SetValue( const char* val, bool staticMem=false ); + void SetValue(const char* val, bool staticMem=false); /// Get the parent of this node on the DOM. const XMLNode* Parent() const { @@ -715,10 +715,10 @@ public: /** Get the first child element, or optionally the first child element with the specified name. */ - const XMLElement* FirstChildElement( const char* name = 0 ) const; + const XMLElement* FirstChildElement(const char* name = 0) const; - XMLElement* FirstChildElement( const char* name = 0 ) { - return const_cast(const_cast(this)->FirstChildElement( name )); + XMLElement* FirstChildElement(const char* name = 0) { + return const_cast(const_cast(this)->FirstChildElement(name)); } /// Get the last child node, or null if none exists. @@ -733,10 +733,10 @@ public: /** Get the last child element or optionally the last child element with the specified name. */ - const XMLElement* LastChildElement( const char* name = 0 ) const; + const XMLElement* LastChildElement(const char* name = 0) const; - XMLElement* LastChildElement( const char* name = 0 ) { - return const_cast(const_cast(this)->LastChildElement(name) ); + XMLElement* LastChildElement(const char* name = 0) { + return const_cast(const_cast(this)->LastChildElement(name)); } /// Get the previous (left) sibling node of this node. @@ -749,10 +749,10 @@ public: } /// Get the previous (left) sibling element of this node, with an optionally supplied name. - const XMLElement* PreviousSiblingElement( const char* name = 0 ) const ; + const XMLElement* PreviousSiblingElement(const char* name = 0) const ; - XMLElement* PreviousSiblingElement( const char* name = 0 ) { - return const_cast(const_cast(this)->PreviousSiblingElement( name ) ); + XMLElement* PreviousSiblingElement(const char* name = 0) { + return const_cast(const_cast(this)->PreviousSiblingElement(name)); } /// Get the next (right) sibling node of this node. @@ -765,10 +765,10 @@ public: } /// Get the next (right) sibling element of this node, with an optionally supplied name. - const XMLElement* NextSiblingElement( const char* name = 0 ) const; + const XMLElement* NextSiblingElement(const char* name = 0) const; - XMLElement* NextSiblingElement( const char* name = 0 ) { - return const_cast(const_cast(this)->NextSiblingElement( name ) ); + XMLElement* NextSiblingElement(const char* name = 0) { + return const_cast(const_cast(this)->NextSiblingElement(name)); } /** @@ -778,10 +778,10 @@ public: Returns the addThis argument or 0 if the node does not belong to the same document. */ - XMLNode* InsertEndChild( XMLNode* addThis ); + XMLNode* InsertEndChild(XMLNode* addThis); - XMLNode* LinkEndChild( XMLNode* addThis ) { - return InsertEndChild( addThis ); + XMLNode* LinkEndChild(XMLNode* addThis) { + return InsertEndChild(addThis); } /** Add a child node as the first (left) child. @@ -790,7 +790,7 @@ public: Returns the addThis argument or 0 if the node does not belong to the same document. */ - XMLNode* InsertFirstChild( XMLNode* addThis ); + XMLNode* InsertFirstChild(XMLNode* addThis); /** Add a node after the specified child node. If the child node is already part of the document, @@ -799,7 +799,7 @@ public: is not a child of this node, or if the node does not belong to the same document. */ - XMLNode* InsertAfterChild( XMLNode* afterThis, XMLNode* addThis ); + XMLNode* InsertAfterChild(XMLNode* afterThis, XMLNode* addThis); /** Delete all the children of this node. @@ -809,7 +809,7 @@ public: /** Delete a child of this node. */ - void DeleteChild( XMLNode* node ); + void DeleteChild(XMLNode* node); /** Make a copy of this node, but not its children. @@ -820,7 +820,7 @@ public: Note: if called on a XMLDocument, this will return null. */ - virtual XMLNode* ShallowClone( XMLDocument* document ) const = 0; + virtual XMLNode* ShallowClone(XMLDocument* document) const = 0; /** Test if 2 nodes are the same, but don't test children. @@ -828,7 +828,7 @@ public: Note: if called on a XMLDocument, this will return false. */ - virtual bool ShallowEqual( const XMLNode* compare ) const = 0; + virtual bool ShallowEqual(const XMLNode* compare) const = 0; /** Accept a hierarchical visit of the nodes in the TinyXML-2 DOM. Every node in the XML tree will be conditionally visited and the host will be called back @@ -848,17 +848,17 @@ public: An example of using Accept(): @verbatim XMLPrinter printer; - tinyxmlDoc.Accept( &printer ); + tinyxmlDoc.Accept(&printer); const char* xmlcstr = printer.CStr(); @endverbatim */ - virtual bool Accept( XMLVisitor* visitor ) const = 0; + virtual bool Accept(XMLVisitor* visitor) const = 0; protected: - XMLNode( XMLDocument* ); + XMLNode(XMLDocument*); virtual ~XMLNode(); - virtual char* ParseDeep( char*, StrPair* ); + virtual char* ParseDeep(char*, StrPair*); XMLDocument* _document; XMLNode* _parent; @@ -872,12 +872,12 @@ protected: private: MemPool* _memPool; - void Unlink( XMLNode* child ); - static void DeleteNode( XMLNode* node ); - void InsertChildPreamble( XMLNode* insertThis ) const; + void Unlink(XMLNode* child); + static void DeleteNode(XMLNode* node); + void InsertChildPreamble(XMLNode* insertThis) const; - XMLNode( const XMLNode& ); // not supported - XMLNode& operator=( const XMLNode& ); // not supported + XMLNode(const XMLNode&); // not supported + XMLNode& operator=(const XMLNode&); // not supported }; @@ -898,7 +898,7 @@ class TINYXML2_LIB XMLText : public XMLNode friend class XMLBase; friend class XMLDocument; public: - virtual bool Accept( XMLVisitor* visitor ) const; + virtual bool Accept(XMLVisitor* visitor) const; virtual XMLText* ToText() { return this; @@ -908,7 +908,7 @@ public: } /// Declare whether this should be CDATA or standard text. - void SetCData( bool isCData ) { + void SetCData(bool isCData) { _isCData = isCData; } /// Returns true if this is a CDATA text element. @@ -916,20 +916,20 @@ public: return _isCData; } - virtual XMLNode* ShallowClone( XMLDocument* document ) const; - virtual bool ShallowEqual( const XMLNode* compare ) const; + virtual XMLNode* ShallowClone(XMLDocument* document) const; + virtual bool ShallowEqual(const XMLNode* compare) const; protected: - XMLText( XMLDocument* doc ) : XMLNode( doc ), _isCData( false ) {} + XMLText(XMLDocument* doc) : XMLNode(doc), _isCData(false) {} virtual ~XMLText() {} - char* ParseDeep( char*, StrPair* endTag ); + char* ParseDeep(char*, StrPair* endTag); private: bool _isCData; - XMLText( const XMLText& ); // not supported - XMLText& operator=( const XMLText& ); // not supported + XMLText(const XMLText&); // not supported + XMLText& operator=(const XMLText&); // not supported }; @@ -945,20 +945,20 @@ public: return this; } - virtual bool Accept( XMLVisitor* visitor ) const; + virtual bool Accept(XMLVisitor* visitor) const; - virtual XMLNode* ShallowClone( XMLDocument* document ) const; - virtual bool ShallowEqual( const XMLNode* compare ) const; + virtual XMLNode* ShallowClone(XMLDocument* document) const; + virtual bool ShallowEqual(const XMLNode* compare) const; protected: - XMLComment( XMLDocument* doc ); + XMLComment(XMLDocument* doc); virtual ~XMLComment(); - char* ParseDeep( char*, StrPair* endTag ); + char* ParseDeep(char*, StrPair* endTag); private: - XMLComment( const XMLComment& ); // not supported - XMLComment& operator=( const XMLComment& ); // not supported + XMLComment(const XMLComment&); // not supported + XMLComment& operator=(const XMLComment&); // not supported }; @@ -984,20 +984,20 @@ public: return this; } - virtual bool Accept( XMLVisitor* visitor ) const; + virtual bool Accept(XMLVisitor* visitor) const; - virtual XMLNode* ShallowClone( XMLDocument* document ) const; - virtual bool ShallowEqual( const XMLNode* compare ) const; + virtual XMLNode* ShallowClone(XMLDocument* document) const; + virtual bool ShallowEqual(const XMLNode* compare) const; protected: - XMLDeclaration( XMLDocument* doc ); + XMLDeclaration(XMLDocument* doc); virtual ~XMLDeclaration(); - char* ParseDeep( char*, StrPair* endTag ); + char* ParseDeep(char*, StrPair* endTag); private: - XMLDeclaration( const XMLDeclaration& ); // not supported - XMLDeclaration& operator=( const XMLDeclaration& ); // not supported + XMLDeclaration(const XMLDeclaration&); // not supported + XMLDeclaration& operator=(const XMLDeclaration&); // not supported }; @@ -1019,20 +1019,20 @@ public: return this; } - virtual bool Accept( XMLVisitor* visitor ) const; + virtual bool Accept(XMLVisitor* visitor) const; - virtual XMLNode* ShallowClone( XMLDocument* document ) const; - virtual bool ShallowEqual( const XMLNode* compare ) const; + virtual XMLNode* ShallowClone(XMLDocument* document) const; + virtual bool ShallowEqual(const XMLNode* compare) const; protected: - XMLUnknown( XMLDocument* doc ); + XMLUnknown(XMLDocument* doc); virtual ~XMLUnknown(); - char* ParseDeep( char*, StrPair* endTag ); + char* ParseDeep(char*, StrPair* endTag); private: - XMLUnknown( const XMLUnknown& ); // not supported - XMLUnknown& operator=( const XMLUnknown& ); // not supported + XMLUnknown(const XMLUnknown&); // not supported + XMLUnknown& operator=(const XMLUnknown&); // not supported }; @@ -1064,31 +1064,31 @@ public: */ int IntValue() const { int i=0; - QueryIntValue( &i ); + QueryIntValue(&i); return i; } /// Query as an unsigned integer. See IntValue() unsigned UnsignedValue() const { unsigned i=0; - QueryUnsignedValue( &i ); + QueryUnsignedValue(&i); return i; } /// Query as a boolean. See IntValue() bool BoolValue() const { bool b=false; - QueryBoolValue( &b ); + QueryBoolValue(&b); return b; } /// Query as a double. See IntValue() double DoubleValue() const { double d=0; - QueryDoubleValue( &d ); + QueryDoubleValue(&d); return d; } /// Query as a float. See IntValue() float FloatValue() const { float f=0; - QueryFloatValue( &f ); + QueryFloatValue(&f); return f; } @@ -1096,40 +1096,40 @@ public: in the provided parameter. The function will return XML_NO_ERROR on success, and XML_WRONG_ATTRIBUTE_TYPE if the conversion is not successful. */ - XMLError QueryIntValue( int* value ) const; + XMLError QueryIntValue(int* value) const; /// See QueryIntValue - XMLError QueryUnsignedValue( unsigned int* value ) const; + XMLError QueryUnsignedValue(unsigned int* value) const; /// See QueryIntValue - XMLError QueryBoolValue( bool* value ) const; + XMLError QueryBoolValue(bool* value) const; /// See QueryIntValue - XMLError QueryDoubleValue( double* value ) const; + XMLError QueryDoubleValue(double* value) const; /// See QueryIntValue - XMLError QueryFloatValue( float* value ) const; + XMLError QueryFloatValue(float* value) const; /// Set the attribute to a string value. - void SetAttribute( const char* value ); + void SetAttribute(const char* value); /// Set the attribute to value. - void SetAttribute( int value ); + void SetAttribute(int value); /// Set the attribute to value. - void SetAttribute( unsigned value ); + void SetAttribute(unsigned value); /// Set the attribute to value. - void SetAttribute( bool value ); + void SetAttribute(bool value); /// Set the attribute to value. - void SetAttribute( double value ); + void SetAttribute(double value); /// Set the attribute to value. - void SetAttribute( float value ); + void SetAttribute(float value); private: enum { BUF_SIZE = 200 }; - XMLAttribute() : _next( 0 ), _memPool( 0 ) {} + XMLAttribute() : _next(0), _memPool(0) {} virtual ~XMLAttribute() {} - XMLAttribute( const XMLAttribute& ); // not supported - void operator=( const XMLAttribute& ); // not supported - void SetName( const char* name ); + XMLAttribute(const XMLAttribute&); // not supported + void operator=(const XMLAttribute&); // not supported + void SetName(const char* name); - char* ParseDeep( char* p, bool processEntities ); + char* ParseDeep(char* p, bool processEntities); mutable StrPair _name; mutable StrPair _value; @@ -1152,8 +1152,8 @@ public: return Value(); } /// Set the name of the element. - void SetName( const char* str, bool staticMem=false ) { - SetValue( str, staticMem ); + void SetName(const char* str, bool staticMem=false) { + SetValue(str, staticMem); } virtual XMLElement* ToElement() { @@ -1162,14 +1162,14 @@ public: virtual const XMLElement* ToElement() const { return this; } - virtual bool Accept( XMLVisitor* visitor ) const; + virtual bool Accept(XMLVisitor* visitor) const; /** Given an attribute name, Attribute() returns the value for the attribute of that name, or null if none exists. For example: @verbatim - const char* value = ele->Attribute( "foo" ); + const char* value = ele->Attribute("foo"); @endverbatim The 'value' parameter is normally null. However, if specified, @@ -1177,55 +1177,55 @@ public: match. This allow you to write code: @verbatim - if ( ele->Attribute( "foo", "bar" ) ) callFooIsBar(); + if (ele->Attribute("foo", "bar")) callFooIsBar(); @endverbatim rather than: @verbatim - if ( ele->Attribute( "foo" ) ) { - if ( strcmp( ele->Attribute( "foo" ), "bar" ) == 0 ) callFooIsBar(); + if (ele->Attribute("foo")) { + if (strcmp(ele->Attribute("foo"), "bar") == 0) callFooIsBar(); } @endverbatim */ - const char* Attribute( const char* name, const char* value=0 ) const; + const char* Attribute(const char* name, const char* value=0) const; /** Functions the same as Attribute(), but returns the result as a std::string. */ - std::string StrAttribute( const char* name, const char* value=0 ) const; + std::string StrAttribute(const char* name, const char* value=0) const; /** Given an attribute name, IntAttribute() returns the value of the attribute interpreted as an integer. 0 will be returned if there is an error. For a method with error checking, see QueryIntAttribute() */ - int IntAttribute( const char* name ) const { + int IntAttribute(const char* name) const { int i=0; - QueryIntAttribute( name, &i ); + QueryIntAttribute(name, &i); return i; } /// See IntAttribute() - unsigned UnsignedAttribute( const char* name ) const { + unsigned UnsignedAttribute(const char* name) const { unsigned i=0; - QueryUnsignedAttribute( name, &i ); + QueryUnsignedAttribute(name, &i); return i; } /// See IntAttribute() - bool BoolAttribute( const char* name ) const { + bool BoolAttribute(const char* name) const { bool b=false; - QueryBoolAttribute( name, &b ); + QueryBoolAttribute(name, &b); return b; } /// See IntAttribute() - double DoubleAttribute( const char* name ) const { + double DoubleAttribute(const char* name) const { double d=0; - QueryDoubleAttribute( name, &d ); + QueryDoubleAttribute(name, &d); return d; } /// See IntAttribute() - float FloatAttribute( const char* name ) const { + float FloatAttribute(const char* name) const { float f=0; - QueryFloatAttribute( name, &f ); + QueryFloatAttribute(name, &f); return f; } @@ -1239,47 +1239,47 @@ public: @verbatim int value = 10; - QueryIntAttribute( "foo", &value ); // if "foo" isn't found, value will still be 10 + QueryIntAttribute("foo", &value); // if "foo" isn't found, value will still be 10 @endverbatim */ - XMLError QueryIntAttribute( const char* name, int* value ) const { - const XMLAttribute* a = FindAttribute( name ); - if ( !a ) { + XMLError QueryIntAttribute(const char* name, int* value) const { + const XMLAttribute* a = FindAttribute(name); + if (!a) { return XML_NO_ATTRIBUTE; } - return a->QueryIntValue( value ); + return a->QueryIntValue(value); } /// See QueryIntAttribute() - XMLError QueryUnsignedAttribute( const char* name, unsigned int* value ) const { - const XMLAttribute* a = FindAttribute( name ); - if ( !a ) { + XMLError QueryUnsignedAttribute(const char* name, unsigned int* value) const { + const XMLAttribute* a = FindAttribute(name); + if (!a) { return XML_NO_ATTRIBUTE; } - return a->QueryUnsignedValue( value ); + return a->QueryUnsignedValue(value); } /// See QueryIntAttribute() - XMLError QueryBoolAttribute( const char* name, bool* value ) const { - const XMLAttribute* a = FindAttribute( name ); - if ( !a ) { + XMLError QueryBoolAttribute(const char* name, bool* value) const { + const XMLAttribute* a = FindAttribute(name); + if (!a) { return XML_NO_ATTRIBUTE; } - return a->QueryBoolValue( value ); + return a->QueryBoolValue(value); } /// See QueryIntAttribute() - XMLError QueryDoubleAttribute( const char* name, double* value ) const { - const XMLAttribute* a = FindAttribute( name ); - if ( !a ) { + XMLError QueryDoubleAttribute(const char* name, double* value) const { + const XMLAttribute* a = FindAttribute(name); + if (!a) { return XML_NO_ATTRIBUTE; } - return a->QueryDoubleValue( value ); + return a->QueryDoubleValue(value); } /// See QueryIntAttribute() - XMLError QueryFloatAttribute( const char* name, float* value ) const { - const XMLAttribute* a = FindAttribute( name ); - if ( !a ) { + XMLError QueryFloatAttribute(const char* name, float* value) const { + const XMLAttribute* a = FindAttribute(name); + if (!a) { return XML_NO_ATTRIBUTE; } - return a->QueryFloatValue( value ); + return a->QueryFloatValue(value); } @@ -1297,71 +1297,71 @@ public: @verbatim int value = 10; - QueryAttribute( "foo", &value ); // if "foo" isn't found, value will still be 10 + QueryAttribute("foo", &value); // if "foo" isn't found, value will still be 10 @endverbatim */ - int QueryAttribute( const char* name, int* value ) const { - return QueryIntAttribute( name, value ); + int QueryAttribute(const char* name, int* value) const { + return QueryIntAttribute(name, value); } - int QueryAttribute( const char* name, unsigned int* value ) const { - return QueryUnsignedAttribute( name, value ); + int QueryAttribute(const char* name, unsigned int* value) const { + return QueryUnsignedAttribute(name, value); } - int QueryAttribute( const char* name, bool* value ) const { - return QueryBoolAttribute( name, value ); + int QueryAttribute(const char* name, bool* value) const { + return QueryBoolAttribute(name, value); } - int QueryAttribute( const char* name, double* value ) const { - return QueryDoubleAttribute( name, value ); + int QueryAttribute(const char* name, double* value) const { + return QueryDoubleAttribute(name, value); } - int QueryAttribute( const char* name, float* value ) const { - return QueryFloatAttribute( name, value ); + int QueryAttribute(const char* name, float* value) const { + return QueryFloatAttribute(name, value); } /// Sets the named attribute to value. - void SetAttribute( const char* name, const char* value ) { - XMLAttribute* a = FindOrCreateAttribute( name ); - a->SetAttribute( value ); + void SetAttribute(const char* name, const char* value) { + XMLAttribute* a = FindOrCreateAttribute(name); + a->SetAttribute(value); } /// Sets the named attribute to value. - void SetAttribute( const char* name, int value ) { - XMLAttribute* a = FindOrCreateAttribute( name ); - a->SetAttribute( value ); + void SetAttribute(const char* name, int value) { + XMLAttribute* a = FindOrCreateAttribute(name); + a->SetAttribute(value); } /// Sets the named attribute to value. - void SetAttribute( const char* name, unsigned value ) { - XMLAttribute* a = FindOrCreateAttribute( name ); - a->SetAttribute( value ); + void SetAttribute(const char* name, unsigned value) { + XMLAttribute* a = FindOrCreateAttribute(name); + a->SetAttribute(value); } /// Sets the named attribute to value. - void SetAttribute( const char* name, bool value ) { - XMLAttribute* a = FindOrCreateAttribute( name ); - a->SetAttribute( value ); + void SetAttribute(const char* name, bool value) { + XMLAttribute* a = FindOrCreateAttribute(name); + a->SetAttribute(value); } /// Sets the named attribute to value. - void SetAttribute( const char* name, double value ) { - XMLAttribute* a = FindOrCreateAttribute( name ); - a->SetAttribute( value ); + void SetAttribute(const char* name, double value) { + XMLAttribute* a = FindOrCreateAttribute(name); + a->SetAttribute(value); } /// Sets the named attribute to value. - void SetAttribute( const char* name, float value ) { - XMLAttribute* a = FindOrCreateAttribute( name ); - a->SetAttribute( value ); + void SetAttribute(const char* name, float value) { + XMLAttribute* a = FindOrCreateAttribute(name); + a->SetAttribute(value); } /** Delete an attribute. */ - void DeleteAttribute( const char* name ); + void DeleteAttribute(const char* name); /// Return the first attribute in the list. const XMLAttribute* FirstAttribute() const { return _rootAttribute; } /// Query a specific attribute in the list. - const XMLAttribute* FindAttribute( const char* name ) const; + const XMLAttribute* FindAttribute(const char* name) const; /** Convenience function for easy access to the text inside an element. Although easy and concise, GetText() is limited compared to getting the XMLText child @@ -1403,7 +1403,7 @@ public: This is a convenient method for setting the text of simple contained text: @verbatim This is text - fooElement->SetText( "Hullaballoo!" ); + fooElement->SetText("Hullaballoo!"); Hullaballoo! @endverbatim @@ -1427,17 +1427,17 @@ public: Hullaballoo! @endverbatim */ - void SetText( const char* inText ); + void SetText(const char* inText); /// Convenience method for setting text inside an element. See SetText() for important limitations. - void SetText( int value ); + void SetText(int value); /// Convenience method for setting text inside an element. See SetText() for important limitations. - void SetText( unsigned value ); + void SetText(unsigned value); /// Convenience method for setting text inside an element. See SetText() for important limitations. - void SetText( bool value ); + void SetText(bool value); /// Convenience method for setting text inside an element. See SetText() for important limitations. - void SetText( double value ); + void SetText(double value); /// Convenience method for setting text inside an element. See SetText() for important limitations. - void SetText( float value ); + void SetText(float value); /** Convenience method to query the value of a child text node. This is probably best @@ -1455,25 +1455,25 @@ public: @verbatim int x = 0; float y = 0; // types of x and y are contrived for example - const XMLElement* xElement = pointElement->FirstChildElement( "x" ); - const XMLElement* yElement = pointElement->FirstChildElement( "y" ); - xElement->QueryIntText( &x ); - yElement->QueryFloatText( &y ); + const XMLElement* xElement = pointElement->FirstChildElement("x"); + const XMLElement* yElement = pointElement->FirstChildElement("y"); + xElement->QueryIntText(&x); + yElement->QueryFloatText(&y); @endverbatim @returns XML_SUCCESS (0) on success, XML_CAN_NOT_CONVERT_TEXT if the text cannot be converted to the requested type, and XML_NO_TEXT_NODE if there is no child text to query. */ - XMLError QueryIntText( int* ival ) const; + XMLError QueryIntText(int* ival) const; /// See QueryIntText() - XMLError QueryUnsignedText( unsigned* uval ) const; + XMLError QueryUnsignedText(unsigned* uval) const; /// See QueryIntText() - XMLError QueryBoolText( bool* bval ) const; + XMLError QueryBoolText(bool* bval) const; /// See QueryIntText() - XMLError QueryDoubleText( double* dval ) const; + XMLError QueryDoubleText(double* dval) const; /// See QueryIntText() - XMLError QueryFloatText( float* fval ) const; + XMLError QueryFloatText(float* fval) const; // internal: enum { @@ -1484,25 +1484,25 @@ public: int ClosingType() const { return _closingType; } - virtual XMLNode* ShallowClone( XMLDocument* document ) const; - virtual bool ShallowEqual( const XMLNode* compare ) const; + virtual XMLNode* ShallowClone(XMLDocument* document) const; + virtual bool ShallowEqual(const XMLNode* compare) const; protected: - char* ParseDeep( char* p, StrPair* endTag ); + char* ParseDeep(char* p, StrPair* endTag); private: - XMLElement( XMLDocument* doc ); + XMLElement(XMLDocument* doc); virtual ~XMLElement(); - XMLElement( const XMLElement& ); // not supported - void operator=( const XMLElement& ); // not supported + XMLElement(const XMLElement&); // not supported + void operator=(const XMLElement&); // not supported - XMLAttribute* FindAttribute( const char* name ) { - return const_cast(const_cast(this)->FindAttribute( name )); + XMLAttribute* FindAttribute(const char* name) { + return const_cast(const_cast(this)->FindAttribute(name)); } - XMLAttribute* FindOrCreateAttribute( const char* name ); - //void LinkAttribute( XMLAttribute* attrib ); - char* ParseAttributes( char* p ); - static void DeleteAttribute( XMLAttribute* attribute ); + XMLAttribute* FindOrCreateAttribute(const char* name); + //void LinkAttribute(XMLAttribute* attrib); + char* ParseAttributes(char* p); + static void DeleteAttribute(XMLAttribute* attribute); enum { BUF_SIZE = 200 }; int _closingType; @@ -1529,15 +1529,15 @@ class TINYXML2_LIB XMLDocument : public XMLNode friend class XMLElement; public: /// constructor - XMLDocument( bool processEntities = true, Whitespace = PRESERVE_WHITESPACE ); + XMLDocument(bool processEntities = true, Whitespace = PRESERVE_WHITESPACE); ~XMLDocument(); virtual XMLDocument* ToDocument() { - TIXMLASSERT( this == _document ); + TIXMLASSERT(this == _document); return this; } virtual const XMLDocument* ToDocument() const { - TIXMLASSERT( this == _document ); + TIXMLASSERT(this == _document); return this; } @@ -1551,14 +1551,14 @@ public: specified, TinyXML-2 will assume 'xml' points to a null terminated string. */ - XMLError Parse( const char* xml, size_t nBytes=(size_t)(-1) ); + XMLError Parse(const char* xml, size_t nBytes=(size_t)(-1)); /** Load an XML file from disk. Returns XML_NO_ERROR (0) on success, or an errorID. */ - XMLError LoadFile( const char* filename ); + XMLError LoadFile(const char* filename); /** Load an XML file from disk. You are responsible @@ -1571,14 +1571,14 @@ public: Returns XML_NO_ERROR (0) on success, or an errorID. */ - XMLError LoadFile( FILE* ); + XMLError LoadFile(FILE*); /** Save the XML file to disk. Returns XML_NO_ERROR (0) on success, or an errorID. */ - XMLError SaveFile( const char* filename, bool compact = false ); + XMLError SaveFile(const char* filename, bool compact = false); /** Save the XML file to disk. You are responsible @@ -1587,7 +1587,7 @@ public: Returns XML_NO_ERROR (0) on success, or an errorID. */ - XMLError SaveFile( FILE* fp, bool compact = false ); + XMLError SaveFile(FILE* fp, bool compact = false); bool ProcessEntities() const { return _processEntities; @@ -1604,7 +1604,7 @@ public: } /** Sets whether to write the BOM when writing the file. */ - void SetBOM( bool useBOM ) { + void SetBOM(bool useBOM) { _writeBOM = useBOM; } @@ -1621,38 +1621,38 @@ public: /** Print the Document. If the Printer is not provided, it will print to stdout. If you provide Printer, this can print to a file: @verbatim - XMLPrinter printer( fp ); - doc.Print( &printer ); + XMLPrinter printer(fp); + doc.Print(&printer); @endverbatim Or you can use a printer to print to memory: @verbatim XMLPrinter printer; - doc.Print( &printer ); + doc.Print(&printer); // printer.CStr() has a const char* to the XML @endverbatim */ - void Print( XMLPrinter* streamer=0 ) const; - virtual bool Accept( XMLVisitor* visitor ) const; + void Print(XMLPrinter* streamer=0) const; + virtual bool Accept(XMLVisitor* visitor) const; /** Create a new Element associated with this Document. The memory for the Element is managed by the Document. */ - XMLElement* NewElement( const char* name ); + XMLElement* NewElement(const char* name); /** Create a new Comment associated with this Document. The memory for the Comment is managed by the Document. */ - XMLComment* NewComment( const char* comment ); + XMLComment* NewComment(const char* comment); /** Create a new Text associated with this Document. The memory for the Text is managed by the Document. */ - XMLText* NewText( const char* text ); + XMLText* NewText(const char* text); /** Create a new Declaration associated with this Document. The memory for the object @@ -1664,21 +1664,21 @@ public: @endverbatim */ - XMLDeclaration* NewDeclaration( const char* text=0 ); + XMLDeclaration* NewDeclaration(const char* text=0); /** Create a new Unknown associated with this Document. The memory for the object is managed by the Document. */ - XMLUnknown* NewUnknown( const char* text ); + XMLUnknown* NewUnknown(const char* text); /** Delete a node associated with this document. It will be unlinked from the DOM. */ - void DeleteNode( XMLNode* node ); + void DeleteNode(XMLNode* node); - void SetError( XMLError error, const char* str1, const char* str2 ); + void SetError(XMLError error, const char* str1, const char* str2); /// Return true if there was an error parsing the document. bool Error() const { @@ -1705,18 +1705,18 @@ public: void Clear(); // internal - char* Identify( char* p, XMLNode** node ); + char* Identify(char* p, XMLNode** node); - virtual XMLNode* ShallowClone( XMLDocument* /*document*/ ) const { + virtual XMLNode* ShallowClone(XMLDocument* /*document*/) const { return 0; } - virtual bool ShallowEqual( const XMLNode* /*compare*/ ) const { + virtual bool ShallowEqual(const XMLNode* /*compare*/) const { return false; } private: - XMLDocument( const XMLDocument& ); // not supported - void operator=( const XMLDocument& ); // not supported + XMLDocument(const XMLDocument&); // not supported + void operator=(const XMLDocument&); // not supported bool _writeBOM; bool _processEntities; @@ -1756,17 +1756,17 @@ private: easy to write a *lot* of code that looks like: @verbatim - XMLElement* root = document.FirstChildElement( "Document" ); - if ( root ) + XMLElement* root = document.FirstChildElement("Document"); + if (root) { - XMLElement* element = root->FirstChildElement( "Element" ); - if ( element ) + XMLElement* element = root->FirstChildElement("Element"); + if (element) { - XMLElement* child = element->FirstChildElement( "Child" ); - if ( child ) + XMLElement* child = element->FirstChildElement("Child"); + if (child) { - XMLElement* child2 = child->NextSiblingElement( "Child" ); - if ( child2 ) + XMLElement* child2 = child->NextSiblingElement("Child"); + if (child2) { // Finally do something useful. @endverbatim @@ -1776,9 +1776,9 @@ private: and correct to use: @verbatim - XMLHandle docHandle( &document ); - XMLElement* child2 = docHandle.FirstChildElement( "Document" ).FirstChildElement( "Element" ).FirstChildElement().NextSiblingElement(); - if ( child2 ) + XMLHandle docHandle(&document); + XMLElement* child2 = docHandle.FirstChildElement("Document").FirstChildElement("Element").FirstChildElement().NextSiblingElement(); + if (child2) { // do something useful @endverbatim @@ -1796,54 +1796,54 @@ class TINYXML2_LIB XMLHandle { public: /// Create a handle from any node (at any depth of the tree.) This can be a null pointer. - XMLHandle( XMLNode* node ) { + XMLHandle(XMLNode* node) { _node = node; } /// Create a handle from a node. - XMLHandle( XMLNode& node ) { + XMLHandle(XMLNode& node) { _node = &node; } /// Copy constructor - XMLHandle( const XMLHandle& ref ) { + XMLHandle(const XMLHandle& ref) { _node = ref._node; } /// Assignment - XMLHandle& operator=( const XMLHandle& ref ) { + XMLHandle& operator=(const XMLHandle& ref) { _node = ref._node; return *this; } /// Get the first child of this handle. XMLHandle FirstChild() { - return XMLHandle( _node ? _node->FirstChild() : 0 ); + return XMLHandle(_node ? _node->FirstChild() : 0); } /// Get the first child element of this handle. - XMLHandle FirstChildElement( const char* name = 0 ) { - return XMLHandle( _node ? _node->FirstChildElement( name ) : 0 ); + XMLHandle FirstChildElement(const char* name = 0) { + return XMLHandle(_node ? _node->FirstChildElement(name) : 0); } /// Get the last child of this handle. XMLHandle LastChild() { - return XMLHandle( _node ? _node->LastChild() : 0 ); + return XMLHandle(_node ? _node->LastChild() : 0); } /// Get the last child element of this handle. - XMLHandle LastChildElement( const char* name = 0 ) { - return XMLHandle( _node ? _node->LastChildElement( name ) : 0 ); + XMLHandle LastChildElement(const char* name = 0) { + return XMLHandle(_node ? _node->LastChildElement(name) : 0); } /// Get the previous sibling of this handle. XMLHandle PreviousSibling() { - return XMLHandle( _node ? _node->PreviousSibling() : 0 ); + return XMLHandle(_node ? _node->PreviousSibling() : 0); } /// Get the previous sibling element of this handle. - XMLHandle PreviousSiblingElement( const char* name = 0 ) { - return XMLHandle( _node ? _node->PreviousSiblingElement( name ) : 0 ); + XMLHandle PreviousSiblingElement(const char* name = 0) { + return XMLHandle(_node ? _node->PreviousSiblingElement(name) : 0); } /// Get the next sibling of this handle. XMLHandle NextSibling() { - return XMLHandle( _node ? _node->NextSibling() : 0 ); + return XMLHandle(_node ? _node->NextSibling() : 0); } /// Get the next sibling element of this handle. - XMLHandle NextSiblingElement( const char* name = 0 ) { - return XMLHandle( _node ? _node->NextSiblingElement( name ) : 0 ); + XMLHandle NextSiblingElement(const char* name = 0) { + return XMLHandle(_node ? _node->NextSiblingElement(name) : 0); } /// Safe cast to XMLNode. This can return null. @@ -1852,19 +1852,19 @@ public: } /// Safe cast to XMLElement. This can return null. XMLElement* ToElement() { - return ( ( _node == 0 ) ? 0 : _node->ToElement() ); + return ((_node == 0) ? 0 : _node->ToElement()); } /// Safe cast to XMLText. This can return null. XMLText* ToText() { - return ( ( _node == 0 ) ? 0 : _node->ToText() ); + return ((_node == 0) ? 0 : _node->ToText()); } /// Safe cast to XMLUnknown. This can return null. XMLUnknown* ToUnknown() { - return ( ( _node == 0 ) ? 0 : _node->ToUnknown() ); + return ((_node == 0) ? 0 : _node->ToUnknown()); } /// Safe cast to XMLDeclaration. This can return null. XMLDeclaration* ToDeclaration() { - return ( ( _node == 0 ) ? 0 : _node->ToDeclaration() ); + return ((_node == 0) ? 0 : _node->ToDeclaration()); } private: @@ -1879,44 +1879,44 @@ private: class TINYXML2_LIB XMLConstHandle { public: - XMLConstHandle( const XMLNode* node ) { + XMLConstHandle(const XMLNode* node) { _node = node; } - XMLConstHandle( const XMLNode& node ) { + XMLConstHandle(const XMLNode& node) { _node = &node; } - XMLConstHandle( const XMLConstHandle& ref ) { + XMLConstHandle(const XMLConstHandle& ref) { _node = ref._node; } - XMLConstHandle& operator=( const XMLConstHandle& ref ) { + XMLConstHandle& operator=(const XMLConstHandle& ref) { _node = ref._node; return *this; } const XMLConstHandle FirstChild() const { - return XMLConstHandle( _node ? _node->FirstChild() : 0 ); + return XMLConstHandle(_node ? _node->FirstChild() : 0); } - const XMLConstHandle FirstChildElement( const char* name = 0 ) const { - return XMLConstHandle( _node ? _node->FirstChildElement( name ) : 0 ); + const XMLConstHandle FirstChildElement(const char* name = 0) const { + return XMLConstHandle(_node ? _node->FirstChildElement(name) : 0); } const XMLConstHandle LastChild() const { - return XMLConstHandle( _node ? _node->LastChild() : 0 ); + return XMLConstHandle(_node ? _node->LastChild() : 0); } - const XMLConstHandle LastChildElement( const char* name = 0 ) const { - return XMLConstHandle( _node ? _node->LastChildElement( name ) : 0 ); + const XMLConstHandle LastChildElement(const char* name = 0) const { + return XMLConstHandle(_node ? _node->LastChildElement(name) : 0); } const XMLConstHandle PreviousSibling() const { - return XMLConstHandle( _node ? _node->PreviousSibling() : 0 ); + return XMLConstHandle(_node ? _node->PreviousSibling() : 0); } - const XMLConstHandle PreviousSiblingElement( const char* name = 0 ) const { - return XMLConstHandle( _node ? _node->PreviousSiblingElement( name ) : 0 ); + const XMLConstHandle PreviousSiblingElement(const char* name = 0) const { + return XMLConstHandle(_node ? _node->PreviousSiblingElement(name) : 0); } const XMLConstHandle NextSibling() const { - return XMLConstHandle( _node ? _node->NextSibling() : 0 ); + return XMLConstHandle(_node ? _node->NextSibling() : 0); } - const XMLConstHandle NextSiblingElement( const char* name = 0 ) const { - return XMLConstHandle( _node ? _node->NextSiblingElement( name ) : 0 ); + const XMLConstHandle NextSiblingElement(const char* name = 0) const { + return XMLConstHandle(_node ? _node->NextSiblingElement(name) : 0); } @@ -1924,16 +1924,16 @@ public: return _node; } const XMLElement* ToElement() const { - return ( ( _node == 0 ) ? 0 : _node->ToElement() ); + return ((_node == 0) ? 0 : _node->ToElement()); } const XMLText* ToText() const { - return ( ( _node == 0 ) ? 0 : _node->ToText() ); + return ((_node == 0) ? 0 : _node->ToText()); } const XMLUnknown* ToUnknown() const { - return ( ( _node == 0 ) ? 0 : _node->ToUnknown() ); + return ((_node == 0) ? 0 : _node->ToUnknown()); } const XMLDeclaration* ToDeclaration() const { - return ( ( _node == 0 ) ? 0 : _node->ToDeclaration() ); + return ((_node == 0) ? 0 : _node->ToDeclaration()); } private: @@ -1954,16 +1954,16 @@ private: @verbatim XMLPrinter printer; - doc.Print( &printer ); - SomeFunction( printer.CStr() ); + doc.Print(&printer); + SomeFunction(printer.CStr()); @endverbatim Print to a File You provide the file pointer. @verbatim - XMLPrinter printer( fp ); - doc.Print( &printer ); + XMLPrinter printer(fp); + doc.Print(&printer); @endverbatim Print without a XMLDocument @@ -1977,9 +1977,9 @@ private: an XML document. @verbatim - XMLPrinter printer( fp ); - printer.OpenElement( "foo" ); - printer.PushAttribute( "foo", "bar" ); + XMLPrinter printer(fp); + printer.OpenElement("foo"); + printer.PushAttribute("foo", "bar"); printer.CloseElement(); @endverbatim */ @@ -1992,55 +1992,55 @@ public: If 'compact' is set to true, then output is created with only required whitespace and newlines. */ - XMLPrinter( FILE* file=0, bool compact = false, int depth = 0 ); + XMLPrinter(FILE* file=0, bool compact = false, int depth = 0); virtual ~XMLPrinter() {} /** If streaming, write the BOM and declaration. */ - void PushHeader( bool writeBOM, bool writeDeclaration ); + void PushHeader(bool writeBOM, bool writeDeclaration); /** If streaming, start writing an element. The element must be closed with CloseElement() */ - void OpenElement( const char* name, bool compactMode=false ); + void OpenElement(const char* name, bool compactMode=false); /// If streaming, add an attribute to an open element. - void PushAttribute( const char* name, const char* value ); - void PushAttribute( const char* name, int value ); - void PushAttribute( const char* name, unsigned value ); - void PushAttribute( const char* name, bool value ); - void PushAttribute( const char* name, double value ); + void PushAttribute(const char* name, const char* value); + void PushAttribute(const char* name, int value); + void PushAttribute(const char* name, unsigned value); + void PushAttribute(const char* name, bool value); + void PushAttribute(const char* name, double value); /// If streaming, close the Element. - virtual void CloseElement( bool compactMode=false ); + virtual void CloseElement(bool compactMode=false); /// Add a text node. - void PushText( const char* text, bool cdata=false ); + void PushText(const char* text, bool cdata=false); /// Add a text node from an integer. - void PushText( int value ); + void PushText(int value); /// Add a text node from an unsigned. - void PushText( unsigned value ); + void PushText(unsigned value); /// Add a text node from a bool. - void PushText( bool value ); + void PushText(bool value); /// Add a text node from a float. - void PushText( float value ); + void PushText(float value); /// Add a text node from a double. - void PushText( double value ); + void PushText(double value); /// Add a comment - void PushComment( const char* comment ); + void PushComment(const char* comment); - void PushDeclaration( const char* value ); - void PushUnknown( const char* value ); + void PushDeclaration(const char* value); + void PushUnknown(const char* value); - virtual bool VisitEnter( const XMLDocument& /*doc*/ ); - virtual bool VisitExit( const XMLDocument& /*doc*/ ) { + virtual bool VisitEnter(const XMLDocument& /*doc*/); + virtual bool VisitExit(const XMLDocument& /*doc*/) { return true; } - virtual bool VisitEnter( const XMLElement& element, const XMLAttribute* attribute ); - virtual bool VisitExit( const XMLElement& element ); + virtual bool VisitEnter(const XMLElement& element, const XMLAttribute* attribute); + virtual bool VisitExit(const XMLElement& element); - virtual bool Visit( const XMLText& text ); - virtual bool Visit( const XMLComment& comment ); - virtual bool Visit( const XMLDeclaration& declaration ); - virtual bool Visit( const XMLUnknown& unknown ); + virtual bool Visit(const XMLText& text); + virtual bool Visit(const XMLComment& comment); + virtual bool Visit(const XMLDeclaration& declaration); + virtual bool Visit(const XMLUnknown& unknown); /** If in print to memory mode, return a pointer to @@ -2067,20 +2067,20 @@ public: } protected: - virtual bool CompactMode( const XMLElement& ) { return _compactMode; } + virtual bool CompactMode(const XMLElement&) { return _compactMode; } /** Prints out the space before an element. You may override to change the space and tabs used. A PrintSpace() override should call Print(). */ - virtual void PrintSpace( int depth ); - void Print( const char* format, ... ); + virtual void PrintSpace(int depth); + void Print(const char* format, ...); void SealElementIfJustOpened(); bool _elementJustOpened; DynArray< const char*, 10 > _stack; private: - void PrintString( const char*, bool restrictedEntitySet ); // prints out, after detecting entities. + void PrintString(const char*, bool restrictedEntitySet); // prints out, after detecting entities. bool _firstElement; FILE* _fp; diff --git a/include/ui.hpp b/include/ui.hpp index 6fa2451..5281d31 100644 --- a/include/ui.hpp +++ b/include/ui.hpp @@ -115,10 +115,10 @@ namespace ui { void closeBox(); void waitForDialog(void); - bool pageExists( void ); - void drawPage( std::string path ); + bool pageExists(void); + void drawPage(std::string path); - void dontTypeOut( void ); + void dontTypeOut(void); /* * Draws a larger string in the center of the screen. Drawing is done inside this function. */ @@ -133,7 +133,7 @@ namespace ui { void draw(void); void quitGame(); - + /* diff --git a/include/ui_menu.hpp b/include/ui_menu.hpp index 9a51739..bfeecba 100644 --- a/include/ui_menu.hpp +++ b/include/ui_menu.hpp @@ -56,7 +56,7 @@ namespace ui { menuItem createParentButton(vec2 l, dim2 d, Color c, const char* t); menuItem createSlider(vec2 l, dim2 d, Color c, float min, float max, const char* t, float* v); - void draw( void ); + void draw(void); } } diff --git a/include/world.hpp b/include/world.hpp index cae3808..bee2bcf 100644 --- a/include/world.hpp +++ b/include/world.hpp @@ -14,7 +14,6 @@ #define GROUND_HEIGHT_INITIAL 80 #define GROUND_HEIGHT_MINIMUM 60 #define GROUND_HEIGHT_MAXIMUM 110 - #define GROUND_HILLINESS 10 #define PLAYER_SPEED_CONSTANT 0.15f @@ -175,7 +174,7 @@ protected: * World::detect(), which is why it is declared private. */ - virtual void singleDetect( Entity *e ); + virtual void singleDetect(Entity *e); /** * Empties all entity vectors. @@ -187,7 +186,7 @@ protected: * call this function. */ - void deleteEntities( void ); + void deleteEntities(void); /** * Number of lines in the world. @@ -232,8 +231,6 @@ protected: std::vector bgFiles; std::vector bgFilesIndoors; -public: - /** * The filename of the XML file for the world to the left; NULL if no world * is present. @@ -249,16 +246,34 @@ public: std::string toRight; /** - * Sets what XML file to use for loading the world to the left. + * Vector of all building textures for the current world style */ - std::string setToLeft( std::string file ); + std::vector sTexLoc; + + std::vector light; + std::vector village; + std::vector particles; + std::vector object; + std::vector mob; + +public: + + Light *getLastLight(void); + Mob *getLastMob(void); + + std::string getSTextureLocation(unsigned int index) const; /** - * Sets what XML file to use for loading the world to the right. + * These handle accessing/modifying pathnames for worlds linked to the left + * and right of this one. */ - std::string setToRight( std::string file ); + std::string setToLeft(std::string file); + std::string setToRight(std::string file); + + std::string getToLeft(void) const; + std::string getToRight(void) const; /** * A vector of pointers to every NPC, Structure, Mob, and Object in this @@ -280,46 +295,13 @@ public: std::vector build; - /** - * A vector of all Mobs in this world. - */ - - std::vector mob; - - /** - * A vector of all Objects in this world. - */ - - std::vector object; - - /** - * A vector of all particles in this world. - */ - - std::vector particles; - - - std::vector village; - - /** - * A vector of all light elements in this world. - */ - - std::vector light; - - /** - * Vector of all building textures for the current world style - */ - - std::vector sTexLoc; - /** * NULLifies pointers and allocates necessary memory. This should be * followed by some combination of setBackground(), setBGM(), or * generate(). */ - World( void ); + World(void); /** * Frees resources taken by the world. @@ -335,6 +317,7 @@ public: */ void addStructure(BUILD_SUB subtype,float x,float y, std::string tex, std::string inside); + Village *addVillage(std::string name, World *world); /** * Adds a Mob to the world with the specified type and coordinates. @@ -367,7 +350,7 @@ public: * upon object interaction. */ - void addObject( std::string in, std::string pickupDialog, float x, float y); + void addObject(std::string in, std::string pickupDialog, float x, float y); /** * Adds a particle to the world with the specified coordinates, dimensions, @@ -375,7 +358,7 @@ public: */ void addParticle(float x, float y, float w, float h, float vx, float vy, Color color, int d); - void addParticle(float x, float y, float w, float h, float vx, float vy, Color color, int d, bool gravity ); + void addParticle(float x, float y, float w, float h, float vx, float vy, Color color, int d, unsigned char flags); /** * Adds a light to the world with the specified coordinates and color. @@ -388,7 +371,7 @@ public: * and a velocity. The provided delta time is used for smoother updating. */ - void update( Player *p, unsigned int delta ); + void update(Player *p, unsigned int delta); /** * Generate a world of the provided width. Worlds are drawn centered on the @@ -445,7 +428,7 @@ public: */ World *goWorldLeft(Player *p); - bool goWorldLeft( NPC *e ); + bool goWorldLeft(NPC *e); /** * Attempts to let the player enter the right-linked world specified by @@ -475,7 +458,7 @@ public: * hill can be. */ - void addHill( ivec2 peak, unsigned int width ); + void addHill(ivec2 peak, unsigned int width); /** * Gets the world's width. @@ -497,18 +480,18 @@ private: std::vector> floor; std::vector fstart; - void singleDetect( Entity *e ); + void singleDetect(Entity *e); public: IndoorWorld(void); ~IndoorWorld(void); - void addFloor( unsigned int width ); - void addFloor( unsigned int width, unsigned int start ); - bool moveToFloor( Entity *e, unsigned int _floor ); + void addFloor(unsigned int width); + void addFloor(unsigned int width, unsigned int start); + bool moveToFloor(Entity *e, unsigned int _floor); - bool isFloorAbove( Entity *e ); - bool isFloorBelow( Entity *e ); + bool isFloorAbove(Entity *e); + bool isFloorBelow(Entity *e); void draw(Player *p); // Draws the world (ignores layers) }; @@ -537,26 +520,26 @@ public: * world `leave` upon exit. */ - Arena( World *leave, Player *p, Mob *m ); + Arena(World *leave, Player *p, Mob *m); /** * Frees resources taken by the arena. */ - ~Arena( void ); + ~Arena(void); /** * Attempts to exit the world, returning the player to the world they were * last in. */ - World *exitArena( Player *p ); + World *exitArena(Player *p); }; -bool isCurrentWorldIndoors( void ); -float getIndoorWorldFloorHeight( void ); +bool isCurrentWorldIndoors(void); +float getIndoorWorldFloorHeight(void); -std::string getWorldWeatherStr( WorldWeather ww ); +std::string getWorldWeatherStr(WorldWeather ww); /** * Loads the player into the world created by the given XML file. If a world is @@ -572,6 +555,6 @@ World *loadWorldFromXML(std::string path); World *loadWorldFromXMLNoSave(std::string path); -World *loadWorldFromPtr( World *ptr ); +World *loadWorldFromPtr(World *ptr); #endif // WORLD_H diff --git a/main.cpp b/main.cpp index 837c785..2be34ca 100644 --- a/main.cpp +++ b/main.cpp @@ -231,7 +231,7 @@ int main(int argc, char *argv[]){ * (Attempt to) Initialize SDL_mixer libraries for loading and playing music/sound files. */ - if(Mix_OpenAudio( 44100, MIX_DEFAULT_FORMAT, 2, 2048) < 0){ + if(Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048) < 0){ std::cout << "SDL_mixer could not initialize! Error: " << Mix_GetError() << std::endl; return -1; } @@ -268,7 +268,7 @@ int main(int argc, char *argv[]){ SCREEN_WIDTH, SCREEN_HEIGHT, SDL_CreateWindowFlags - ); + ); /* * Exit if the window cannot be created @@ -356,7 +356,7 @@ int main(int argc, char *argv[]){ glGetShaderInfoLog(fragShader, logLength, NULL, &fragShaderError[0]); std::cout << &fragShaderError[0] << std::endl; - if ( bufferln == GL_FALSE ) + if (bufferln == GL_FALSE) UserError("Error compiling shader"); shaderProgram = glCreateProgram(); @@ -366,7 +366,7 @@ int main(int argc, char *argv[]){ glGetProgramiv(shaderProgram, GL_LINK_STATUS, &bufferln); glGetProgramiv(shaderProgram, GL_INFO_LOG_LENGTH, &logLength); - std::vector programError( (logLength > 1) ? logLength : 1 ); + std::vector programError((logLength > 1) ? logLength : 1); glGetProgramInfoLog(shaderProgram, logLength, NULL, &programError[0]); std::cout << &programError[0] << std::endl; @@ -412,7 +412,7 @@ int main(int argc, char *argv[]){ glClearColor(1,1,1,1); gameRunning = true; - while ( gameRunning ) + while (gameRunning) mainLoop(); /************************** @@ -468,7 +468,7 @@ void mainLoop(void){ deltaTime = currentTime - prevTime; prevTime = currentTime; - if ( currentMenu ) + if (currentMenu) goto MENU; /* @@ -497,19 +497,19 @@ void mainLoop(void){ /*pool.Enqueue([](){ currentWorld->update(player,deltaTime); });*/ - currentWorld->update( player, deltaTime ); + currentWorld->update(player, deltaTime); currentWorld->detect(player); /* * Update debug variables if necessary */ - if ( ++debugDiv == 20 ) { + if (++debugDiv == 20) { debugDiv=0; - if ( deltaTime ) + if (deltaTime) fps = 1000 / deltaTime; - if ( !(debugDiv % 10) ) + if (!(debugDiv % 10)) debugY = player->loc.y; } MENU: @@ -600,7 +600,7 @@ void render() { * GL_COLOR_BUFFER_BIT allows the matrices to have color on them */ - glPushAttrib( GL_DEPTH_BUFFER_BIT); + glPushAttrib(GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /************************** @@ -680,10 +680,10 @@ void render() { tickCount, handAngle, VOLUME_MASTER, - getWorldWeatherStr( weather ).c_str() + getWorldWeatherStr(weather).c_str() ); - if ( ui::posFlag ) { + if (ui::posFlag) { glBegin(GL_LINES); /*glColor3ub(255,0,0); glVertex2i(0,0); @@ -692,16 +692,16 @@ void render() { /*glColor3ub(255,255,255); glVertex2i(player->loc.x + player->width/2,0); glVertex2i(player->loc.x + player->width/2,SCREEN_HEIGHT); - glVertex2i( offset.x - SCREEN_WIDTH / 2, player->loc.y + player->height / 2 ); - glVertex2i( offset.x + SCREEN_WIDTH / 2, player->loc.y + player->height / 2 );*/ + glVertex2i(offset.x - SCREEN_WIDTH / 2, player->loc.y + player->height / 2); + glVertex2i(offset.x + SCREEN_WIDTH / 2, player->loc.y + player->height / 2);*/ - /*glVertex2i( -SCREEN_WIDTH / 2 + offset.x, player->loc.y ); - glVertex2i( SCREEN_WIDTH / 2 + offset.x, player->loc.y );*/ + /*glVertex2i(-SCREEN_WIDTH / 2 + offset.x, player->loc.y); + glVertex2i( SCREEN_WIDTH / 2 + offset.x, player->loc.y);*/ glColor3ub(100,100,255); - for ( auto &e : currentWorld->entity ) { - glVertex2i( player->loc.x + player->width / 2, player->loc.y + player->height / 2 ); - glVertex2i( e->loc.x + e->width / 2, e->loc.y + e->height / 2 ); + for (auto &e : currentWorld->entity) { + glVertex2i(player->loc.x + player->width / 2, player->loc.y + player->height / 2); + glVertex2i(e->loc.x + e->width / 2, e->loc.y + e->height / 2); } glEnd(); @@ -709,7 +709,7 @@ void render() { } - if ( currentMenu ) + if (currentMenu) ui::menu::draw(); // draw the mouse cursor @@ -732,21 +732,20 @@ void render() { SDL_GL_SwapWindow(window); } -static bool objectInteracting = false; - void logic(){ - static bool NPCSelected = false; + static bool NPCSelected = false; + static bool ObjectSelected = false; // exit the game if the player falls out of the world - if ( player->loc.y < 0 ) + if (player->loc.y < 0) gameRunning = false; - if ( player->inv->usingi ) { - for ( auto &e : currentWorld->entity ) { + if (player->inv->usingi) { + for (auto &e : currentWorld->entity) { e->hit = false; - if ( player->inv->usingi && !e->hit && - player->inv->detectCollision( { e->loc.x, e->loc.y }, { e->loc.x + e->width, e->loc.y + e->height} ) ) { + if (player->inv->usingi && !e->hit && + player->inv->detectCollision({ e->loc.x, e->loc.y }, { e->loc.x + e->width, e->loc.y + e->height})) { e->health -= 25; e->hit = true; e->forcedMove = true; @@ -756,7 +755,7 @@ void logic(){ break; //for(int r = 0; r < (rand()%5);r++) // currentWorld->addParticle(rand()%HLINE*3 + n->loc.x - .05f,n->loc.y + n->height*.5, HLINE,HLINE, -(rand()%10)*.01,((rand()%4)*.001-.002), {(rand()%75+10)/100.0f,0,0}, 10000); - //if ( e->health <= 0 ) { + //if (e->health <= 0) { //for(int r = 0; r < (rand()%30)+15;r++) // currentWorld->addParticle(rand()%HLINE*3 + n->loc.x - .05f,n->loc.y + n->height*.5, HLINE,HLINE, -(rand()%10)*.01,((rand()%10)*.01-.05), {(rand()%75)+10/100.0f,0,0}, 10000); } @@ -764,126 +763,49 @@ void logic(){ player->inv->usingi = false; } - /* - * Entity logic: This loop finds every entity that is alive and in the current world. It then - * basically runs their AI functions depending on what type of entity they are. For NPCs, - * click detection is done as well for NPC/player interaction. - */ - - for(auto &n : currentWorld->npc){ - if(n->alive){ - - /* - * Make the NPC 'wander' about the world if they're allowed to do so. - * Entity->canMove is modified when a player interacts with an NPC so - * that the NPC doesn't move when it talks to the player. - */ - - if(n->canMove) - n->wander((rand() % 120 + 30)); - - /* - * Don't bother handling the NPC if another has already been handled. - */ - - if(NPCSelected){ - n->near=false; - break; - } - - /* - * Check if the NPC is under the mouse. - */ - - if(ui::mouse.x >= n->loc.x && - ui::mouse.x <= n->loc.x + n->width && - ui::mouse.y >= n->loc.y && - ui::mouse.y <= n->loc.y + n->width ){ - - /* - * Check of the NPC is close enough to the player for interaction to be - * considered legal. In other words, require the player to be close to - * the NPC in order to interact with it. - * - * This uses the Pythagorean theorem to check for NPCs within a certain - */ - - if(pow((n->loc.x - player->loc.x),2) + pow((n->loc.y - player->loc.y),2) <= pow(40*HLINE,2)){ - - /* - * Set Entity->near so that this NPC's name is drawn under them, and toggle NPCSelected - * so this NPC is the only one that's clickable. - */ - - n->near=true; - NPCSelected=true; - - /* - * Check for a right click, and allow the NPC to interact with the - * player if one was made. - */ - - if(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_RIGHT)){ - - if(!ui::dialogBoxExists) - n->interact(); - + for (auto &e : currentWorld->entity) { + if (e->alive) { + if (e->type == NPCT || e->type == MERCHT || e->type == OBJECTT) { + + if (e->type == OBJECTT && ObjectSelected) { + e->near = false; + continue; + } else { // has to be NPC + if (e->canMove) { + e->wander((rand() % 120 + 30)); + if (NPCSelected) { + e->near = false; + continue; + } } } - /* - * Hide the NPC's name if the mouse isn't on the NPC. - */ - - }else n->near=false; - } - } - - for(auto &m : currentWorld->mob){ - if(m->alive){ - - /* - * Run the Mob's AI function. - */ - - switch(m->subtype){ - case MS_RABBIT: - case MS_BIRD: - m->wander((rand()%240 + 15)); // Make the mob wander - break; - case MS_TRIGGER: - case MS_PAGE: - m->wander(0); - break; - case MS_DOOR: - break; - default: - std::cout<<"Unhandled mob of subtype "<subtype<<"."<object){ - if(o->alive){ - if(ui::mouse.x >= o->loc.x && - ui::mouse.x <= o->loc.x + o->width && - ui::mouse.y >= o->loc.y && - ui::mouse.y <= o->loc.y + o->height ){ - if(pow((o->loc.x - player->loc.x),2) + pow((o->loc.y - player->loc.y),2) <= pow(40*HLINE,2)){ - - /* - * Check for a right click, and allow the Object to interact with the - * player if one was made. - */ - - if(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_RIGHT)){ - objectInteracting=true; - o->interact(); - objectInteracting=false; - } - } + if(e->isInside(ui::mouse) && player->isNear(*e)) { + if (e->type == OBJECTT) + ObjectSelected = true; + else + NPCSelected = true; + e->near = true; + + if ((SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_RIGHT)) && !ui::dialogBoxExists) + e->interact(); + } else + e->near = false; + } else if (e->type == MOBT) { + switch (e->subtype) { + case MS_RABBIT: + case MS_BIRD: + e->wander((rand()%240 + 15)); + break; + case MS_TRIGGER: + case MS_PAGE: + e->wander(0); + break; + case MS_DOOR: + break; + default: + std::cout<<"Unhandled mob of subtype "<subtype<<"."<addParticle(randGet() % currentWorld->getTheWidth() - (currentWorld->getTheWidth() / 2), offset.y + SCREEN_HEIGHT / 2, HLINE * 1.25, // width @@ -935,12 +857,12 @@ void logic(){ randGet() % 7 * .01 * (randGet() % 2 == 0 ? -1 : 1), // vel.x (4 + randGet() % 6) * .05, // vel.y { 0, 0, 255 }, // RGB color - 2500 // duration (ms) - ); - currentWorld->particles.back().bounce = true; + 2500, // duration (ms) + (1 << 0) | (1 << 1) // gravity and bounce + ); } - } else if ( weather == WorldWeather::Snowy ) { - for ( unsigned int r = (randGet() % 25) + 11; r--; ) { + } else if (weather == WorldWeather::Snowy) { + for (unsigned int r = (randGet() % 25) + 11; r--;) { currentWorld->addParticle(randGet() % currentWorld->getTheWidth() - (currentWorld->getTheWidth() / 2), offset.y + SCREEN_HEIGHT / 2, HLINE * 1.25, // width @@ -949,8 +871,8 @@ void logic(){ (4 + randGet() % 6) * -.03, // vel.y { 255, 255, 255 }, // RGB color 5000, // duration (ms) - false - ); + 0 // no gravity, no bounce + ); } } diff --git a/setup.mk b/setup.mk index 564fa24..89bb9c3 100644 --- a/setup.mk +++ b/setup.mk @@ -2,4 +2,4 @@ TARGET_OS = linux # Bits setting, 32 or 64 -TARGET_BITS = 64 +TARGET_BITS = 32 diff --git a/src/common.cpp b/src/common.cpp index b4258f6..8f59fba 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -81,7 +81,7 @@ const char *readFile(const char *path){ unsigned int size; GLchar *buf; - if ( !in.is_open() ) + if (!in.is_open()) UserError("Error reading file " + (std::string)path + "!"); in.seekg(0,in.end); @@ -95,7 +95,7 @@ const char *readFile(const char *path){ } void -UserError( std::string reason ) +UserError(std::string reason) { std::cout << "User error: " << reason << "!" << std::endl; abort(); diff --git a/src/config.cpp b/src/config.cpp index b8a483d..a2acc03 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -21,7 +21,7 @@ XMLElement *vol; namespace config { - void read( void ) { + void read(void) { unsigned int uval; float fval; bool bval; @@ -61,19 +61,19 @@ namespace config { ui::initFonts(); ui::setFontFace(xml.FirstChildElement("font")->Attribute("path")); - if ( xml.FirstChildElement("debug") ) + if (xml.FirstChildElement("debug")) ui::debug = ui::posFlag = true; config::update(); } - void update( void ) { + void update(void) { Mix_Volume(0,VOLUME_MASTER); Mix_Volume(1,VOLUME_SFX * (VOLUME_MASTER/100.0f)); Mix_VolumeMusic(VOLUME_MUSIC * (VOLUME_MASTER/100.0f)); } - void save( void ) { + void save(void) { vol->FirstChildElement("master")->SetAttribute("volume",VOLUME_MASTER); vol->FirstChildElement("music")->SetAttribute("volume",VOLUME_MUSIC); vol->FirstChildElement("sfx")->SetAttribute("volume", VOLUME_SFX); diff --git a/src/entities.cpp b/src/entities.cpp index df32a5b..02be6fe 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -71,7 +71,7 @@ void getRandomName(Entity *e){ break; } - strcpy( e->name, bufs + 1 ); + strcpy(e->name, bufs + 1); delete[] bufs; } @@ -315,11 +315,15 @@ void Object::reloadTexture(void){ height = getItemHeight(iname); } +bool Entity::isNear(Entity e){ + return pow(e.loc.x - loc.x, 2) + pow(e.loc.y - loc.y, 2) <= pow(40 * HLINE, 2); +} + void Entity::draw(void){ //draws the entities glPushMatrix(); glColor3ub(255,255,255); - if ( !alive ) + if (!alive) return; if(type==NPCT){ @@ -392,7 +396,7 @@ void Entity::draw(void){ //draws the entities break; } - if ( hitCooldown ) + if (hitCooldown) glColor3ub(255,255,0); else glColor3ub(255,255,255); @@ -410,11 +414,11 @@ NOPE: glDisable(GL_TEXTURE_2D); glMatrixMode(GL_MODELVIEW); glPopMatrix(); - if ( near ) + if (near) ui::putStringCentered(loc.x+width/2,loc.y-ui::fontSize-HLINE/2,name); - if ( health != maxHealth ) { - glColor3ub(150,0,0); glRectf( loc.x, loc.y + height, loc.x + width, loc.y + height + HLINE * 2 ); - glColor3ub(255,0,0); glRectf( loc.x, loc.y + height, loc.x + width * ( health / maxHealth ), loc.y + height + HLINE * 2 ); + if (health != maxHealth) { + glColor3ub(150,0,0); glRectf(loc.x, loc.y + height, loc.x + width, loc.y + height + HLINE * 2); + glColor3ub(255,0,0); glRectf(loc.x, loc.y + height, loc.x + width * (health / maxHealth), loc.y + height + HLINE * 2); } } @@ -423,46 +427,46 @@ NOPE: */ void NPC:: -wander( int timeRun ) +wander(int timeRun) { static int direction; - if ( forcedMove ) + if (forcedMove) return; - if ( hitCooldown ) + if (hitCooldown) hitCooldown--; - if ( followee ) { - if ( loc.x < followee->loc.x - 40 ) + if (followee) { + if (loc.x < followee->loc.x - 40) direction = 1; - else if ( loc.x > followee->loc.x + 40 ) + else if (loc.x > followee->loc.x + 40) direction = -1; else direction = 0; vel.x = .018 * HLINE * direction; - } else if ( targetx != 0.9112001f ) { - if ( loc.x > targetx + HLINE * 5) + } else if (targetx != 0.9112001f) { + if (loc.x > targetx + HLINE * 5) vel.x = -0.018 * HLINE; - else if ( loc.x < targetx - HLINE * 5) + else if (loc.x < targetx - HLINE * 5) vel.x = 0.018 * HLINE; else targetx = 0.9112001f; - } else if ( ticksToUse == 0 ) { + } else if (ticksToUse == 0) { ticksToUse = timeRun; vel.x = .008 * HLINE; direction = (getRand() % 3 - 1); - if ( direction == 0 ) + if (direction == 0) ticksToUse *= 2; vel.x *= direction; } - if( vel.x < 0) - currentWorld->goWorldLeft( this ); + if(vel.x < 0) + currentWorld->goWorldLeft(this); ticksToUse--; } @@ -506,29 +510,29 @@ void NPC::interact(){ //have the npc's interact back to the player void Merchant::wander(int timeRun){ static int direction; - if ( forcedMove ) + if (forcedMove) return; - if ( ticksToUse == 0 ) { + if (ticksToUse == 0) { ticksToUse = timeRun; vel.x = .008 * HLINE; direction = (getRand() % 3 - 1); - if ( direction == 0 ) + if (direction == 0) ticksToUse *= 2; vel.x *= direction; } - if( vel.x < 0) - currentWorld->goWorldLeft( this ); - if ( inside != nullptr ) { + if(vel.x < 0) + currentWorld->goWorldLeft(this); + if (inside != nullptr) { loc.y = inside->loc.y + HLINE * 2; vel.y = GRAVITY_CONSTANT * 5; - if ( loc.x <= inside->loc.x + HLINE * 5 ) + if (loc.x <= inside->loc.x + HLINE * 5) loc.x = inside->loc.x + HLINE * 5; - else if ( loc.x + width >= inside->loc.x + inside->width - HLINE * 5 ) + else if (loc.x + width >= inside->loc.x + inside->width - HLINE * 5) loc.x = inside->loc.x + inside->width - width - HLINE * 5; } ticksToUse--; @@ -540,10 +544,10 @@ void Merchant::interact(){ ui::waitForDialog(); // handle normal dialog options - switch ( ui::dialogOptChosen ) { + switch (ui::dialogOptChosen) { // Accept case 1: - if ( !(player->inv->takeItem( trade[currTrade].item[1], trade[currTrade].quantity[1])) ) + if (!(player->inv->takeItem(trade[currTrade].item[1], trade[currTrade].quantity[1]))) player->inv->addItem(trade[currTrade].item[0],trade[currTrade].quantity[0]); break; @@ -556,10 +560,10 @@ void Merchant::interact(){ } // handle merchant-specific dialog options - switch ( ui::merchOptChosen ) { + switch (ui::merchOptChosen) { // left arrow case 1: - if ( currTrade ) + if (currTrade) currTrade--; ui::dontTypeOut(); interact(); // TODO should we nest like this? @@ -567,7 +571,7 @@ void Merchant::interact(){ // right arrow case 2: - if ( currTrade < trade.size() - 1 ) + if (currTrade < trade.size() - 1) currTrade++; ui::dontTypeOut(); interact(); @@ -582,10 +586,10 @@ void Merchant::interact(){ void Object::interact(void){ std::thread([this]{ if(questObject && alive){ - ui::dialogBox( player->name, ":Yes:No", false, pickupDialog.c_str()); + ui::dialogBox(player->name, ":Yes:No", false, pickupDialog.c_str()); ui::waitForDialog(); if(ui::dialogOptChosen == 1){ - player->inv->addItem( iname, 1 ); + player->inv->addItem(iname, 1); alive = false; } }else{ @@ -595,9 +599,14 @@ void Object::interact(void){ }).detach(); } -void Entity:: -follow( Entity *e ) -{ +bool Entity::isInside(vec2 coord) const { + return coord.x >= loc.x && + coord.x <= loc.x + width && + coord.y >= loc.y && + coord.y <= loc.y + height; +} + +void Entity::follow(Entity *e){ followee = e; } @@ -630,19 +639,19 @@ unsigned int Structures::spawn(BUILD_SUB sub, float x, float y){ //unsigned int tempN = (getRand() % 5 + 2); - if ( textureLoc.empty() ) - textureLoc = inWorld->sTexLoc[sub]; + if (textureLoc.empty()) + textureLoc = inWorld->getSTextureLocation(sub); switch(sub){ case STALL_MARKET: tex = new Texturec({ textureLoc }); - dim = Texture::imageDim( textureLoc ); + dim = Texture::imageDim(textureLoc); width = dim.x; height = dim.y; break; default: tex = new Texturec({ textureLoc }); - dim = Texture::imageDim( textureLoc ); + dim = Texture::imageDim(textureLoc); width = dim.x; height = dim.y; inv = NULL; @@ -663,13 +672,13 @@ void Mob::wander(int timeRun){ static unsigned int heya=0,hi=0; static bool YAYA = false; - if ( forcedMove ) + if (forcedMove) return; - if ( followee ) { - if ( loc.x < followee->loc.x - 40 ) + if (followee) { + if (loc.x < followee->loc.x - 40) direction = 1; - else if ( loc.x > followee->loc.x + 40 ) + else if (loc.x > followee->loc.x + 40) direction = -1; else direction = 0; @@ -680,11 +689,11 @@ void Mob::wander(int timeRun){ if(aggressive && !YAYA && player->loc.x + (width / 2) > loc.x && player->loc.x + (width / 2) < loc.x + width && - player->loc.y + (height / 3) > loc.y && player->loc.y + (height / 3) < loc.y + height ){ - if ( !ui::dialogBoxExists ) { + player->loc.y + (height / 3) > loc.y && player->loc.y + (height / 3) < loc.y + height){ + if (!ui::dialogBoxExists) { Arena *a = new Arena(currentWorld,player,this); a->setStyle(""); - a->setBackground( WorldBGType::Forest ); + a->setBackground(WorldBGType::Forest); a->setBGM("assets/music/embark.wav"); ui::toggleWhiteFast(); @@ -721,7 +730,7 @@ void Mob::wander(int timeRun){ break; case MS_TRIGGER: if(player->loc.x + player->width / 2 > loc.x && - player->loc.x + player->width / 2 < loc.x + width ) + player->loc.x + player->width / 2 < loc.x + width) std::thread([this]{hey(this);}).detach(); //hey(this); break; diff --git a/src/gameplay.cpp b/src/gameplay.cpp index 7b5b3ba..66b7f1d 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -69,10 +69,10 @@ int commonAIFunc(NPC *speaker){ if((oxml = exml->FirstChildElement("quest"))){ std::string qname; - while ( oxml ) { - if ( !(qname = oxml->StrAttribute("assign")).empty() ) + while (oxml) { + if (!(qname = oxml->StrAttribute("assign")).empty()) player->qh.assign(qname,"None",(std::string)oxml->GetText()); - else if( !(qname = oxml->StrAttribute("check")).empty() ){ + else if(!(qname = oxml->StrAttribute("check")).empty()){ if(player->qh.hasQuest(qname) && player->qh.finish(qname)){ goto CONT; }else{ @@ -114,7 +114,7 @@ CONT: * Handle 'go to' thingy */ - if ( (oxml = exml->FirstChildElement("gotox")) ) + if ((oxml = exml->FirstChildElement("gotox"))) speaker->targetx = atoi(oxml->GetText()); /* @@ -218,8 +218,8 @@ CONT: return 0; } -void commonPageFunc( Mob *callee ){ - ui::drawPage( callee->heyid ); +void commonPageFunc(Mob *callee){ + ui::drawPage(callee->heyid); ui::waitForDialog(); callee->health = 0; } @@ -272,7 +272,7 @@ void initEverything(void){ * Read the XML directory into an array. */ - if ( getdir( std::string("./" + xmlFolder).c_str(), xmlFiles ) ) + if (getdir(std::string("./" + xmlFolder).c_str(), xmlFiles)) UserError("Error reading XML files!!!"); /* @@ -312,7 +312,7 @@ void initEverything(void){ optionsMenu.items.push_back(ui::menu::createSlider({-200,000}, {512,50}, {0.0f, 0.0f, 0.0f}, 0, 100, "SFX", &VOLUME_SFX)); optionsMenu.child = NULL; optionsMenu.parent = &pauseMenu; - // optionsMenu.push_back(ui::menu::createButton({-256/2,-200},{256,75},{0.0f,0.0f,0.0f}, (const char*)("Save and Quit"), ); + // optionsMenu.push_back(ui::menu::createButton({-256/2,-200},{256,75},{0.0f,0.0f,0.0f}, (const char*)("Save and Quit"),); /* * Spawn the player and begin the game. diff --git a/src/inventory.cpp b/src/inventory.cpp index 64254e9..1b2d378 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -49,7 +49,7 @@ int Inventory::addItem(std::string name,uint count){ return 0; } } - items.push_back( item_t { count, i }); + items.push_back(item_t { count, i }); return 0; } } @@ -145,11 +145,11 @@ const char *getItemTexturePath(std::string name){ } GLuint getItemTexture(std::string name){ - for ( int i = itemMap.size(); i--; ) { - if ( itemMap[i]->name == name ) + for (int i = itemMap.size(); i--;) { + if (itemMap[i]->name == name) return itemtex[i]; } - DEBUG_printf("Failed to find texture for item %s!", name.c_str() ); + DEBUG_printf("Failed to find texture for item %s!", name.c_str()); return 0; } @@ -182,12 +182,12 @@ void Inventory::setSelection(unsigned int s){ } void Inventory::setSelectionUp(){ - if ( !sel-- ) + if (!sel--) sel++; } void Inventory::setSelectionDown(){ - if ( ++sel >= numSlot ) + if (++sel >= numSlot) sel = numSlot - 1; } @@ -215,79 +215,79 @@ void Inventory::draw(void){ static vec2 mouseStart = {0,0}; C("End define"); - for ( auto &r : iray ) { + for (auto &r : iray) { r.start.x = player->loc.x + (player->width / 2); r.start.y = player->loc.y + (player->height / 2); curCoord[a++] = r.start; } a = 0; - for ( auto &cr : curRay ) { + for (auto &cr : curRay) { cr.start.x = (offset.x + SCREEN_WIDTH / 2); cr.start.y = offset.y - (a * itemWide * 1.5f); curCurCoord[a++] = cr.start; } a = 0; - for ( int r = 0; r < 4; r++ ) { - for ( int c = 0; c < 8; c++ ) { - massRay[a ].x = ((offset.x - SCREEN_WIDTH / 2) + itemWide ) + c * itemWide * 1.5f; + for (int r = 0; r < 4; r++) { + for (int c = 0; c < 8; c++) { + massRay[a ].x = ((offset.x - SCREEN_WIDTH / 2) + itemWide) + c * itemWide * 1.5f; massRay[a++].y = ((offset.y + SCREEN_HEIGHT / 2) - itemWide * 1.5f) - r * itemWide * 1.5f; } } a = 0; ui::fontTransInv = 255 * (averagef(dfp) / range); - if ( ui::fontTransInv > 255 ) + if (ui::fontTransInv > 255) ui::fontTransInv = 255; - else if ( ui::fontTransInv < 0 ) + else if (ui::fontTransInv < 0) ui::fontTransInv = 0; - if ( invOpening ) { - for ( auto &d : dfp ) { - if ( !a || dfp[a - 1] > 50 ) + if (invOpening) { + for (auto &d : dfp) { + if (!a || dfp[a - 1] > 50) d += 1.65f * deltaTime; - if ( d > range ) + if (d > range) d = range; a++; } a = 0; - for ( auto &cd : curdfp ) { - if ( !a || curdfp[a - 1] > 90 ) + for (auto &cd : curdfp) { + if (!a || curdfp[a - 1] > 90) cd += 1.5f * deltaTime; - if ( cd > curRange ) + if (cd > curRange) cd = curRange; a++; } a = 0; - while ( ++a < massOrder.size() ) { - if ( !a || massDfp[ massOrder[a - 1] ] > massRange * 0.75f ) + while (++a < massOrder.size()) { + if (!a || massDfp[ massOrder[a - 1] ] > massRange * 0.75f) massDfp[ massOrder[a] ] += 5.0f * deltaTime; - if ( massDfp[ massOrder[a] ] > massRange ) + if (massDfp[ massOrder[a] ] > massRange) massDfp[ massOrder[a] ] = massRange; } a = 0; - if ( numSlot > 0 ) + if (numSlot > 0) invOpen = true; } else { - for ( auto &d : dfp ) { - if ( d > 0 ) + for (auto &d : dfp) { + if (d > 0) d -= 1.65f * deltaTime; } - for ( auto &cd : curdfp ) { - if ( cd > 0 ) + for (auto &cd : curdfp) { + if (cd > 0) cd -= 1.0f * deltaTime; } a = 0; - while ( ++a < massRay.size() ) { - if ( !a || massDfp[ massOrderClosing[a - 1] ] <= 0 ) + while (++a < massRay.size()) { + if (!a || massDfp[ massOrderClosing[a - 1] ] <= 0) massDfp[ massOrderClosing[a] ] -= 10.0f * deltaTime; - if ( massDfp[ massOrderClosing[a - 1] ] < 0 ) + if (massDfp[ massOrderClosing[a - 1] ] < 0) massDfp[ massOrderClosing[a - 1] ] = 0; } a = 0; - if ( std::all_of( std::begin(massDfp), std::end(massDfp), [](auto d){ return d <= 0; } ) ) { + if (std::all_of(std::begin(massDfp), std::end(massDfp), [](auto d){ return d <= 0; })) { invOpen = false; - for ( auto &md : massDfp ) { - if ( md < 0 ) + for (auto &md : massDfp) { + if (md < 0) md = 0; } } @@ -546,10 +546,10 @@ void itemDraw(Player *p,uint id){ } else hangle = 0; - if ( p->inv->usingi ) + if (p->inv->usingi) inc = 10; - if ( inc ) { + if (inc) { inc--; p->inv->useItem(); } @@ -574,31 +574,31 @@ void itemDraw(Player *p,uint id){ glUseProgram(0); } -int Inventory::useItem( void ) +int Inventory::useItem(void) { static bool up = false; - if ( !invHover ) { - if ( itemMap[items[sel].id]->type == "Sword" ) { - if ( swing ) { + if (!invHover) { + if (itemMap[items[sel].id]->type == "Sword") { + if (swing) { int dir = player->left ? 1 : -1; - if ( hangle == 15 * dir ) { + if (hangle == 15 * dir) { up = true; - Mix_PlayChannel( 2, swordSwing, 0 ); + Mix_PlayChannel(2, swordSwing, 0); } - if ( up ) + if (up) hangle += 0.325f * dir * deltaTime; - if ( !player->left ) { - if ( hangle <= -90 ) + if (!player->left) { + if (hangle <= -90) hangle = -14; - } else if ( hangle >= 90 ) + } else if (hangle >= 90) hangle = 14; } else { swing = true; - Mix_PlayChannel( 2, swordSwing, 0 ); + Mix_PlayChannel(2, swordSwing, 0); } }else if(itemMap[items[sel].id]->type == "Cooked Food"){ player->health += itemMap[items[sel].id]->attribValue; diff --git a/src/quest.cpp b/src/quest.cpp index 4ab827f..afeec6b 100644 --- a/src/quest.cpp +++ b/src/quest.cpp @@ -12,45 +12,45 @@ int QuestHandler::assign(std::string title,std::string desc,std::string req){ tmp.title = title; tmp.desc = desc; - tok = strtok( &req[0], "\n\r\t," ); - tmp.need.emplace_back( "", 0 ); + tok = strtok(&req[0], "\n\r\t,"); + tmp.need.emplace_back("", 0); - while ( tok ) { - if ( !tmp.need.back().first.empty() ) { - tmp.need.back().second = atoi( tok ); - tmp.need.emplace_back( "", 0 ); + while (tok) { + if (!tmp.need.back().first.empty()) { + tmp.need.back().second = atoi(tok); + tmp.need.emplace_back("", 0); } else tmp.need.back().first = tok; - tok = strtok( NULL, "\n\r\t," ); + tok = strtok(NULL, "\n\r\t,"); } tmp.need.pop_back(); - current.push_back( tmp ); + current.push_back(tmp); return 0; } int QuestHandler::drop(std::string title){ - current.erase( std::remove_if( current.begin(), + current.erase(std::remove_if(current.begin(), current.end(), [&](Quest q){ return q.title == title; }), - current.end() ); + current.end()); return 0; } int QuestHandler::finish(std::string t){ - for ( auto c = current.begin(); c != current.end(); c++ ) { - if ( (*c).title == t ) { - for ( auto &n : (*c).need ) { - if ( player->inv->hasItem( n.first ) < n.second ) + for (auto c = current.begin(); c != current.end(); c++) { + if ((*c).title == t) { + for (auto &n : (*c).need) { + if (player->inv->hasItem(n.first) < n.second) return 0; } - for ( auto &n : (*c).need ) - player->inv->takeItem( n.first, n.second ); - current.erase( c ); + for (auto &n : (*c).need) + player->inv->takeItem(n.first, n.second); + current.erase(c); return 1; } } @@ -59,8 +59,8 @@ int QuestHandler::finish(std::string t){ } bool QuestHandler::hasQuest(std::string t){ - for ( auto &c : current ) { - if ( c.title == t ) + for (auto &c : current) { + if (c.title == t) return true; } diff --git a/src/texture.cpp b/src/texture.cpp index 1f8dca3..a61d426 100644 --- a/src/texture.cpp +++ b/src/texture.cpp @@ -78,7 +78,7 @@ namespace Texture{ GL_RGBA, GL_UNSIGNED_BYTE, image->pixels - ); + ); // add texture to LoadedTexture LoadedTexture.push_back(texture_t{fileName,object,{image->w,image->h}}); @@ -171,25 +171,25 @@ Texturec::Texturec(uint amt, ...){ texState = 0; va_start(fNames, amt); for(unsigned int i = 0; i < amt; i++) - image.push_back( Texture::loadTexture(va_arg(fNames, char *)) ); + image.push_back(Texture::loadTexture(va_arg(fNames, char *))); va_end(fNames); } -Texturec::Texturec( std::initializer_list l ) +Texturec::Texturec(std::initializer_list l) { texState = 0; - std::for_each( l.begin(), l.end(), [&](std::string s){ image.push_back( Texture::loadTexture( s ) ); }); + std::for_each(l.begin(), l.end(), [&](std::string s){ image.push_back(Texture::loadTexture(s)); }); } Texturec::Texturec(std::vectorv){ texState = 0; - std::for_each( v.begin(), v.end(), [&](std::string s){ image.push_back( Texture::loadTexture( s ) ); }); + std::for_each(v.begin(), v.end(), [&](std::string s){ image.push_back(Texture::loadTexture(s)); }); } Texturec::Texturec(uint amt,const char **paths){ texState = 0; for(unsigned int i = 0; i < amt; i++) - image.push_back( Texture::loadTexture(paths[i]) ); + image.push_back(Texture::loadTexture(paths[i])); } Texturec::~Texturec(){ diff --git a/src/tinyxml2.cpp b/src/tinyxml2.cpp index 6198418..1388489 100755 --- a/src/tinyxml2.cpp +++ b/src/tinyxml2.cpp @@ -32,7 +32,7 @@ distribution. # include #endif -#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE) +#if defined(_MSC_VER) && (_MSC_VER >= 1400) && (!defined WINCE) // Microsoft Visual Studio, version 2005 and higher. Not WinCE. /*int _snprintf_s( char *buffer, @@ -41,18 +41,18 @@ distribution. const char *format [, argument] ... );*/ - static inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... ) + static inline int TIXML_SNPRINTF(char* buffer, size_t size, const char* format, ...) { va_list va; - va_start( va, format ); - int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va ); - va_end( va ); + va_start(va, format); + int result = vsnprintf_s(buffer, size, _TRUNCATE, format, va); + va_end(va); return result; } - static inline int TIXML_VSNPRINTF( char* buffer, size_t size, const char* format, va_list va ) + static inline int TIXML_VSNPRINTF(char* buffer, size_t size, const char* format, va_list va) { - int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va ); + int result = vsnprintf_s(buffer, size, _TRUNCATE, format, va); return result; } @@ -63,12 +63,12 @@ distribution. #define TIXML_SNPRINTF _snprintf #define TIXML_VSNPRINTF _vsnprintf #define TIXML_SSCANF sscanf - #if (_MSC_VER < 1400 ) && (!defined WINCE) + #if (_MSC_VER < 1400) && (!defined WINCE) // Microsoft Visual Studio 2003 and not WinCE. #define TIXML_VSCPRINTF _vscprintf // VS2003's C runtime has this, but VC6 C runtime or WinCE SDK doesn't have. #else // Microsoft Visual Studio 2003 and earlier or WinCE. - static inline int TIXML_VSCPRINTF( const char* format, va_list va ) + static inline int TIXML_VSCPRINTF(const char* format, va_list va) { int len = 512; for (;;) { @@ -76,25 +76,25 @@ distribution. char* str = new char[len](); const int required = _vsnprintf(str, len, format, va); delete[] str; - if ( required != -1 ) { - TIXMLASSERT( required >= 0 ); + if (required != -1) { + TIXMLASSERT(required >= 0); len = required; break; } } - TIXMLASSERT( len >= 0 ); + TIXMLASSERT(len >= 0); return len; } #endif #else // GCC version 3 and higher - //#warning( "Using sn* functions." ) + //#warning("Using sn* functions.") #define TIXML_SNPRINTF snprintf #define TIXML_VSNPRINTF vsnprintf - static inline int TIXML_VSCPRINTF( const char* format, va_list va ) + static inline int TIXML_VSCPRINTF(const char* format, va_list va) { - int len = vsnprintf( 0, 0, format, va ); - TIXMLASSERT( len >= 0 ); + int len = vsnprintf(0, 0, format, va); + TIXMLASSERT(len >= 0); return len; } #define TIXML_SSCANF sscanf @@ -141,17 +141,17 @@ StrPair::~StrPair() } -void StrPair::TransferTo( StrPair* other ) +void StrPair::TransferTo(StrPair* other) { - if ( this == other ) { + if (this == other) { return; } // This in effect implements the assignment operator by "moving" // ownership (as in auto_ptr). - TIXMLASSERT( other->_flags == 0 ); - TIXMLASSERT( other->_start == 0 ); - TIXMLASSERT( other->_end == 0 ); + TIXMLASSERT(other->_flags == 0); + TIXMLASSERT(other->_start == 0); + TIXMLASSERT(other->_end == 0); other->Reset(); @@ -166,7 +166,7 @@ void StrPair::TransferTo( StrPair* other ) void StrPair::Reset() { - if ( _flags & NEEDS_DELETE ) { + if (_flags & NEEDS_DELETE) { delete [] _start; } _flags = 0; @@ -175,31 +175,31 @@ void StrPair::Reset() } -void StrPair::SetStr( const char* str, int flags ) +void StrPair::SetStr(const char* str, int flags) { - TIXMLASSERT( str ); + TIXMLASSERT(str); Reset(); - size_t len = strlen( str ); - TIXMLASSERT( _start == 0 ); + size_t len = strlen(str); + TIXMLASSERT(_start == 0); _start = new char[ len+1 ]; - memcpy( _start, str, len+1 ); + memcpy(_start, str, len+1); _end = _start + len; _flags = flags | NEEDS_DELETE; } -char* StrPair::ParseText( char* p, const char* endTag, int strFlags ) +char* StrPair::ParseText(char* p, const char* endTag, int strFlags) { - TIXMLASSERT( endTag && *endTag ); + TIXMLASSERT(endTag && *endTag); char* start = p; char endChar = *endTag; - size_t length = strlen( endTag ); + size_t length = strlen(endTag); // Inner loop of text parsing. - while ( *p ) { - if ( *p == endChar && strncmp( p, endTag, length ) == 0 ) { - Set( start, p, strFlags ); + while (*p) { + if (*p == endChar && strncmp(p, endTag, length) == 0) { + Set(start, p, strFlags); return p + length; } ++p; @@ -208,22 +208,22 @@ char* StrPair::ParseText( char* p, const char* endTag, int strFlags ) } -char* StrPair::ParseName( char* p ) +char* StrPair::ParseName(char* p) { - if ( !p || !(*p) ) { + if (!p || !(*p)) { return 0; } - if ( !XMLUtil::IsNameStartChar( *p ) ) { + if (!XMLUtil::IsNameStartChar(*p)) { return 0; } char* const start = p; ++p; - while ( *p && XMLUtil::IsNameChar( *p ) ) { + while (*p && XMLUtil::IsNameChar(*p)) { ++p; } - Set( start, p, 0 ); + Set(start, p, 0); return p; } @@ -231,18 +231,18 @@ char* StrPair::ParseName( char* p ) void StrPair::CollapseWhitespace() { // Adjusting _start would cause undefined behavior on delete[] - TIXMLASSERT( ( _flags & NEEDS_DELETE ) == 0 ); + TIXMLASSERT((_flags & NEEDS_DELETE) == 0); // Trim leading space. - _start = XMLUtil::SkipWhiteSpace( _start ); + _start = XMLUtil::SkipWhiteSpace(_start); - if ( *_start ) { + if (*_start) { char* p = _start; // the read pointer char* q = _start; // the write pointer - while( *p ) { - if ( XMLUtil::IsWhiteSpace( *p )) { - p = XMLUtil::SkipWhiteSpace( p ); - if ( *p == 0 ) { + while(*p) { + if (XMLUtil::IsWhiteSpace(*p)) { + p = XMLUtil::SkipWhiteSpace(p); + if (*p == 0) { break; // don't write to q; this trims the trailing space. } *q = ' '; @@ -259,22 +259,22 @@ void StrPair::CollapseWhitespace() const char* StrPair::GetStr() { - TIXMLASSERT( _start ); - TIXMLASSERT( _end ); - if ( _flags & NEEDS_FLUSH ) { + TIXMLASSERT(_start); + TIXMLASSERT(_end); + if (_flags & NEEDS_FLUSH) { *_end = 0; _flags ^= NEEDS_FLUSH; - if ( _flags ) { + if (_flags) { char* p = _start; // the read pointer char* q = _start; // the write pointer - while( p < _end ) { - if ( (_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == CR ) { + while(p < _end) { + if ((_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == CR) { // CR-LF pair becomes LF // CR alone becomes LF // LF-CR becomes LF - if ( *(p+1) == LF ) { + if (*(p+1) == LF) { p += 2; } else { @@ -282,8 +282,8 @@ const char* StrPair::GetStr() } *q++ = LF; } - else if ( (_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == LF ) { - if ( *(p+1) == CR ) { + else if ((_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == LF) { + if (*(p+1) == CR) { p += 2; } else { @@ -291,36 +291,36 @@ const char* StrPair::GetStr() } *q++ = LF; } - else if ( (_flags & NEEDS_ENTITY_PROCESSING) && *p == '&' ) { + else if ((_flags & NEEDS_ENTITY_PROCESSING) && *p == '&') { // Entities handled by tinyXML2: // - special entities in the entity table [in/out] // - numeric character reference [in] // 中 or 中 - if ( *(p+1) == '#' ) { + if (*(p+1) == '#') { const int buflen = 10; char buf[buflen] = { 0 }; int len = 0; - char* adjusted = const_cast( XMLUtil::GetCharacterRef( p, buf, &len ) ); - if ( adjusted == 0 ) { + char* adjusted = const_cast(XMLUtil::GetCharacterRef(p, buf, &len)); + if (adjusted == 0) { *q = *p; ++p; ++q; } else { - TIXMLASSERT( 0 <= len && len <= buflen ); - TIXMLASSERT( q + len <= adjusted ); + TIXMLASSERT(0 <= len && len <= buflen); + TIXMLASSERT(q + len <= adjusted); p = adjusted; - memcpy( q, buf, len ); + memcpy(q, buf, len); q += len; } } else { bool entityFound = false; - for( int i = 0; i < NUM_ENTITIES; ++i ) { + for(int i = 0; i < NUM_ENTITIES; ++i) { const Entity& entity = entities[i]; - if ( strncmp( p + 1, entity.pattern, entity.length ) == 0 - && *( p + entity.length + 1 ) == ';' ) { + if (strncmp(p + 1, entity.pattern, entity.length) == 0 + && *(p + entity.length + 1) == ';') { // Found an entity - convert. *q = entity.value; ++q; @@ -329,7 +329,7 @@ const char* StrPair::GetStr() break; } } - if ( !entityFound ) { + if (!entityFound) { // fixme: treat as error? ++p; ++q; @@ -346,12 +346,12 @@ const char* StrPair::GetStr() } // The loop below has plenty going on, and this // is a less useful mode. Break it out. - if ( _flags & NEEDS_WHITESPACE_COLLAPSING ) { + if (_flags & NEEDS_WHITESPACE_COLLAPSING) { CollapseWhitespace(); } _flags = (_flags & NEEDS_DELETE); } - TIXMLASSERT( _start ); + TIXMLASSERT(_start); return _start; } @@ -360,25 +360,25 @@ const char* StrPair::GetStr() // --------- XMLUtil ----------- // -const char* XMLUtil::ReadBOM( const char* p, bool* bom ) +const char* XMLUtil::ReadBOM(const char* p, bool* bom) { - TIXMLASSERT( p ); - TIXMLASSERT( bom ); + TIXMLASSERT(p); + TIXMLASSERT(bom); *bom = false; const unsigned char* pu = reinterpret_cast(p); // Check for BOM: - if ( *(pu+0) == TIXML_UTF_LEAD_0 + if (*(pu+0) == TIXML_UTF_LEAD_0 && *(pu+1) == TIXML_UTF_LEAD_1 - && *(pu+2) == TIXML_UTF_LEAD_2 ) { + && *(pu+2) == TIXML_UTF_LEAD_2) { *bom = true; p += 3; } - TIXMLASSERT( p ); + TIXMLASSERT(p); return p; } -void XMLUtil::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ) +void XMLUtil::ConvertUTF32ToUTF8(unsigned long input, char* output, int* length) { const unsigned long BYTE_MASK = 0xBF; const unsigned long BYTE_MARK = 0x80; @@ -387,13 +387,13 @@ void XMLUtil::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length if (input < 0x80) { *length = 1; } - else if ( input < 0x800 ) { + else if (input < 0x800) { *length = 2; } - else if ( input < 0x10000 ) { + else if (input < 0x10000) { *length = 3; } - else if ( input < 0x200000 ) { + else if (input < 0x200000) { *length = 4; } else { @@ -422,61 +422,61 @@ void XMLUtil::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length *output = (char)(input | FIRST_BYTE_MARK[*length]); break; default: - TIXMLASSERT( false ); + TIXMLASSERT(false); } } -const char* XMLUtil::GetCharacterRef( const char* p, char* value, int* length ) +const char* XMLUtil::GetCharacterRef(const char* p, char* value, int* length) { // Presume an entity, and pull it out. *length = 0; - if ( *(p+1) == '#' && *(p+2) ) { + if (*(p+1) == '#' && *(p+2)) { unsigned long ucs = 0; - TIXMLASSERT( sizeof( ucs ) >= 4 ); + TIXMLASSERT(sizeof(ucs) >= 4); ptrdiff_t delta = 0; unsigned mult = 1; static const char SEMICOLON = ';'; - if ( *(p+2) == 'x' ) { + if (*(p+2) == 'x') { // Hexadecimal. const char* q = p+3; - if ( !(*q) ) { + if (!(*q)) { return 0; } - q = strchr( q, SEMICOLON ); + q = strchr(q, SEMICOLON); - if ( !q ) { + if (!q) { return 0; } - TIXMLASSERT( *q == SEMICOLON ); + TIXMLASSERT(*q == SEMICOLON); delta = q-p; --q; - while ( *q != 'x' ) { + while (*q != 'x') { unsigned int digit = 0; - if ( *q >= '0' && *q <= '9' ) { + if (*q >= '0' && *q <= '9') { digit = *q - '0'; } - else if ( *q >= 'a' && *q <= 'f' ) { + else if (*q >= 'a' && *q <= 'f') { digit = *q - 'a' + 10; } - else if ( *q >= 'A' && *q <= 'F' ) { + else if (*q >= 'A' && *q <= 'F') { digit = *q - 'A' + 10; } else { return 0; } - TIXMLASSERT( digit >= 0 && digit < 16); - TIXMLASSERT( digit == 0 || mult <= UINT_MAX / digit ); + TIXMLASSERT(digit >= 0 && digit < 16); + TIXMLASSERT(digit == 0 || mult <= UINT_MAX / digit); const unsigned int digitScaled = mult * digit; - TIXMLASSERT( ucs <= ULONG_MAX - digitScaled ); + TIXMLASSERT(ucs <= ULONG_MAX - digitScaled); ucs += digitScaled; - TIXMLASSERT( mult <= UINT_MAX / 16 ); + TIXMLASSERT(mult <= UINT_MAX / 16); mult *= 16; --q; } @@ -484,106 +484,106 @@ const char* XMLUtil::GetCharacterRef( const char* p, char* value, int* length ) else { // Decimal. const char* q = p+2; - if ( !(*q) ) { + if (!(*q)) { return 0; } - q = strchr( q, SEMICOLON ); + q = strchr(q, SEMICOLON); - if ( !q ) { + if (!q) { return 0; } - TIXMLASSERT( *q == SEMICOLON ); + TIXMLASSERT(*q == SEMICOLON); delta = q-p; --q; - while ( *q != '#' ) { - if ( *q >= '0' && *q <= '9' ) { + while (*q != '#') { + if (*q >= '0' && *q <= '9') { const unsigned int digit = *q - '0'; - TIXMLASSERT( digit >= 0 && digit < 10); - TIXMLASSERT( digit == 0 || mult <= UINT_MAX / digit ); + TIXMLASSERT(digit >= 0 && digit < 10); + TIXMLASSERT(digit == 0 || mult <= UINT_MAX / digit); const unsigned int digitScaled = mult * digit; - TIXMLASSERT( ucs <= ULONG_MAX - digitScaled ); + TIXMLASSERT(ucs <= ULONG_MAX - digitScaled); ucs += digitScaled; } else { return 0; } - TIXMLASSERT( mult <= UINT_MAX / 10 ); + TIXMLASSERT(mult <= UINT_MAX / 10); mult *= 10; --q; } } // convert the UCS to UTF-8 - ConvertUTF32ToUTF8( ucs, value, length ); + ConvertUTF32ToUTF8(ucs, value, length); return p + delta + 1; } return p+1; } -void XMLUtil::ToStr( int v, char* buffer, int bufferSize ) +void XMLUtil::ToStr(int v, char* buffer, int bufferSize) { - TIXML_SNPRINTF( buffer, bufferSize, "%d", v ); + TIXML_SNPRINTF(buffer, bufferSize, "%d", v); } -void XMLUtil::ToStr( unsigned v, char* buffer, int bufferSize ) +void XMLUtil::ToStr(unsigned v, char* buffer, int bufferSize) { - TIXML_SNPRINTF( buffer, bufferSize, "%u", v ); + TIXML_SNPRINTF(buffer, bufferSize, "%u", v); } -void XMLUtil::ToStr( bool v, char* buffer, int bufferSize ) +void XMLUtil::ToStr(bool v, char* buffer, int bufferSize) { - TIXML_SNPRINTF( buffer, bufferSize, "%d", v ? 1 : 0 ); + TIXML_SNPRINTF(buffer, bufferSize, "%d", v ? 1 : 0); } /* ToStr() of a number is a very tricky topic. https://github.com/leethomason/tinyxml2/issues/106 */ -void XMLUtil::ToStr( float v, char* buffer, int bufferSize ) +void XMLUtil::ToStr(float v, char* buffer, int bufferSize) { - TIXML_SNPRINTF( buffer, bufferSize, "%.8g", v ); + TIXML_SNPRINTF(buffer, bufferSize, "%.8g", v); } -void XMLUtil::ToStr( double v, char* buffer, int bufferSize ) +void XMLUtil::ToStr(double v, char* buffer, int bufferSize) { - TIXML_SNPRINTF( buffer, bufferSize, "%.17g", v ); + TIXML_SNPRINTF(buffer, bufferSize, "%.17g", v); } -bool XMLUtil::ToInt( const char* str, int* value ) +bool XMLUtil::ToInt(const char* str, int* value) { - if ( TIXML_SSCANF( str, "%d", value ) == 1 ) { + if (TIXML_SSCANF(str, "%d", value) == 1) { return true; } return false; } -bool XMLUtil::ToUnsigned( const char* str, unsigned *value ) +bool XMLUtil::ToUnsigned(const char* str, unsigned *value) { - if ( TIXML_SSCANF( str, "%u", value ) == 1 ) { + if (TIXML_SSCANF(str, "%u", value) == 1) { return true; } return false; } -bool XMLUtil::ToBool( const char* str, bool* value ) +bool XMLUtil::ToBool(const char* str, bool* value) { int ival = 0; - if ( ToInt( str, &ival )) { + if (ToInt(str, &ival)) { *value = (ival==0) ? false : true; return true; } - if ( StringEqual( str, "true" ) ) { + if (StringEqual(str, "true")) { *value = true; return true; } - else if ( StringEqual( str, "false" ) ) { + else if (StringEqual(str, "false")) { *value = false; return true; } @@ -591,32 +591,32 @@ bool XMLUtil::ToBool( const char* str, bool* value ) } -bool XMLUtil::ToFloat( const char* str, float* value ) +bool XMLUtil::ToFloat(const char* str, float* value) { - if ( TIXML_SSCANF( str, "%f", value ) == 1 ) { + if (TIXML_SSCANF(str, "%f", value) == 1) { return true; } return false; } -bool XMLUtil::ToDouble( const char* str, double* value ) +bool XMLUtil::ToDouble(const char* str, double* value) { - if ( TIXML_SSCANF( str, "%lf", value ) == 1 ) { + if (TIXML_SSCANF(str, "%lf", value) == 1) { return true; } return false; } -char* XMLDocument::Identify( char* p, XMLNode** node ) +char* XMLDocument::Identify(char* p, XMLNode** node) { - TIXMLASSERT( node ); - TIXMLASSERT( p ); + TIXMLASSERT(node); + TIXMLASSERT(p); char* const start = p; - p = XMLUtil::SkipWhiteSpace( p ); - if( !*p ) { + p = XMLUtil::SkipWhiteSpace(p); + if(!*p) { *node = 0; - TIXMLASSERT( p ); + TIXMLASSERT(p); return p; } @@ -633,77 +633,77 @@ char* XMLDocument::Identify( char* p, XMLNode** node ) static const int dtdHeaderLen = 2; static const int elementHeaderLen = 1; - TIXMLASSERT( sizeof( XMLComment ) == sizeof( XMLUnknown ) ); // use same memory pool - TIXMLASSERT( sizeof( XMLComment ) == sizeof( XMLDeclaration ) ); // use same memory pool + TIXMLASSERT(sizeof(XMLComment) == sizeof(XMLUnknown)); // use same memory pool + TIXMLASSERT(sizeof(XMLComment) == sizeof(XMLDeclaration)); // use same memory pool XMLNode* returnNode = 0; - if ( XMLUtil::StringEqual( p, xmlHeader, xmlHeaderLen ) ) { - TIXMLASSERT( sizeof( XMLDeclaration ) == _commentPool.ItemSize() ); - returnNode = new (_commentPool.Alloc()) XMLDeclaration( this ); + if (XMLUtil::StringEqual(p, xmlHeader, xmlHeaderLen)) { + TIXMLASSERT(sizeof(XMLDeclaration) == _commentPool.ItemSize()); + returnNode = new (_commentPool.Alloc()) XMLDeclaration(this); returnNode->_memPool = &_commentPool; p += xmlHeaderLen; } - else if ( XMLUtil::StringEqual( p, commentHeader, commentHeaderLen ) ) { - TIXMLASSERT( sizeof( XMLComment ) == _commentPool.ItemSize() ); - returnNode = new (_commentPool.Alloc()) XMLComment( this ); + else if (XMLUtil::StringEqual(p, commentHeader, commentHeaderLen)) { + TIXMLASSERT(sizeof(XMLComment) == _commentPool.ItemSize()); + returnNode = new (_commentPool.Alloc()) XMLComment(this); returnNode->_memPool = &_commentPool; p += commentHeaderLen; } - else if ( XMLUtil::StringEqual( p, cdataHeader, cdataHeaderLen ) ) { - TIXMLASSERT( sizeof( XMLText ) == _textPool.ItemSize() ); - XMLText* text = new (_textPool.Alloc()) XMLText( this ); + else if (XMLUtil::StringEqual(p, cdataHeader, cdataHeaderLen)) { + TIXMLASSERT(sizeof(XMLText) == _textPool.ItemSize()); + XMLText* text = new (_textPool.Alloc()) XMLText(this); returnNode = text; returnNode->_memPool = &_textPool; p += cdataHeaderLen; - text->SetCData( true ); + text->SetCData(true); } - else if ( XMLUtil::StringEqual( p, dtdHeader, dtdHeaderLen ) ) { - TIXMLASSERT( sizeof( XMLUnknown ) == _commentPool.ItemSize() ); - returnNode = new (_commentPool.Alloc()) XMLUnknown( this ); + else if (XMLUtil::StringEqual(p, dtdHeader, dtdHeaderLen)) { + TIXMLASSERT(sizeof(XMLUnknown) == _commentPool.ItemSize()); + returnNode = new (_commentPool.Alloc()) XMLUnknown(this); returnNode->_memPool = &_commentPool; p += dtdHeaderLen; } - else if ( XMLUtil::StringEqual( p, elementHeader, elementHeaderLen ) ) { - TIXMLASSERT( sizeof( XMLElement ) == _elementPool.ItemSize() ); - returnNode = new (_elementPool.Alloc()) XMLElement( this ); + else if (XMLUtil::StringEqual(p, elementHeader, elementHeaderLen)) { + TIXMLASSERT(sizeof(XMLElement) == _elementPool.ItemSize()); + returnNode = new (_elementPool.Alloc()) XMLElement(this); returnNode->_memPool = &_elementPool; p += elementHeaderLen; } else { - TIXMLASSERT( sizeof( XMLText ) == _textPool.ItemSize() ); - returnNode = new (_textPool.Alloc()) XMLText( this ); + TIXMLASSERT(sizeof(XMLText) == _textPool.ItemSize()); + returnNode = new (_textPool.Alloc()) XMLText(this); returnNode->_memPool = &_textPool; p = start; // Back it up, all the text counts. } - TIXMLASSERT( returnNode ); - TIXMLASSERT( p ); + TIXMLASSERT(returnNode); + TIXMLASSERT(p); *node = returnNode; return p; } -bool XMLDocument::Accept( XMLVisitor* visitor ) const +bool XMLDocument::Accept(XMLVisitor* visitor) const { - TIXMLASSERT( visitor ); - if ( visitor->VisitEnter( *this ) ) { - for ( const XMLNode* node=FirstChild(); node; node=node->NextSibling() ) { - if ( !node->Accept( visitor ) ) { + TIXMLASSERT(visitor); + if (visitor->VisitEnter(*this)) { + for (const XMLNode* node=FirstChild(); node; node=node->NextSibling()) { + if (!node->Accept(visitor)) { break; } } } - return visitor->VisitExit( *this ); + return visitor->VisitExit(*this); } // --------- XMLNode ----------- // -XMLNode::XMLNode( XMLDocument* doc ) : - _document( doc ), - _parent( 0 ), - _firstChild( 0 ), _lastChild( 0 ), - _prev( 0 ), _next( 0 ), - _memPool( 0 ) +XMLNode::XMLNode(XMLDocument* doc) : + _document(doc), + _parent(0), + _firstChild(0), _lastChild(0), + _prev(0), _next(0), + _memPool(0) { } @@ -711,88 +711,88 @@ XMLNode::XMLNode( XMLDocument* doc ) : XMLNode::~XMLNode() { DeleteChildren(); - if ( _parent ) { - _parent->Unlink( this ); + if (_parent) { + _parent->Unlink(this); } } const char* XMLNode::Value() const { // Catch an edge case: XMLDocuments don't have a a Value. Carefully return nullptr. - if ( this->ToDocument() ) + if (this->ToDocument()) return 0; return _value.GetStr(); } -void XMLNode::SetValue( const char* str, bool staticMem ) +void XMLNode::SetValue(const char* str, bool staticMem) { - if ( staticMem ) { - _value.SetInternedStr( str ); + if (staticMem) { + _value.SetInternedStr(str); } else { - _value.SetStr( str ); + _value.SetStr(str); } } void XMLNode::DeleteChildren() { - while( _firstChild ) { - TIXMLASSERT( _lastChild ); - TIXMLASSERT( _firstChild->_document == _document ); + while(_firstChild) { + TIXMLASSERT(_lastChild); + TIXMLASSERT(_firstChild->_document == _document); XMLNode* node = _firstChild; - Unlink( node ); + Unlink(node); - DeleteNode( node ); + DeleteNode(node); } _firstChild = _lastChild = 0; } -void XMLNode::Unlink( XMLNode* child ) +void XMLNode::Unlink(XMLNode* child) { - TIXMLASSERT( child ); - TIXMLASSERT( child->_document == _document ); - TIXMLASSERT( child->_parent == this ); - if ( child == _firstChild ) { + TIXMLASSERT(child); + TIXMLASSERT(child->_document == _document); + TIXMLASSERT(child->_parent == this); + if (child == _firstChild) { _firstChild = _firstChild->_next; } - if ( child == _lastChild ) { + if (child == _lastChild) { _lastChild = _lastChild->_prev; } - if ( child->_prev ) { + if (child->_prev) { child->_prev->_next = child->_next; } - if ( child->_next ) { + if (child->_next) { child->_next->_prev = child->_prev; } child->_parent = 0; } -void XMLNode::DeleteChild( XMLNode* node ) +void XMLNode::DeleteChild(XMLNode* node) { - TIXMLASSERT( node ); - TIXMLASSERT( node->_document == _document ); - TIXMLASSERT( node->_parent == this ); - Unlink( node ); - DeleteNode( node ); + TIXMLASSERT(node); + TIXMLASSERT(node->_document == _document); + TIXMLASSERT(node->_parent == this); + Unlink(node); + DeleteNode(node); } -XMLNode* XMLNode::InsertEndChild( XMLNode* addThis ) +XMLNode* XMLNode::InsertEndChild(XMLNode* addThis) { - TIXMLASSERT( addThis ); - if ( addThis->_document != _document ) { - TIXMLASSERT( false ); + TIXMLASSERT(addThis); + if (addThis->_document != _document) { + TIXMLASSERT(false); return 0; } - InsertChildPreamble( addThis ); + InsertChildPreamble(addThis); - if ( _lastChild ) { - TIXMLASSERT( _firstChild ); - TIXMLASSERT( _lastChild->_next == 0 ); + if (_lastChild) { + TIXMLASSERT(_firstChild); + TIXMLASSERT(_lastChild->_next == 0); _lastChild->_next = addThis; addThis->_prev = _lastChild; _lastChild = addThis; @@ -800,7 +800,7 @@ XMLNode* XMLNode::InsertEndChild( XMLNode* addThis ) addThis->_next = 0; } else { - TIXMLASSERT( _firstChild == 0 ); + TIXMLASSERT(_firstChild == 0); _firstChild = _lastChild = addThis; addThis->_prev = 0; @@ -811,18 +811,18 @@ XMLNode* XMLNode::InsertEndChild( XMLNode* addThis ) } -XMLNode* XMLNode::InsertFirstChild( XMLNode* addThis ) +XMLNode* XMLNode::InsertFirstChild(XMLNode* addThis) { - TIXMLASSERT( addThis ); - if ( addThis->_document != _document ) { - TIXMLASSERT( false ); + TIXMLASSERT(addThis); + if (addThis->_document != _document) { + TIXMLASSERT(false); return 0; } - InsertChildPreamble( addThis ); + InsertChildPreamble(addThis); - if ( _firstChild ) { - TIXMLASSERT( _lastChild ); - TIXMLASSERT( _firstChild->_prev == 0 ); + if (_firstChild) { + TIXMLASSERT(_lastChild); + TIXMLASSERT(_firstChild->_prev == 0); _firstChild->_prev = addThis; addThis->_next = _firstChild; @@ -831,7 +831,7 @@ XMLNode* XMLNode::InsertFirstChild( XMLNode* addThis ) addThis->_prev = 0; } else { - TIXMLASSERT( _lastChild == 0 ); + TIXMLASSERT(_lastChild == 0); _firstChild = _lastChild = addThis; addThis->_prev = 0; @@ -842,26 +842,26 @@ XMLNode* XMLNode::InsertFirstChild( XMLNode* addThis ) } -XMLNode* XMLNode::InsertAfterChild( XMLNode* afterThis, XMLNode* addThis ) +XMLNode* XMLNode::InsertAfterChild(XMLNode* afterThis, XMLNode* addThis) { - TIXMLASSERT( addThis ); - if ( addThis->_document != _document ) { - TIXMLASSERT( false ); + TIXMLASSERT(addThis); + if (addThis->_document != _document) { + TIXMLASSERT(false); return 0; } - TIXMLASSERT( afterThis ); + TIXMLASSERT(afterThis); - if ( afterThis->_parent != this ) { - TIXMLASSERT( false ); + if (afterThis->_parent != this) { + TIXMLASSERT(false); return 0; } - if ( afterThis->_next == 0 ) { + if (afterThis->_next == 0) { // The last node or the only node. - return InsertEndChild( addThis ); + return InsertEndChild(addThis); } - InsertChildPreamble( addThis ); + InsertChildPreamble(addThis); addThis->_prev = afterThis; addThis->_next = afterThis->_next; afterThis->_next->_prev = addThis; @@ -873,12 +873,12 @@ XMLNode* XMLNode::InsertAfterChild( XMLNode* afterThis, XMLNode* addThis ) -const XMLElement* XMLNode::FirstChildElement( const char* name ) const +const XMLElement* XMLNode::FirstChildElement(const char* name) const { - for( const XMLNode* node = _firstChild; node; node = node->_next ) { + for(const XMLNode* node = _firstChild; node; node = node->_next) { const XMLElement* element = node->ToElement(); - if ( element ) { - if ( !name || XMLUtil::StringEqual( element->Name(), name ) ) { + if (element) { + if (!name || XMLUtil::StringEqual(element->Name(), name)) { return element; } } @@ -887,12 +887,12 @@ const XMLElement* XMLNode::FirstChildElement( const char* name ) const } -const XMLElement* XMLNode::LastChildElement( const char* name ) const +const XMLElement* XMLNode::LastChildElement(const char* name) const { - for( const XMLNode* node = _lastChild; node; node = node->_prev ) { + for(const XMLNode* node = _lastChild; node; node = node->_prev) { const XMLElement* element = node->ToElement(); - if ( element ) { - if ( !name || XMLUtil::StringEqual( element->Name(), name ) ) { + if (element) { + if (!name || XMLUtil::StringEqual(element->Name(), name)) { return element; } } @@ -901,12 +901,12 @@ const XMLElement* XMLNode::LastChildElement( const char* name ) const } -const XMLElement* XMLNode::NextSiblingElement( const char* name ) const +const XMLElement* XMLNode::NextSiblingElement(const char* name) const { - for( const XMLNode* node = _next; node; node = node->_next ) { + for(const XMLNode* node = _next; node; node = node->_next) { const XMLElement* element = node->ToElement(); - if ( element - && (!name || XMLUtil::StringEqual( name, element->Name() ))) { + if (element + && (!name || XMLUtil::StringEqual(name, element->Name()))) { return element; } } @@ -914,12 +914,12 @@ const XMLElement* XMLNode::NextSiblingElement( const char* name ) const } -const XMLElement* XMLNode::PreviousSiblingElement( const char* name ) const +const XMLElement* XMLNode::PreviousSiblingElement(const char* name) const { - for( const XMLNode* node = _prev; node; node = node->_prev ) { + for(const XMLNode* node = _prev; node; node = node->_prev) { const XMLElement* element = node->ToElement(); - if ( element - && (!name || XMLUtil::StringEqual( name, element->Name() ))) { + if (element + && (!name || XMLUtil::StringEqual(name, element->Name()))) { return element; } } @@ -927,7 +927,7 @@ const XMLElement* XMLNode::PreviousSiblingElement( const char* name ) const } -char* XMLNode::ParseDeep( char* p, StrPair* parentEnd ) +char* XMLNode::ParseDeep(char* p, StrPair* parentEnd) { // This is a recursive method, but thinking about it "at the current level" // it is a pretty simple flat list: @@ -946,152 +946,152 @@ char* XMLNode::ParseDeep( char* p, StrPair* parentEnd ) // 'endTag' is the end tag for this node, it is returned by a call to a child. // 'parentEnd' is the end tag for the parent, which is filled in and returned. - while( p && *p ) { + while(p && *p) { XMLNode* node = 0; - p = _document->Identify( p, &node ); - if ( node == 0 ) { + p = _document->Identify(p, &node); + if (node == 0) { break; } StrPair endTag; - p = node->ParseDeep( p, &endTag ); - if ( !p ) { - DeleteNode( node ); - if ( !_document->Error() ) { - _document->SetError( XML_ERROR_PARSING, 0, 0 ); + p = node->ParseDeep(p, &endTag); + if (!p) { + DeleteNode(node); + if (!_document->Error()) { + _document->SetError(XML_ERROR_PARSING, 0, 0); } break; } XMLDeclaration* decl = node->ToDeclaration(); - if ( decl ) { + if (decl) { // A declaration can only be the first child of a document. // Set error, if document already has children. - if ( !_document->NoChildren() ) { - _document->SetError( XML_ERROR_PARSING_DECLARATION, decl->Value(), 0); - DeleteNode( decl ); + if (!_document->NoChildren()) { + _document->SetError(XML_ERROR_PARSING_DECLARATION, decl->Value(), 0); + DeleteNode(decl); break; } } XMLElement* ele = node->ToElement(); - if ( ele ) { + if (ele) { // We read the end tag. Return it to the parent. - if ( ele->ClosingType() == XMLElement::CLOSING ) { - if ( parentEnd ) { - ele->_value.TransferTo( parentEnd ); + if (ele->ClosingType() == XMLElement::CLOSING) { + if (parentEnd) { + ele->_value.TransferTo(parentEnd); } node->_memPool->SetTracked(); // created and then immediately deleted. - DeleteNode( node ); + DeleteNode(node); return p; } // Handle an end tag returned to this level. // And handle a bunch of annoying errors. bool mismatch = false; - if ( endTag.Empty() ) { - if ( ele->ClosingType() == XMLElement::OPEN ) { + if (endTag.Empty()) { + if (ele->ClosingType() == XMLElement::OPEN) { mismatch = true; } } else { - if ( ele->ClosingType() != XMLElement::OPEN ) { + if (ele->ClosingType() != XMLElement::OPEN) { mismatch = true; } - else if ( !XMLUtil::StringEqual( endTag.GetStr(), ele->Name() ) ) { + else if (!XMLUtil::StringEqual(endTag.GetStr(), ele->Name())) { mismatch = true; } } - if ( mismatch ) { - _document->SetError( XML_ERROR_MISMATCHED_ELEMENT, ele->Name(), 0 ); - DeleteNode( node ); + if (mismatch) { + _document->SetError(XML_ERROR_MISMATCHED_ELEMENT, ele->Name(), 0); + DeleteNode(node); break; } } - InsertEndChild( node ); + InsertEndChild(node); } return 0; } -void XMLNode::DeleteNode( XMLNode* node ) +void XMLNode::DeleteNode(XMLNode* node) { - if ( node == 0 ) { + if (node == 0) { return; } MemPool* pool = node->_memPool; node->~XMLNode(); - pool->Free( node ); + pool->Free(node); } -void XMLNode::InsertChildPreamble( XMLNode* insertThis ) const +void XMLNode::InsertChildPreamble(XMLNode* insertThis) const { - TIXMLASSERT( insertThis ); - TIXMLASSERT( insertThis->_document == _document ); + TIXMLASSERT(insertThis); + TIXMLASSERT(insertThis->_document == _document); - if ( insertThis->_parent ) - insertThis->_parent->Unlink( insertThis ); + if (insertThis->_parent) + insertThis->_parent->Unlink(insertThis); else insertThis->_memPool->SetTracked(); } // --------- XMLText ---------- // -char* XMLText::ParseDeep( char* p, StrPair* ) +char* XMLText::ParseDeep(char* p, StrPair*) { const char* start = p; - if ( this->CData() ) { - p = _value.ParseText( p, "]]>", StrPair::NEEDS_NEWLINE_NORMALIZATION ); - if ( !p ) { - _document->SetError( XML_ERROR_PARSING_CDATA, start, 0 ); + if (this->CData()) { + p = _value.ParseText(p, "]]>", StrPair::NEEDS_NEWLINE_NORMALIZATION); + if (!p) { + _document->SetError(XML_ERROR_PARSING_CDATA, start, 0); } return p; } else { int flags = _document->ProcessEntities() ? StrPair::TEXT_ELEMENT : StrPair::TEXT_ELEMENT_LEAVE_ENTITIES; - if ( _document->WhitespaceMode() == COLLAPSE_WHITESPACE ) { + if (_document->WhitespaceMode() == COLLAPSE_WHITESPACE) { flags |= StrPair::NEEDS_WHITESPACE_COLLAPSING; } - p = _value.ParseText( p, "<", flags ); - if ( p && *p ) { + p = _value.ParseText(p, "<", flags); + if (p && *p) { return p-1; } - if ( !p ) { - _document->SetError( XML_ERROR_PARSING_TEXT, start, 0 ); + if (!p) { + _document->SetError(XML_ERROR_PARSING_TEXT, start, 0); } } return 0; } -XMLNode* XMLText::ShallowClone( XMLDocument* doc ) const +XMLNode* XMLText::ShallowClone(XMLDocument* doc) const { - if ( !doc ) { + if (!doc) { doc = _document; } - XMLText* text = doc->NewText( Value() ); // fixme: this will always allocate memory. Intern? - text->SetCData( this->CData() ); + XMLText* text = doc->NewText(Value()); // fixme: this will always allocate memory. Intern? + text->SetCData(this->CData()); return text; } -bool XMLText::ShallowEqual( const XMLNode* compare ) const +bool XMLText::ShallowEqual(const XMLNode* compare) const { const XMLText* text = compare->ToText(); - return ( text && XMLUtil::StringEqual( text->Value(), Value() ) ); + return (text && XMLUtil::StringEqual(text->Value(), Value())); } -bool XMLText::Accept( XMLVisitor* visitor ) const +bool XMLText::Accept(XMLVisitor* visitor) const { - TIXMLASSERT( visitor ); - return visitor->Visit( *this ); + TIXMLASSERT(visitor); + return visitor->Visit(*this); } // --------- XMLComment ---------- // -XMLComment::XMLComment( XMLDocument* doc ) : XMLNode( doc ) +XMLComment::XMLComment(XMLDocument* doc) : XMLNode(doc) { } @@ -1101,96 +1101,96 @@ XMLComment::~XMLComment() } -char* XMLComment::ParseDeep( char* p, StrPair* ) +char* XMLComment::ParseDeep(char* p, StrPair*) { // Comment parses as text. const char* start = p; - p = _value.ParseText( p, "-->", StrPair::COMMENT ); - if ( p == 0 ) { - _document->SetError( XML_ERROR_PARSING_COMMENT, start, 0 ); + p = _value.ParseText(p, "-->", StrPair::COMMENT); + if (p == 0) { + _document->SetError(XML_ERROR_PARSING_COMMENT, start, 0); } return p; } -XMLNode* XMLComment::ShallowClone( XMLDocument* doc ) const +XMLNode* XMLComment::ShallowClone(XMLDocument* doc) const { - if ( !doc ) { + if (!doc) { doc = _document; } - XMLComment* comment = doc->NewComment( Value() ); // fixme: this will always allocate memory. Intern? + XMLComment* comment = doc->NewComment(Value()); // fixme: this will always allocate memory. Intern? return comment; } -bool XMLComment::ShallowEqual( const XMLNode* compare ) const +bool XMLComment::ShallowEqual(const XMLNode* compare) const { - TIXMLASSERT( compare ); + TIXMLASSERT(compare); const XMLComment* comment = compare->ToComment(); - return ( comment && XMLUtil::StringEqual( comment->Value(), Value() )); + return (comment && XMLUtil::StringEqual(comment->Value(), Value())); } -bool XMLComment::Accept( XMLVisitor* visitor ) const +bool XMLComment::Accept(XMLVisitor* visitor) const { - TIXMLASSERT( visitor ); - return visitor->Visit( *this ); + TIXMLASSERT(visitor); + return visitor->Visit(*this); } // --------- XMLDeclaration ---------- // -XMLDeclaration::XMLDeclaration( XMLDocument* doc ) : XMLNode( doc ) +XMLDeclaration::XMLDeclaration(XMLDocument* doc) : XMLNode(doc) { } XMLDeclaration::~XMLDeclaration() { - //printf( "~XMLDeclaration\n" ); + //printf("~XMLDeclaration\n"); } -char* XMLDeclaration::ParseDeep( char* p, StrPair* ) +char* XMLDeclaration::ParseDeep(char* p, StrPair*) { // Declaration parses as text. const char* start = p; - p = _value.ParseText( p, "?>", StrPair::NEEDS_NEWLINE_NORMALIZATION ); - if ( p == 0 ) { - _document->SetError( XML_ERROR_PARSING_DECLARATION, start, 0 ); + p = _value.ParseText(p, "?>", StrPair::NEEDS_NEWLINE_NORMALIZATION); + if (p == 0) { + _document->SetError(XML_ERROR_PARSING_DECLARATION, start, 0); } return p; } -XMLNode* XMLDeclaration::ShallowClone( XMLDocument* doc ) const +XMLNode* XMLDeclaration::ShallowClone(XMLDocument* doc) const { - if ( !doc ) { + if (!doc) { doc = _document; } - XMLDeclaration* dec = doc->NewDeclaration( Value() ); // fixme: this will always allocate memory. Intern? + XMLDeclaration* dec = doc->NewDeclaration(Value()); // fixme: this will always allocate memory. Intern? return dec; } -bool XMLDeclaration::ShallowEqual( const XMLNode* compare ) const +bool XMLDeclaration::ShallowEqual(const XMLNode* compare) const { - TIXMLASSERT( compare ); + TIXMLASSERT(compare); const XMLDeclaration* declaration = compare->ToDeclaration(); - return ( declaration && XMLUtil::StringEqual( declaration->Value(), Value() )); + return (declaration && XMLUtil::StringEqual(declaration->Value(), Value())); } -bool XMLDeclaration::Accept( XMLVisitor* visitor ) const +bool XMLDeclaration::Accept(XMLVisitor* visitor) const { - TIXMLASSERT( visitor ); - return visitor->Visit( *this ); + TIXMLASSERT(visitor); + return visitor->Visit(*this); } // --------- XMLUnknown ---------- // -XMLUnknown::XMLUnknown( XMLDocument* doc ) : XMLNode( doc ) +XMLUnknown::XMLUnknown(XMLDocument* doc) : XMLNode(doc) { } @@ -1200,41 +1200,41 @@ XMLUnknown::~XMLUnknown() } -char* XMLUnknown::ParseDeep( char* p, StrPair* ) +char* XMLUnknown::ParseDeep(char* p, StrPair*) { // Unknown parses as text. const char* start = p; - p = _value.ParseText( p, ">", StrPair::NEEDS_NEWLINE_NORMALIZATION ); - if ( !p ) { - _document->SetError( XML_ERROR_PARSING_UNKNOWN, start, 0 ); + p = _value.ParseText(p, ">", StrPair::NEEDS_NEWLINE_NORMALIZATION); + if (!p) { + _document->SetError(XML_ERROR_PARSING_UNKNOWN, start, 0); } return p; } -XMLNode* XMLUnknown::ShallowClone( XMLDocument* doc ) const +XMLNode* XMLUnknown::ShallowClone(XMLDocument* doc) const { - if ( !doc ) { + if (!doc) { doc = _document; } - XMLUnknown* text = doc->NewUnknown( Value() ); // fixme: this will always allocate memory. Intern? + XMLUnknown* text = doc->NewUnknown(Value()); // fixme: this will always allocate memory. Intern? return text; } -bool XMLUnknown::ShallowEqual( const XMLNode* compare ) const +bool XMLUnknown::ShallowEqual(const XMLNode* compare) const { - TIXMLASSERT( compare ); + TIXMLASSERT(compare); const XMLUnknown* unknown = compare->ToUnknown(); - return ( unknown && XMLUtil::StringEqual( unknown->Value(), Value() )); + return (unknown && XMLUtil::StringEqual(unknown->Value(), Value())); } -bool XMLUnknown::Accept( XMLVisitor* visitor ) const +bool XMLUnknown::Accept(XMLVisitor* visitor) const { - TIXMLASSERT( visitor ); - return visitor->Visit( *this ); + TIXMLASSERT(visitor); + return visitor->Visit(*this); } // --------- XMLAttribute ---------- // @@ -1249,163 +1249,163 @@ const char* XMLAttribute::Value() const return _value.GetStr(); } -char* XMLAttribute::ParseDeep( char* p, bool processEntities ) +char* XMLAttribute::ParseDeep(char* p, bool processEntities) { // Parse using the name rules: bug fix, was using ParseText before - p = _name.ParseName( p ); - if ( !p || !*p ) { + p = _name.ParseName(p); + if (!p || !*p) { return 0; } // Skip white space before = - p = XMLUtil::SkipWhiteSpace( p ); - if ( *p != '=' ) { + p = XMLUtil::SkipWhiteSpace(p); + if (*p != '=') { return 0; } ++p; // move up to opening quote - p = XMLUtil::SkipWhiteSpace( p ); - if ( *p != '\"' && *p != '\'' ) { + p = XMLUtil::SkipWhiteSpace(p); + if (*p != '\"' && *p != '\'') { return 0; } char endTag[2] = { *p, 0 }; ++p; // move past opening quote - p = _value.ParseText( p, endTag, processEntities ? StrPair::ATTRIBUTE_VALUE : StrPair::ATTRIBUTE_VALUE_LEAVE_ENTITIES ); + p = _value.ParseText(p, endTag, processEntities ? StrPair::ATTRIBUTE_VALUE : StrPair::ATTRIBUTE_VALUE_LEAVE_ENTITIES); return p; } -void XMLAttribute::SetName( const char* n ) +void XMLAttribute::SetName(const char* n) { - _name.SetStr( n ); + _name.SetStr(n); } -XMLError XMLAttribute::QueryIntValue( int* value ) const +XMLError XMLAttribute::QueryIntValue(int* value) const { - if ( XMLUtil::ToInt( Value(), value )) { + if (XMLUtil::ToInt(Value(), value)) { return XML_NO_ERROR; } return XML_WRONG_ATTRIBUTE_TYPE; } -XMLError XMLAttribute::QueryUnsignedValue( unsigned int* value ) const +XMLError XMLAttribute::QueryUnsignedValue(unsigned int* value) const { - if ( XMLUtil::ToUnsigned( Value(), value )) { + if (XMLUtil::ToUnsigned(Value(), value)) { return XML_NO_ERROR; } return XML_WRONG_ATTRIBUTE_TYPE; } -XMLError XMLAttribute::QueryBoolValue( bool* value ) const +XMLError XMLAttribute::QueryBoolValue(bool* value) const { - if ( XMLUtil::ToBool( Value(), value )) { + if (XMLUtil::ToBool(Value(), value)) { return XML_NO_ERROR; } return XML_WRONG_ATTRIBUTE_TYPE; } -XMLError XMLAttribute::QueryFloatValue( float* value ) const +XMLError XMLAttribute::QueryFloatValue(float* value) const { - if ( XMLUtil::ToFloat( Value(), value )) { + if (XMLUtil::ToFloat(Value(), value)) { return XML_NO_ERROR; } return XML_WRONG_ATTRIBUTE_TYPE; } -XMLError XMLAttribute::QueryDoubleValue( double* value ) const +XMLError XMLAttribute::QueryDoubleValue(double* value) const { - if ( XMLUtil::ToDouble( Value(), value )) { + if (XMLUtil::ToDouble(Value(), value)) { return XML_NO_ERROR; } return XML_WRONG_ATTRIBUTE_TYPE; } -void XMLAttribute::SetAttribute( const char* v ) +void XMLAttribute::SetAttribute(const char* v) { - _value.SetStr( v ); + _value.SetStr(v); } -void XMLAttribute::SetAttribute( int v ) +void XMLAttribute::SetAttribute(int v) { char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - _value.SetStr( buf ); + XMLUtil::ToStr(v, buf, BUF_SIZE); + _value.SetStr(buf); } -void XMLAttribute::SetAttribute( unsigned v ) +void XMLAttribute::SetAttribute(unsigned v) { char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - _value.SetStr( buf ); + XMLUtil::ToStr(v, buf, BUF_SIZE); + _value.SetStr(buf); } -void XMLAttribute::SetAttribute( bool v ) +void XMLAttribute::SetAttribute(bool v) { char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - _value.SetStr( buf ); + XMLUtil::ToStr(v, buf, BUF_SIZE); + _value.SetStr(buf); } -void XMLAttribute::SetAttribute( double v ) +void XMLAttribute::SetAttribute(double v) { char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - _value.SetStr( buf ); + XMLUtil::ToStr(v, buf, BUF_SIZE); + _value.SetStr(buf); } -void XMLAttribute::SetAttribute( float v ) +void XMLAttribute::SetAttribute(float v) { char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - _value.SetStr( buf ); + XMLUtil::ToStr(v, buf, BUF_SIZE); + _value.SetStr(buf); } // --------- XMLElement ---------- // -XMLElement::XMLElement( XMLDocument* doc ) : XMLNode( doc ), - _closingType( 0 ), - _rootAttribute( 0 ) +XMLElement::XMLElement(XMLDocument* doc) : XMLNode(doc), + _closingType(0), + _rootAttribute(0) { } XMLElement::~XMLElement() { - while( _rootAttribute ) { + while(_rootAttribute) { XMLAttribute* next = _rootAttribute->_next; - DeleteAttribute( _rootAttribute ); + DeleteAttribute(_rootAttribute); _rootAttribute = next; } } -const XMLAttribute* XMLElement::FindAttribute( const char* name ) const +const XMLAttribute* XMLElement::FindAttribute(const char* name) const { - for( XMLAttribute* a = _rootAttribute; a; a = a->_next ) { - if ( XMLUtil::StringEqual( a->Name(), name ) ) { + for(XMLAttribute* a = _rootAttribute; a; a = a->_next) { + if (XMLUtil::StringEqual(a->Name(), name)) { return a; } } return 0; } -std::string XMLElement::StrAttribute( const char* name, const char* value ) const +std::string XMLElement::StrAttribute(const char* name, const char* value) const { std::string str; - const XMLAttribute* a = FindAttribute( name ); - if ( a ) { - if ( !value || XMLUtil::StringEqual( a->Value(), value )) { + const XMLAttribute* a = FindAttribute(name); + if (a) { + if (!value || XMLUtil::StringEqual(a->Value(), value)) { str = a->Value(); return str; } @@ -1413,13 +1413,13 @@ std::string XMLElement::StrAttribute( const char* name, const char* value ) cons return str; } -const char* XMLElement::Attribute( const char* name, const char* value ) const +const char* XMLElement::Attribute(const char* name, const char* value) const { - const XMLAttribute* a = FindAttribute( name ); - if ( !a ) { + const XMLAttribute* a = FindAttribute(name); + if (!a) { return 0; } - if ( !value || XMLUtil::StringEqual( a->Value(), value )) { + if (!value || XMLUtil::StringEqual(a->Value(), value)) { return a->Value(); } return 0; @@ -1427,69 +1427,69 @@ const char* XMLElement::Attribute( const char* name, const char* value ) const const char* XMLElement::GetText() const { - if ( FirstChild() && FirstChild()->ToText() ) { + if (FirstChild() && FirstChild()->ToText()) { return FirstChild()->Value(); } return 0; } -void XMLElement::SetText( const char* inText ) +void XMLElement::SetText(const char* inText) { - if ( FirstChild() && FirstChild()->ToText() ) - FirstChild()->SetValue( inText ); + if (FirstChild() && FirstChild()->ToText()) + FirstChild()->SetValue(inText); else { - XMLText* theText = GetDocument()->NewText( inText ); - InsertFirstChild( theText ); + XMLText* theText = GetDocument()->NewText(inText); + InsertFirstChild(theText); } } -void XMLElement::SetText( int v ) +void XMLElement::SetText(int v) { char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - SetText( buf ); + XMLUtil::ToStr(v, buf, BUF_SIZE); + SetText(buf); } -void XMLElement::SetText( unsigned v ) +void XMLElement::SetText(unsigned v) { char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - SetText( buf ); + XMLUtil::ToStr(v, buf, BUF_SIZE); + SetText(buf); } -void XMLElement::SetText( bool v ) +void XMLElement::SetText(bool v) { char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - SetText( buf ); + XMLUtil::ToStr(v, buf, BUF_SIZE); + SetText(buf); } -void XMLElement::SetText( float v ) +void XMLElement::SetText(float v) { char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - SetText( buf ); + XMLUtil::ToStr(v, buf, BUF_SIZE); + SetText(buf); } -void XMLElement::SetText( double v ) +void XMLElement::SetText(double v) { char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - SetText( buf ); + XMLUtil::ToStr(v, buf, BUF_SIZE); + SetText(buf); } -XMLError XMLElement::QueryIntText( int* ival ) const +XMLError XMLElement::QueryIntText(int* ival) const { - if ( FirstChild() && FirstChild()->ToText() ) { + if (FirstChild() && FirstChild()->ToText()) { const char* t = FirstChild()->Value(); - if ( XMLUtil::ToInt( t, ival ) ) { + if (XMLUtil::ToInt(t, ival)) { return XML_SUCCESS; } return XML_CAN_NOT_CONVERT_TEXT; @@ -1498,11 +1498,11 @@ XMLError XMLElement::QueryIntText( int* ival ) const } -XMLError XMLElement::QueryUnsignedText( unsigned* uval ) const +XMLError XMLElement::QueryUnsignedText(unsigned* uval) const { - if ( FirstChild() && FirstChild()->ToText() ) { + if (FirstChild() && FirstChild()->ToText()) { const char* t = FirstChild()->Value(); - if ( XMLUtil::ToUnsigned( t, uval ) ) { + if (XMLUtil::ToUnsigned(t, uval)) { return XML_SUCCESS; } return XML_CAN_NOT_CONVERT_TEXT; @@ -1511,11 +1511,11 @@ XMLError XMLElement::QueryUnsignedText( unsigned* uval ) const } -XMLError XMLElement::QueryBoolText( bool* bval ) const +XMLError XMLElement::QueryBoolText(bool* bval) const { - if ( FirstChild() && FirstChild()->ToText() ) { + if (FirstChild() && FirstChild()->ToText()) { const char* t = FirstChild()->Value(); - if ( XMLUtil::ToBool( t, bval ) ) { + if (XMLUtil::ToBool(t, bval)) { return XML_SUCCESS; } return XML_CAN_NOT_CONVERT_TEXT; @@ -1524,11 +1524,11 @@ XMLError XMLElement::QueryBoolText( bool* bval ) const } -XMLError XMLElement::QueryDoubleText( double* dval ) const +XMLError XMLElement::QueryDoubleText(double* dval) const { - if ( FirstChild() && FirstChild()->ToText() ) { + if (FirstChild() && FirstChild()->ToText()) { const char* t = FirstChild()->Value(); - if ( XMLUtil::ToDouble( t, dval ) ) { + if (XMLUtil::ToDouble(t, dval)) { return XML_SUCCESS; } return XML_CAN_NOT_CONVERT_TEXT; @@ -1537,11 +1537,11 @@ XMLError XMLElement::QueryDoubleText( double* dval ) const } -XMLError XMLElement::QueryFloatText( float* fval ) const +XMLError XMLElement::QueryFloatText(float* fval) const { - if ( FirstChild() && FirstChild()->ToText() ) { + if (FirstChild() && FirstChild()->ToText()) { const char* t = FirstChild()->Value(); - if ( XMLUtil::ToFloat( t, fval ) ) { + if (XMLUtil::ToFloat(t, fval)) { return XML_SUCCESS; } return XML_CAN_NOT_CONVERT_TEXT; @@ -1551,46 +1551,46 @@ XMLError XMLElement::QueryFloatText( float* fval ) const -XMLAttribute* XMLElement::FindOrCreateAttribute( const char* name ) +XMLAttribute* XMLElement::FindOrCreateAttribute(const char* name) { XMLAttribute* last = 0; XMLAttribute* attrib = 0; - for( attrib = _rootAttribute; + for(attrib = _rootAttribute; attrib; - last = attrib, attrib = attrib->_next ) { - if ( XMLUtil::StringEqual( attrib->Name(), name ) ) { + last = attrib, attrib = attrib->_next) { + if (XMLUtil::StringEqual(attrib->Name(), name)) { break; } } - if ( !attrib ) { - TIXMLASSERT( sizeof( XMLAttribute ) == _document->_attributePool.ItemSize() ); - attrib = new (_document->_attributePool.Alloc() ) XMLAttribute(); + if (!attrib) { + TIXMLASSERT(sizeof(XMLAttribute) == _document->_attributePool.ItemSize()); + attrib = new (_document->_attributePool.Alloc()) XMLAttribute(); attrib->_memPool = &_document->_attributePool; - if ( last ) { + if (last) { last->_next = attrib; } else { _rootAttribute = attrib; } - attrib->SetName( name ); + attrib->SetName(name); attrib->_memPool->SetTracked(); // always created and linked. } return attrib; } -void XMLElement::DeleteAttribute( const char* name ) +void XMLElement::DeleteAttribute(const char* name) { XMLAttribute* prev = 0; - for( XMLAttribute* a=_rootAttribute; a; a=a->_next ) { - if ( XMLUtil::StringEqual( name, a->Name() ) ) { - if ( prev ) { + for(XMLAttribute* a=_rootAttribute; a; a=a->_next) { + if (XMLUtil::StringEqual(name, a->Name())) { + if (prev) { prev->_next = a->_next; } else { _rootAttribute = a->_next; } - DeleteAttribute( a ); + DeleteAttribute(a); break; } prev = a; @@ -1598,30 +1598,30 @@ void XMLElement::DeleteAttribute( const char* name ) } -char* XMLElement::ParseAttributes( char* p ) +char* XMLElement::ParseAttributes(char* p) { const char* start = p; XMLAttribute* prevAttribute = 0; // Read the attributes. - while( p ) { - p = XMLUtil::SkipWhiteSpace( p ); - if ( !(*p) ) { - _document->SetError( XML_ERROR_PARSING_ELEMENT, start, Name() ); + while(p) { + p = XMLUtil::SkipWhiteSpace(p); + if (!(*p)) { + _document->SetError(XML_ERROR_PARSING_ELEMENT, start, Name()); return 0; } // attribute. - if (XMLUtil::IsNameStartChar( *p ) ) { - TIXMLASSERT( sizeof( XMLAttribute ) == _document->_attributePool.ItemSize() ); - XMLAttribute* attrib = new (_document->_attributePool.Alloc() ) XMLAttribute(); + if (XMLUtil::IsNameStartChar(*p)) { + TIXMLASSERT(sizeof(XMLAttribute) == _document->_attributePool.ItemSize()); + XMLAttribute* attrib = new (_document->_attributePool.Alloc()) XMLAttribute(); attrib->_memPool = &_document->_attributePool; attrib->_memPool->SetTracked(); - p = attrib->ParseDeep( p, _document->ProcessEntities() ); - if ( !p || Attribute( attrib->Name() ) ) { - DeleteAttribute( attrib ); - _document->SetError( XML_ERROR_PARSING_ATTRIBUTE, start, p ); + p = attrib->ParseDeep(p, _document->ProcessEntities()); + if (!p || Attribute(attrib->Name())) { + DeleteAttribute(attrib); + _document->SetError(XML_ERROR_PARSING_ATTRIBUTE, start, p); return 0; } // There is a minor bug here: if the attribute in the source xml @@ -1629,7 +1629,7 @@ char* XMLElement::ParseAttributes( char* p ) // attribute will be doubly added. However, tracking the 'prevAttribute' // avoids re-scanning the attribute list. Preferring performance for // now, may reconsider in the future. - if ( prevAttribute ) { + if (prevAttribute) { prevAttribute->_next = attrib; } else { @@ -1638,96 +1638,96 @@ char* XMLElement::ParseAttributes( char* p ) prevAttribute = attrib; } // end of the tag - else if ( *p == '>' ) { + else if (*p == '>') { ++p; break; } // end of the tag - else if ( *p == '/' && *(p+1) == '>' ) { + else if (*p == '/' && *(p+1) == '>') { _closingType = CLOSED; return p+2; // done; sealed element. } else { - _document->SetError( XML_ERROR_PARSING_ELEMENT, start, p ); + _document->SetError(XML_ERROR_PARSING_ELEMENT, start, p); return 0; } } return p; } -void XMLElement::DeleteAttribute( XMLAttribute* attribute ) +void XMLElement::DeleteAttribute(XMLAttribute* attribute) { - if ( attribute == 0 ) { + if (attribute == 0) { return; } MemPool* pool = attribute->_memPool; attribute->~XMLAttribute(); - pool->Free( attribute ); + pool->Free(attribute); } // // // foobar // -char* XMLElement::ParseDeep( char* p, StrPair* strPair ) +char* XMLElement::ParseDeep(char* p, StrPair* strPair) { // Read the element name. - p = XMLUtil::SkipWhiteSpace( p ); + p = XMLUtil::SkipWhiteSpace(p); // The closing element is the form. It is // parsed just like a regular element then deleted from // the DOM. - if ( *p == '/' ) { + if (*p == '/') { _closingType = CLOSING; ++p; } - p = _value.ParseName( p ); - if ( _value.Empty() ) { + p = _value.ParseName(p); + if (_value.Empty()) { return 0; } - p = ParseAttributes( p ); - if ( !p || !*p || _closingType ) { + p = ParseAttributes(p); + if (!p || !*p || _closingType) { return p; } - p = XMLNode::ParseDeep( p, strPair ); + p = XMLNode::ParseDeep(p, strPair); return p; } -XMLNode* XMLElement::ShallowClone( XMLDocument* doc ) const +XMLNode* XMLElement::ShallowClone(XMLDocument* doc) const { - if ( !doc ) { + if (!doc) { doc = _document; } - XMLElement* element = doc->NewElement( Value() ); // fixme: this will always allocate memory. Intern? - for( const XMLAttribute* a=FirstAttribute(); a; a=a->Next() ) { - element->SetAttribute( a->Name(), a->Value() ); // fixme: this will always allocate memory. Intern? + XMLElement* element = doc->NewElement(Value()); // fixme: this will always allocate memory. Intern? + for(const XMLAttribute* a=FirstAttribute(); a; a=a->Next()) { + element->SetAttribute(a->Name(), a->Value()); // fixme: this will always allocate memory. Intern? } return element; } -bool XMLElement::ShallowEqual( const XMLNode* compare ) const +bool XMLElement::ShallowEqual(const XMLNode* compare) const { - TIXMLASSERT( compare ); + TIXMLASSERT(compare); const XMLElement* other = compare->ToElement(); - if ( other && XMLUtil::StringEqual( other->Name(), Name() )) { + if (other && XMLUtil::StringEqual(other->Name(), Name())) { const XMLAttribute* a=FirstAttribute(); const XMLAttribute* b=other->FirstAttribute(); - while ( a && b ) { - if ( !XMLUtil::StringEqual( a->Value(), b->Value() ) ) { + while (a && b) { + if (!XMLUtil::StringEqual(a->Value(), b->Value())) { return false; } a = a->Next(); b = b->Next(); } - if ( a || b ) { + if (a || b) { // different count return false; } @@ -1737,17 +1737,17 @@ bool XMLElement::ShallowEqual( const XMLNode* compare ) const } -bool XMLElement::Accept( XMLVisitor* visitor ) const +bool XMLElement::Accept(XMLVisitor* visitor) const { - TIXMLASSERT( visitor ); - if ( visitor->VisitEnter( *this, _rootAttribute ) ) { - for ( const XMLNode* node=FirstChild(); node; node=node->NextSibling() ) { - if ( !node->Accept( visitor ) ) { + TIXMLASSERT(visitor); + if (visitor->VisitEnter(*this, _rootAttribute)) { + for (const XMLNode* node=FirstChild(); node; node=node->NextSibling()) { + if (!node->Accept(visitor)) { break; } } } - return visitor->VisitExit( *this ); + return visitor->VisitExit(*this); } @@ -1778,15 +1778,15 @@ const char* XMLDocument::_errorNames[XML_ERROR_COUNT] = { }; -XMLDocument::XMLDocument( bool processEntities, Whitespace whitespace ) : - XMLNode( 0 ), - _writeBOM( false ), - _processEntities( processEntities ), - _errorID( XML_NO_ERROR ), - _whitespace( whitespace ), - _errorStr1( 0 ), - _errorStr2( 0 ), - _charBuffer( 0 ) +XMLDocument::XMLDocument(bool processEntities, Whitespace whitespace) : + XMLNode(0), + _writeBOM(false), + _processEntities(processEntities), + _errorID(XML_NO_ERROR), + _whitespace(whitespace), + _errorStr1(0), + _errorStr2(0), + _charBuffer(0) { // avoid VC++ C4355 warning about 'this' in initializer list (C4355 is off by default in VS2012+) _document = this; @@ -1814,93 +1814,93 @@ void XMLDocument::Clear() _charBuffer = 0; #if 0 - _textPool.Trace( "text" ); - _elementPool.Trace( "element" ); - _commentPool.Trace( "comment" ); - _attributePool.Trace( "attribute" ); + _textPool.Trace("text"); + _elementPool.Trace("element"); + _commentPool.Trace("comment"); + _attributePool.Trace("attribute"); #endif #ifdef DEBUG - if ( !hadError ) { - TIXMLASSERT( _elementPool.CurrentAllocs() == _elementPool.Untracked() ); - TIXMLASSERT( _attributePool.CurrentAllocs() == _attributePool.Untracked() ); - TIXMLASSERT( _textPool.CurrentAllocs() == _textPool.Untracked() ); - TIXMLASSERT( _commentPool.CurrentAllocs() == _commentPool.Untracked() ); + if (!hadError) { + TIXMLASSERT(_elementPool.CurrentAllocs() == _elementPool.Untracked()); + TIXMLASSERT(_attributePool.CurrentAllocs() == _attributePool.Untracked()); + TIXMLASSERT(_textPool.CurrentAllocs() == _textPool.Untracked()); + TIXMLASSERT(_commentPool.CurrentAllocs() == _commentPool.Untracked()); } #endif } -XMLElement* XMLDocument::NewElement( const char* name ) +XMLElement* XMLDocument::NewElement(const char* name) { - TIXMLASSERT( sizeof( XMLElement ) == _elementPool.ItemSize() ); - XMLElement* ele = new (_elementPool.Alloc()) XMLElement( this ); + TIXMLASSERT(sizeof(XMLElement) == _elementPool.ItemSize()); + XMLElement* ele = new (_elementPool.Alloc()) XMLElement(this); ele->_memPool = &_elementPool; - ele->SetName( name ); + ele->SetName(name); return ele; } -XMLComment* XMLDocument::NewComment( const char* str ) +XMLComment* XMLDocument::NewComment(const char* str) { - TIXMLASSERT( sizeof( XMLComment ) == _commentPool.ItemSize() ); - XMLComment* comment = new (_commentPool.Alloc()) XMLComment( this ); + TIXMLASSERT(sizeof(XMLComment) == _commentPool.ItemSize()); + XMLComment* comment = new (_commentPool.Alloc()) XMLComment(this); comment->_memPool = &_commentPool; - comment->SetValue( str ); + comment->SetValue(str); return comment; } -XMLText* XMLDocument::NewText( const char* str ) +XMLText* XMLDocument::NewText(const char* str) { - TIXMLASSERT( sizeof( XMLText ) == _textPool.ItemSize() ); - XMLText* text = new (_textPool.Alloc()) XMLText( this ); + TIXMLASSERT(sizeof(XMLText) == _textPool.ItemSize()); + XMLText* text = new (_textPool.Alloc()) XMLText(this); text->_memPool = &_textPool; - text->SetValue( str ); + text->SetValue(str); return text; } -XMLDeclaration* XMLDocument::NewDeclaration( const char* str ) +XMLDeclaration* XMLDocument::NewDeclaration(const char* str) { - TIXMLASSERT( sizeof( XMLDeclaration ) == _commentPool.ItemSize() ); - XMLDeclaration* dec = new (_commentPool.Alloc()) XMLDeclaration( this ); + TIXMLASSERT(sizeof(XMLDeclaration) == _commentPool.ItemSize()); + XMLDeclaration* dec = new (_commentPool.Alloc()) XMLDeclaration(this); dec->_memPool = &_commentPool; - dec->SetValue( str ? str : "xml version=\"1.0\" encoding=\"UTF-8\"" ); + dec->SetValue(str ? str : "xml version=\"1.0\" encoding=\"UTF-8\""); return dec; } -XMLUnknown* XMLDocument::NewUnknown( const char* str ) +XMLUnknown* XMLDocument::NewUnknown(const char* str) { - TIXMLASSERT( sizeof( XMLUnknown ) == _commentPool.ItemSize() ); - XMLUnknown* unk = new (_commentPool.Alloc()) XMLUnknown( this ); + TIXMLASSERT(sizeof(XMLUnknown) == _commentPool.ItemSize()); + XMLUnknown* unk = new (_commentPool.Alloc()) XMLUnknown(this); unk->_memPool = &_commentPool; - unk->SetValue( str ); + unk->SetValue(str); return unk; } -static FILE* callfopen( const char* filepath, const char* mode ) +static FILE* callfopen(const char* filepath, const char* mode) { - TIXMLASSERT( filepath ); - TIXMLASSERT( mode ); -#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE) + TIXMLASSERT(filepath); + TIXMLASSERT(mode); +#if defined(_MSC_VER) && (_MSC_VER >= 1400) && (!defined WINCE) FILE* fp = 0; - errno_t err = fopen_s( &fp, filepath, mode ); - if ( err ) { + errno_t err = fopen_s(&fp, filepath, mode); + if (err) { return 0; } #else - FILE* fp = fopen( filepath, mode ); + FILE* fp = fopen(filepath, mode); #endif return fp; } -void XMLDocument::DeleteNode( XMLNode* node ) { - TIXMLASSERT( node ); - TIXMLASSERT(node->_document == this ); +void XMLDocument::DeleteNode(XMLNode* node) { + TIXMLASSERT(node); + TIXMLASSERT(node->_document == this); if (node->_parent) { - node->_parent->DeleteChild( node ); + node->_parent->DeleteChild(node); } else { // Isn't in the tree. @@ -1914,16 +1914,16 @@ void XMLDocument::DeleteNode( XMLNode* node ) { } -XMLError XMLDocument::LoadFile( const char* filename ) +XMLError XMLDocument::LoadFile(const char* filename) { Clear(); - FILE* fp = callfopen( filename, "rb" ); - if ( !fp ) { - SetError( XML_ERROR_FILE_NOT_FOUND, filename, 0 ); + FILE* fp = callfopen(filename, "rb"); + if (!fp) { + SetError(XML_ERROR_FILE_NOT_FOUND, filename, 0); return _errorID; } - LoadFile( fp ); - fclose( fp ); + LoadFile(fp); + fclose(fp); return _errorID; } @@ -1936,53 +1936,53 @@ XMLError XMLDocument::LoadFile( const char* filename ) template = sizeof(size_t))> struct LongFitsIntoSizeTMinusOne { - static bool Fits( unsigned long value ) + static bool Fits(unsigned long value) { return value < (size_t)-1; } }; template <> -bool LongFitsIntoSizeTMinusOne::Fits( unsigned long /*value*/ ) +bool LongFitsIntoSizeTMinusOne::Fits(unsigned long /*value*/) { return true; } -XMLError XMLDocument::LoadFile( FILE* fp ) +XMLError XMLDocument::LoadFile(FILE* fp) { Clear(); - fseek( fp, 0, SEEK_SET ); - if ( fgetc( fp ) == EOF && ferror( fp ) != 0 ) { - SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 ); + fseek(fp, 0, SEEK_SET); + if (fgetc(fp) == EOF && ferror(fp) != 0) { + SetError(XML_ERROR_FILE_READ_ERROR, 0, 0); return _errorID; } - fseek( fp, 0, SEEK_END ); - const long filelength = ftell( fp ); - fseek( fp, 0, SEEK_SET ); - if ( filelength == -1L ) { - SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 ); + fseek(fp, 0, SEEK_END); + const long filelength = ftell(fp); + fseek(fp, 0, SEEK_SET); + if (filelength == -1L) { + SetError(XML_ERROR_FILE_READ_ERROR, 0, 0); return _errorID; } - if ( !LongFitsIntoSizeTMinusOne<>::Fits( filelength ) ) { + if (!LongFitsIntoSizeTMinusOne<>::Fits(filelength)) { // Cannot handle files which won't fit in buffer together with null terminator - SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 ); + SetError(XML_ERROR_FILE_READ_ERROR, 0, 0); return _errorID; } - if ( filelength == 0 ) { - SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 ); + if (filelength == 0) { + SetError(XML_ERROR_EMPTY_DOCUMENT, 0, 0); return _errorID; } const size_t size = filelength; - TIXMLASSERT( _charBuffer == 0 ); + TIXMLASSERT(_charBuffer == 0); _charBuffer = new char[size+1]; - size_t read = fread( _charBuffer, 1, size, fp ); - if ( read != size ) { - SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 ); + size_t read = fread(_charBuffer, 1, size, fp); + if (read != size) { + SetError(XML_ERROR_FILE_READ_ERROR, 0, 0); return _errorID; } @@ -1993,48 +1993,48 @@ XMLError XMLDocument::LoadFile( FILE* fp ) } -XMLError XMLDocument::SaveFile( const char* filename, bool compact ) +XMLError XMLDocument::SaveFile(const char* filename, bool compact) { - FILE* fp = callfopen( filename, "w" ); - if ( !fp ) { - SetError( XML_ERROR_FILE_COULD_NOT_BE_OPENED, filename, 0 ); + FILE* fp = callfopen(filename, "w"); + if (!fp) { + SetError(XML_ERROR_FILE_COULD_NOT_BE_OPENED, filename, 0); return _errorID; } SaveFile(fp, compact); - fclose( fp ); + fclose(fp); return _errorID; } -XMLError XMLDocument::SaveFile( FILE* fp, bool compact ) +XMLError XMLDocument::SaveFile(FILE* fp, bool compact) { // Clear any error from the last save, otherwise it will get reported // for *this* call. - SetError( XML_NO_ERROR, 0, 0 ); - XMLPrinter stream( fp, compact ); - Print( &stream ); + SetError(XML_NO_ERROR, 0, 0); + XMLPrinter stream(fp, compact); + Print(&stream); return _errorID; } -XMLError XMLDocument::Parse( const char* p, size_t len ) +XMLError XMLDocument::Parse(const char* p, size_t len) { Clear(); - if ( len == 0 || !p || !*p ) { - SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 ); + if (len == 0 || !p || !*p) { + SetError(XML_ERROR_EMPTY_DOCUMENT, 0, 0); return _errorID; } - if ( len == (size_t)(-1) ) { - len = strlen( p ); + if (len == (size_t)(-1)) { + len = strlen(p); } - TIXMLASSERT( _charBuffer == 0 ); + TIXMLASSERT(_charBuffer == 0); _charBuffer = new char[ len+1 ]; - memcpy( _charBuffer, p, len ); + memcpy(_charBuffer, p, len); _charBuffer[len] = 0; Parse(); - if ( Error() ) { + if (Error()) { // clean up now essentially dangling memory. // and the parse fail can put objects in the // pools that are dead and inaccessible. @@ -2048,21 +2048,21 @@ XMLError XMLDocument::Parse( const char* p, size_t len ) } -void XMLDocument::Print( XMLPrinter* streamer ) const +void XMLDocument::Print(XMLPrinter* streamer) const { - if ( streamer ) { - Accept( streamer ); + if (streamer) { + Accept(streamer); } else { - XMLPrinter stdoutStreamer( stdout ); - Accept( &stdoutStreamer ); + XMLPrinter stdoutStreamer(stdout); + Accept(&stdoutStreamer); } } -void XMLDocument::SetError( XMLError error, const char* str1, const char* str2 ) +void XMLDocument::SetError(XMLError error, const char* str1, const char* str2) { - TIXMLASSERT( error >= 0 && error < XML_ERROR_COUNT ); + TIXMLASSERT(error >= 0 && error < XML_ERROR_COUNT); _errorID = error; _errorStr1 = str1; _errorStr2 = str2; @@ -2070,246 +2070,246 @@ void XMLDocument::SetError( XMLError error, const char* str1, const char* str2 ) const char* XMLDocument::ErrorName() const { - TIXMLASSERT( _errorID >= 0 && _errorID < XML_ERROR_COUNT ); + TIXMLASSERT(_errorID >= 0 && _errorID < XML_ERROR_COUNT); const char* errorName = _errorNames[_errorID]; - TIXMLASSERT( errorName && errorName[0] ); + TIXMLASSERT(errorName && errorName[0]); return errorName; } void XMLDocument::PrintError() const { - if ( Error() ) { + if (Error()) { static const int LEN = 20; char buf1[LEN] = { 0 }; char buf2[LEN] = { 0 }; - if ( _errorStr1 ) { - TIXML_SNPRINTF( buf1, LEN, "%s", _errorStr1 ); + if (_errorStr1) { + TIXML_SNPRINTF(buf1, LEN, "%s", _errorStr1); } - if ( _errorStr2 ) { - TIXML_SNPRINTF( buf2, LEN, "%s", _errorStr2 ); + if (_errorStr2) { + TIXML_SNPRINTF(buf2, LEN, "%s", _errorStr2); } // Should check INT_MIN <= _errorID && _errorId <= INT_MAX, but that // causes a clang "always true" -Wtautological-constant-out-of-range-compare warning - TIXMLASSERT( 0 <= _errorID && XML_ERROR_COUNT - 1 <= INT_MAX ); - printf( "XMLDocument error id=%d '%s' str1=%s str2=%s\n", - static_cast( _errorID ), ErrorName(), buf1, buf2 ); + TIXMLASSERT(0 <= _errorID && XML_ERROR_COUNT - 1 <= INT_MAX); + printf("XMLDocument error id=%d '%s' str1=%s str2=%s\n", + static_cast(_errorID), ErrorName(), buf1, buf2); } } void XMLDocument::Parse() { - TIXMLASSERT( NoChildren() ); // Clear() must have been called previously - TIXMLASSERT( _charBuffer ); + TIXMLASSERT(NoChildren()); // Clear() must have been called previously + TIXMLASSERT(_charBuffer); char* p = _charBuffer; - p = XMLUtil::SkipWhiteSpace( p ); - p = const_cast( XMLUtil::ReadBOM( p, &_writeBOM ) ); - if ( !*p ) { - SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 ); + p = XMLUtil::SkipWhiteSpace(p); + p = const_cast(XMLUtil::ReadBOM(p, &_writeBOM)); + if (!*p) { + SetError(XML_ERROR_EMPTY_DOCUMENT, 0, 0); return; } - ParseDeep(p, 0 ); + ParseDeep(p, 0); } -XMLPrinter::XMLPrinter( FILE* file, bool compact, int depth ) : - _elementJustOpened( false ), - _firstElement( true ), - _fp( file ), - _depth( depth ), - _textDepth( -1 ), - _processEntities( true ), - _compactMode( compact ) +XMLPrinter::XMLPrinter(FILE* file, bool compact, int depth) : + _elementJustOpened(false), + _firstElement(true), + _fp(file), + _depth(depth), + _textDepth(-1), + _processEntities(true), + _compactMode(compact) { - for( int i=0; i'] = true; // not required, but consistency is nice - _buffer.Push( 0 ); + _buffer.Push(0); } -void XMLPrinter::Print( const char* format, ... ) +void XMLPrinter::Print(const char* format, ...) { va_list va; - va_start( va, format ); + va_start(va, format); - if ( _fp ) { - vfprintf( _fp, format, va ); + if (_fp) { + vfprintf(_fp, format, va); } else { - const int len = TIXML_VSCPRINTF( format, va ); + const int len = TIXML_VSCPRINTF(format, va); // Close out and re-start the va-args - va_end( va ); - TIXMLASSERT( len >= 0 ); - va_start( va, format ); - TIXMLASSERT( _buffer.Size() > 0 && _buffer[_buffer.Size() - 1] == 0 ); - char* p = _buffer.PushArr( len ) - 1; // back up over the null terminator. - TIXML_VSNPRINTF( p, len+1, format, va ); + va_end(va); + TIXMLASSERT(len >= 0); + va_start(va, format); + TIXMLASSERT(_buffer.Size() > 0 && _buffer[_buffer.Size() - 1] == 0); + char* p = _buffer.PushArr(len) - 1; // back up over the null terminator. + TIXML_VSNPRINTF(p, len+1, format, va); } - va_end( va ); + va_end(va); } -void XMLPrinter::PrintSpace( int depth ) +void XMLPrinter::PrintSpace(int depth) { - for( int i=0; i 0 && *q < ENTITY_RANGE ) { + if (*q > 0 && *q < ENTITY_RANGE) { // Check for entities. If one is found, flush // the stream up until the entity, write the // entity, and keep looking. - if ( flag[(unsigned char)(*q)] ) { - while ( p < q ) { + if (flag[(unsigned char)(*q)]) { + while (p < q) { const size_t delta = q - p; // %.*s accepts type int as "precision" - const int toPrint = ( INT_MAX < delta ) ? INT_MAX : (int)delta; - Print( "%.*s", toPrint, p ); + const int toPrint = (INT_MAX < delta) ? INT_MAX : (int)delta; + Print("%.*s", toPrint, p); p += toPrint; } bool entityPatternPrinted = false; - for( int i=0; i" ); + if (_elementJustOpened) { + Print("/>"); } else { - if ( _textDepth < 0 && !compactMode) { - Print( "\n" ); - PrintSpace( _depth ); + if (_textDepth < 0 && !compactMode) { + Print("\n"); + PrintSpace(_depth); } - Print( "", name ); + Print("", name); } - if ( _textDepth == _depth ) { + if (_textDepth == _depth) { _textDepth = -1; } - if ( _depth == 0 && !compactMode) { - Print( "\n" ); + if (_depth == 0 && !compactMode) { + Print("\n"); } _elementJustOpened = false; } @@ -2317,159 +2317,159 @@ void XMLPrinter::CloseElement( bool compactMode ) void XMLPrinter::SealElementIfJustOpened() { - if ( !_elementJustOpened ) { + if (!_elementJustOpened) { return; } _elementJustOpened = false; - Print( ">" ); + Print(">"); } -void XMLPrinter::PushText( const char* text, bool cdata ) +void XMLPrinter::PushText(const char* text, bool cdata) { _textDepth = _depth-1; SealElementIfJustOpened(); - if ( cdata ) { - Print( "", text ); + if (cdata) { + Print("", text); } else { - PrintString( text, true ); + PrintString(text, true); } } -void XMLPrinter::PushText( int value ) +void XMLPrinter::PushText(int value) { char buf[BUF_SIZE]; - XMLUtil::ToStr( value, buf, BUF_SIZE ); - PushText( buf, false ); + XMLUtil::ToStr(value, buf, BUF_SIZE); + PushText(buf, false); } -void XMLPrinter::PushText( unsigned value ) +void XMLPrinter::PushText(unsigned value) { char buf[BUF_SIZE]; - XMLUtil::ToStr( value, buf, BUF_SIZE ); - PushText( buf, false ); + XMLUtil::ToStr(value, buf, BUF_SIZE); + PushText(buf, false); } -void XMLPrinter::PushText( bool value ) +void XMLPrinter::PushText(bool value) { char buf[BUF_SIZE]; - XMLUtil::ToStr( value, buf, BUF_SIZE ); - PushText( buf, false ); + XMLUtil::ToStr(value, buf, BUF_SIZE); + PushText(buf, false); } -void XMLPrinter::PushText( float value ) +void XMLPrinter::PushText(float value) { char buf[BUF_SIZE]; - XMLUtil::ToStr( value, buf, BUF_SIZE ); - PushText( buf, false ); + XMLUtil::ToStr(value, buf, BUF_SIZE); + PushText(buf, false); } -void XMLPrinter::PushText( double value ) +void XMLPrinter::PushText(double value) { char buf[BUF_SIZE]; - XMLUtil::ToStr( value, buf, BUF_SIZE ); - PushText( buf, false ); + XMLUtil::ToStr(value, buf, BUF_SIZE); + PushText(buf, false); } -void XMLPrinter::PushComment( const char* comment ) +void XMLPrinter::PushComment(const char* comment) { SealElementIfJustOpened(); - if ( _textDepth < 0 && !_firstElement && !_compactMode) { - Print( "\n" ); - PrintSpace( _depth ); + if (_textDepth < 0 && !_firstElement && !_compactMode) { + Print("\n"); + PrintSpace(_depth); } _firstElement = false; - Print( "", comment ); + Print("", comment); } -void XMLPrinter::PushDeclaration( const char* value ) +void XMLPrinter::PushDeclaration(const char* value) { SealElementIfJustOpened(); - if ( _textDepth < 0 && !_firstElement && !_compactMode) { - Print( "\n" ); - PrintSpace( _depth ); + if (_textDepth < 0 && !_firstElement && !_compactMode) { + Print("\n"); + PrintSpace(_depth); } _firstElement = false; - Print( "", value ); + Print("", value); } -void XMLPrinter::PushUnknown( const char* value ) +void XMLPrinter::PushUnknown(const char* value) { SealElementIfJustOpened(); - if ( _textDepth < 0 && !_firstElement && !_compactMode) { - Print( "\n" ); - PrintSpace( _depth ); + if (_textDepth < 0 && !_firstElement && !_compactMode) { + Print("\n"); + PrintSpace(_depth); } _firstElement = false; - Print( "", value ); + Print("", value); } -bool XMLPrinter::VisitEnter( const XMLDocument& doc ) +bool XMLPrinter::VisitEnter(const XMLDocument& doc) { _processEntities = doc.ProcessEntities(); - if ( doc.HasBOM() ) { - PushHeader( true, false ); + if (doc.HasBOM()) { + PushHeader(true, false); } return true; } -bool XMLPrinter::VisitEnter( const XMLElement& element, const XMLAttribute* attribute ) +bool XMLPrinter::VisitEnter(const XMLElement& element, const XMLAttribute* attribute) { const XMLElement* parentElem = 0; - if ( element.Parent() ) { + if (element.Parent()) { parentElem = element.Parent()->ToElement(); } - const bool compactMode = parentElem ? CompactMode( *parentElem ) : _compactMode; - OpenElement( element.Name(), compactMode ); - while ( attribute ) { - PushAttribute( attribute->Name(), attribute->Value() ); + const bool compactMode = parentElem ? CompactMode(*parentElem) : _compactMode; + OpenElement(element.Name(), compactMode); + while (attribute) { + PushAttribute(attribute->Name(), attribute->Value()); attribute = attribute->Next(); } return true; } -bool XMLPrinter::VisitExit( const XMLElement& element ) +bool XMLPrinter::VisitExit(const XMLElement& element) { - CloseElement( CompactMode(element) ); + CloseElement(CompactMode(element)); return true; } -bool XMLPrinter::Visit( const XMLText& text ) +bool XMLPrinter::Visit(const XMLText& text) { - PushText( text.Value(), text.CData() ); + PushText(text.Value(), text.CData()); return true; } -bool XMLPrinter::Visit( const XMLComment& comment ) +bool XMLPrinter::Visit(const XMLComment& comment) { - PushComment( comment.Value() ); + PushComment(comment.Value()); return true; } -bool XMLPrinter::Visit( const XMLDeclaration& declaration ) +bool XMLPrinter::Visit(const XMLDeclaration& declaration) { - PushDeclaration( declaration.Value() ); + PushDeclaration(declaration.Value()); return true; } -bool XMLPrinter::Visit( const XMLUnknown& unknown ) +bool XMLPrinter::Visit(const XMLUnknown& unknown) { - PushUnknown( unknown.Value() ); + PushUnknown(unknown.Value()); return true; } diff --git a/src/ui.cpp b/src/ui.cpp index 731d18b..a78686c 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -12,6 +12,8 @@ extern SDL_Window *window; extern Player *player; extern World *currentWorld; +extern World *currentWorldToLeft; +extern World *currentWorldToRight; extern WorldWeather weather; /* @@ -42,12 +44,12 @@ typedef struct { vec2 ad; } FT_Info; -static std::vector ftdat16 ( 93, { { 0, 0 }, { 0, 0 }, { 0, 0 } } ); -static std::vector ftex16 ( 93, 0 ); +static std::vector ftdat16 (93, { { 0, 0 }, { 0, 0 }, { 0, 0 } }); +static std::vector ftex16 (93, 0); static bool ft16loaded = false; -static std::vector ftdat24 ( 93, { { 0, 0 }, { 0, 0 }, { 0, 0 } } ); -static std::vector ftex24 ( 93, 0 ); +static std::vector ftdat24 (93, { { 0, 0 }, { 0, 0 }, { 0, 0 } }); +static std::vector ftex24 (93, 0); static bool ft24loaded = false; static auto *ftdat = &ftdat16; @@ -61,7 +63,7 @@ static unsigned char fontColor[4] = {255,255,255,255}; static std::vector> dialogOptText; static std::string dialogBoxText; -static std::vector merchArrowLoc ( 2, vec3 { 0, 0, 0 } ); +static std::vector merchArrowLoc (2, vec3 { 0, 0, 0 }); static bool typeOutDone = true; static bool typeOutSustain = false; @@ -86,7 +88,7 @@ Mix_Chunk *sanic; static GLuint pageTex = 0; static bool pageTexReady = false; -void loadFontSize( unsigned int size, std::vector &tex, std::vector &dat ) +void loadFontSize(unsigned int size, std::vector &tex, std::vector &dat) { FT_Set_Pixel_Sizes(ftf,0,size); @@ -94,8 +96,8 @@ void loadFontSize( unsigned int size, std::vector &tex, std::vector &tex, std::vector &tex, std::vector &tex, std::vector buf ( ftf->glyph->bitmap.width * ftf->glyph->bitmap.rows, 0xFFFFFFFF ); + std::vector buf (ftf->glyph->bitmap.width * ftf->glyph->bitmap.rows, 0xFFFFFFFF); - for( unsigned int j = buf.size(); j--; ) + for(unsigned int j = buf.size(); j--;) buf[j] ^= !ftf->glyph->bitmap.buffer[j] ? buf[j] : 0; dat[i - 33].wh.x = ftf->glyph->bitmap.width; @@ -136,8 +138,8 @@ void loadFontSize( unsigned int size, std::vector &tex, std::vectorglyph->advance.x >> 6; dat[i - 33].ad.y = ftf->glyph->advance.y >> 6; - glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, ftf->glyph->bitmap.width, ftf->glyph->bitmap.rows, - 0, GL_RGBA, GL_UNSIGNED_BYTE, buf.data() ); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ftf->glyph->bitmap.width, ftf->glyph->bitmap.rows, + 0, GL_RGBA, GL_UNSIGNED_BYTE, buf.data()); } } @@ -193,7 +195,7 @@ namespace ui { */ void initFonts(void){ - if ( FT_Init_FreeType(&ftl) ) + if (FT_Init_FreeType(&ftl)) UserError("Couldn't initialize freetype."); #ifdef DEBUG @@ -221,7 +223,7 @@ namespace ui { */ void setFontFace(const char *ttf){ - if ( FT_New_Face( ftl, ttf, 0, &ftf ) ) + if (FT_New_Face(ftl, ttf, 0, &ftf)) UserError("Error! Couldn't open " + (std::string)ttf + "."); #ifdef DEBUG @@ -236,17 +238,17 @@ namespace ui { */ void setFontSize(unsigned int size){ - if ( size == 16 ) { - if( !ft16loaded ) { - loadFontSize( fontSize = size, ftex16, ftdat16 ); + if (size == 16) { + if(!ft16loaded) { + loadFontSize(fontSize = size, ftex16, ftdat16); ft16loaded = true; } ftex = &ftex16; ftdat = &ftdat16; fontSize = 16; - } else if ( size == 24 ) { - if ( !ft24loaded ) { - loadFontSize( fontSize = size, ftex24, ftdat24 ); + } else if (size == 24) { + if (!ft24loaded) { + loadFontSize(fontSize = size, ftex24, ftdat24); ft24loaded = true; } ftex = &ftex24; @@ -316,7 +318,7 @@ namespace ui { * Draw a string at the specified coordinates. */ - float putString( const float x, const float y, std::string s ) { + float putString(const float x, const float y, std::string s) { unsigned int i=0; vec2 add, o = {x, y}; @@ -341,7 +343,7 @@ namespace ui { i++; } - switch ( s[i] ) { + switch (s[i]) { case '\n': o.y -= fontSize * 1.05f; o.x = x; @@ -357,7 +359,7 @@ namespace ui { o.x += fontSize / 2; break; default: - add = putChar( floor(o.x), floor(o.y), s[i] ); + add = putChar(floor(o.x), floor(o.y), s[i]); o.x += add.x; o.y += add.y; break; @@ -368,12 +370,12 @@ namespace ui { return o.x; // i.e. the string width } - float putStringCentered( const float x, const float y, std::string s ) { + float putStringCentered(const float x, const float y, std::string s) { unsigned int i = 0; float width = 0; do { - switch ( s[i] ) { + switch (s[i]) { case '\n': // TODO break; @@ -395,7 +397,7 @@ namespace ui { * Prevents typeOut from typing the next string it's given. */ - void dontTypeOut( void ) { + void dontTypeOut(void) { typeOutSustain = true; } @@ -405,31 +407,31 @@ namespace ui { */ std::string ret; - std::string typeOut( std::string str ) { + std::string typeOut(std::string str) { static unsigned int tadv = TICKS_PER_SEC / 12; static unsigned int tickk, linc=0, // Contains the number of letters that should be drawn. size=0; // Contains the full size of the current string. // reset values if a new string is being passed. - if ( !linc || ret.substr( 0, linc ) != str.substr( 0, linc ) ) { + if (!linc || ret.substr(0, linc) != str.substr(0, linc)) { tickk = tickCount + tadv; - ret = str.substr( 0, 1 ); + ret = str.substr(0, 1); size = str.size(); // Set the new target string size linc = 1; // Reset the incrementers - if ( (typeOutDone = typeOutSustain) ) + if ((typeOutDone = typeOutSustain)) typeOutSustain = false; } - if ( typeOutDone ) + if (typeOutDone) return str; // Draw the next letter if necessary. - else if ( tickk <= tickCount ) { + else if (tickk <= tickCount) { tickk = tickCount + tadv; ret += str[linc]; - if ( linc < size ) + if (linc < size) linc++; else typeOutDone = true; @@ -442,7 +444,7 @@ namespace ui { * Draw a formatted string to the specified coordinates. */ - float putText( const float x, const float y, const char *str, ... ) { + float putText(const float x, const float y, const char *str, ...) { va_list args; std::unique_ptr buf (new char[512]); @@ -458,10 +460,10 @@ namespace ui { va_end(args); // draw the string and return the width - return putString( x, y, buf.get() ); + return putString(x, y, buf.get()); } - void dialogBox( const char *name, const char *opt, bool passive, const char *text, ... ) { + void dialogBox(const char *name, const char *opt, bool passive, const char *text, ...) { va_list dialogArgs; std::unique_ptr printfbuf (new char[512]); @@ -483,13 +485,13 @@ namespace ui { dialogOptChosen = 0; - if ( opt ) { + if (opt) { std::string soptbuf = opt; char *sopt = strtok(&soptbuf[0], ":"); // cycle through options while(sopt){ - dialogOptText.push_back(std::make_pair((std::string)sopt, vec3 {0,0,0}) ); + dialogOptText.push_back(std::make_pair((std::string)sopt, vec3 {0,0,0})); sopt = strtok(NULL,":"); } } @@ -533,7 +535,7 @@ namespace ui { // cycle through options while(sopt){ - dialogOptText.push_back(std::make_pair((std::string)sopt, vec3 {0,0,0}) ); + dialogOptText.push_back(std::make_pair((std::string)sopt, vec3 {0,0,0})); sopt = strtok(NULL,":"); } } @@ -556,19 +558,19 @@ namespace ui { * Wait for a dialog box to be dismissed. */ - void waitForDialog ( void ) { - while ( dialogBoxExists ); + void waitForDialog (void) { + while (dialogBoxExists); } - void waitForCover ( void ) { - while ( fadeIntensity < 255 ) + void waitForCover (void) { + while (fadeIntensity < 255) mainLoop(); fadeIntensity = 255; } - void waitForNothing ( unsigned int ms ) { + void waitForNothing (unsigned int ms) { unsigned int target = millis() + ms; - while ( millis() < target ); + while (millis() < target); } void importantText(const char *text,...){ @@ -608,8 +610,8 @@ namespace ui { } - void drawPage( std::string path ) { - pageTex = Texture::loadTexture( path ); + void drawPage(std::string path) { + pageTex = Texture::loadTexture(path); pageTexReady = true; } @@ -618,16 +620,16 @@ namespace ui { float x,y,tmp; std::string rtext; - if ( pageTexReady ) { - glEnable( GL_TEXTURE_2D ); - glBindTexture( GL_TEXTURE_2D, pageTex ); - glBegin( GL_QUADS ); - glTexCoord2i( 0, 0 ); glVertex2i( offset.x - 300, SCREEN_HEIGHT - 100 ); - glTexCoord2i( 1, 0 ); glVertex2i( offset.x + 300, SCREEN_HEIGHT - 100 ); - glTexCoord2i( 1, 1 ); glVertex2i( offset.x + 300, SCREEN_HEIGHT - 600 ); - glTexCoord2i( 0, 1 ); glVertex2i( offset.x - 300, SCREEN_HEIGHT - 600 ); + if (pageTexReady) { + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, pageTex); + glBegin(GL_QUADS); + glTexCoord2i(0, 0); glVertex2i(offset.x - 300, SCREEN_HEIGHT - 100); + glTexCoord2i(1, 0); glVertex2i(offset.x + 300, SCREEN_HEIGHT - 100); + glTexCoord2i(1, 1); glVertex2i(offset.x + 300, SCREEN_HEIGHT - 600); + glTexCoord2i(0, 1); glVertex2i(offset.x - 300, SCREEN_HEIGHT - 600); glEnd(); - glDisable( GL_TEXTURE_2D ); + glDisable(GL_TEXTURE_2D); } else if (dialogBoxExists) { @@ -648,7 +650,7 @@ namespace ui { putStringCentered(offset.x,offset.y,rtext.c_str()); setFontSize(16); } - }else if ( dialogMerchant ) { + }else if (dialogMerchant) { x=offset.x-SCREEN_WIDTH/6; y=(offset.y+SCREEN_HEIGHT/2)-HLINE*8; @@ -711,8 +713,8 @@ namespace ui { for(i = 0; i < 2; i++){ if(((merchArrowLoc[i].x < merchArrowLoc[i].z) ? (mouse.x > merchArrowLoc[i].x && mouse.x < merchArrowLoc[i].z) : - (mouse.x < merchArrowLoc[i].x && mouse.x > merchArrowLoc[i].z) ) && - mouse.y > merchArrowLoc[i].y - 8 && mouse.y < merchArrowLoc[i].y + 8 ) { + (mouse.x < merchArrowLoc[i].x && mouse.x > merchArrowLoc[i].z)) && + mouse.y > merchArrowLoc[i].y - 8 && mouse.y < merchArrowLoc[i].y + 8) { glColor3ub(255,255, 0); }else{ glColor3ub(255,255,255); @@ -739,7 +741,7 @@ namespace ui { // make text yellow if the mouse hovers over the text if(mouse.x > dialogOptText[i].second.x && mouse.x < dialogOptText[i].second.z && - mouse.y > dialogOptText[i].second.y && mouse.y < dialogOptText[i].second.y + 16 ){ + mouse.y > dialogOptText[i].second.y && mouse.y < dialogOptText[i].second.y + 16){ setFontColor(255, 255, 0); putStringCentered(offset.x, dialogOptText[i].second.y, dialogOptText[i].first); } @@ -778,7 +780,7 @@ namespace ui { if(mouse.x > dialogOptText[i].second.x && mouse.x < dialogOptText[i].second.z && mouse.y > dialogOptText[i].second.y && - mouse.y < dialogOptText[i].second.y + 16 ){ // fontSize + mouse.y < dialogOptText[i].second.y + 16){ // fontSize setFontColor(255,255,0); putStringCentered(offset.x,dialogOptText[i].second.y,dialogOptText[i].first); } @@ -787,9 +789,9 @@ namespace ui { } static unsigned int rtext_oldsize = 0; - if ( rtext_oldsize != rtext.size() ) { - if ( !isspace( rtext[(rtext_oldsize = rtext.size()) - 1] ) ) - Mix_PlayChannel( 1, dialogClick, 0 ); + if (rtext_oldsize != rtext.size()) { + if (!isspace(rtext[(rtext_oldsize = rtext.size()) - 1])) + Mix_PlayChannel(1, dialogClick, 0); } }if(!fadeIntensity){ @@ -861,8 +863,8 @@ namespace ui { void dialogAdvance(void){ unsigned char i; - if ( pageTex ) { - glDeleteTextures( 1, &pageTex ); + if (pageTex) { + glDeleteTextures(1, &pageTex); pageTex = 0; pageTexReady = false; return; @@ -877,14 +879,14 @@ namespace ui { if(mouse.x > dialogOptText[i].second.x && mouse.x < dialogOptText[i].second.z && mouse.y > dialogOptText[i].second.y && - mouse.y < dialogOptText[i].second.y + 16 ){ // fontSize + mouse.y < dialogOptText[i].second.y + 16){ // fontSize dialogOptChosen = i + 1; goto EXIT; } } - if ( dialogMerchant ) { - for ( i = 0; i < merchArrowLoc.size(); i++ ) { + if (dialogMerchant) { + for (i = 0; i < merchArrowLoc.size(); i++) { // TODO neaten this if statement @@ -922,8 +924,8 @@ EXIT: SDL_Event e; // update mouse coords - mouse.x = premouse.x + offset.x - ( SCREEN_WIDTH / 2 ); - mouse.y = ( offset.y + SCREEN_HEIGHT / 2 ) - premouse.y; + mouse.x = premouse.x + offset.x - (SCREEN_WIDTH / 2); + mouse.y = (offset.y + SCREEN_HEIGHT / 2) - premouse.y; static vec2 fr; static Entity *ig; @@ -943,7 +945,7 @@ EXIT: break; case SDL_MOUSEBUTTONUP: - if ( ig ) { + if (ig) { ig->vel.x = (fr.x - mouse.x) / 50.0f; ig->vel.y = (fr.y - mouse.y) / 50.0f; //ig->forcedMove = true; // kills vel.x too quickly @@ -955,22 +957,22 @@ EXIT: case SDL_MOUSEBUTTONDOWN: // right click advances dialog - if ( ( e.button.button & SDL_BUTTON_RIGHT ) && (dialogBoxExists | pageTexReady) ) + if ((e.button.button & SDL_BUTTON_RIGHT) && (dialogBoxExists | pageTexReady)) dialogAdvance(); // left click uses item - if ( ( e.button.button & SDL_BUTTON_LEFT ) && !dialogBoxExists ) + if ((e.button.button & SDL_BUTTON_LEFT) && !dialogBoxExists) player->inv->usingi = true; - if( mouse.x > player->loc.x && mouse.x < player->loc.x + player->width && - mouse.y > player->loc.y && mouse.y < player->loc.y + player->height ) { + if(mouse.x > player->loc.x && mouse.x < player->loc.x + player->width && + mouse.y > player->loc.y && mouse.y < player->loc.y + player->height) { player->vel.y = .05; fr = mouse; ig = player; } else { - for ( auto &e : currentWorld->entity ) { - if( mouse.x > e->loc.x && mouse.x < e->loc.x + e->width && - mouse.y > e->loc.y && mouse.y < e->loc.y + e->height ) { + for (auto &e : currentWorld->entity) { + if(mouse.x > e->loc.x && mouse.x < e->loc.x + e->width && + mouse.y > e->loc.y && mouse.y < e->loc.y + e->height) { e->vel.y = .05; fr = mouse; ig = e; @@ -997,8 +999,8 @@ EXIT: case SDL_KEYDOWN: // space - make player jump - if ( SDL_KEY == SDLK_SPACE ) { - if ( player->ground ) { + if (SDL_KEY == SDLK_SPACE) { + if (player->ground) { player->loc.y += HLINE * 2; player->vel.y = .4; player->ground = false; @@ -1006,7 +1008,7 @@ EXIT: break; // only let other keys be handled if dialog allows it - } else if ( !dialogBoxExists || dialogPassive ) { + } else if (!dialogBoxExists || dialogPassive) { tmp = currentWorld; switch(SDL_KEY){ case SDLK_t: @@ -1017,7 +1019,7 @@ EXIT: player->vel.x = -PLAYER_SPEED_CONSTANT; player->left = left = true; player->right = right = false; - if ( !currentWorld->toLeft.empty() ) { + if (currentWorldToLeft) { oldpos = player->loc; if((tmp = currentWorld->goWorldLeft(player)) != currentWorld){ tmppos = player->loc; @@ -1037,7 +1039,7 @@ EXIT: player->vel.x = PLAYER_SPEED_CONSTANT; player->right = right = true; player->left = left = false; - if ( !currentWorld->toRight.empty() ) { + if (currentWorldToRight) { oldpos = player->loc; if((tmp = currentWorld->goWorldRight(player)) != currentWorld){ tmppos = player->loc; @@ -1055,12 +1057,12 @@ EXIT: case SDLK_s: break; case SDLK_w: - if ( inBattle ) { + if (inBattle) { tmp = currentWorld; - currentWorld = ((Arena *)currentWorld)->exitArena( player ); - if ( tmp != currentWorld ) + currentWorld = ((Arena *)currentWorld)->exitArena(player); + if (tmp != currentWorld) toggleBlackFast(); - } else if ( (tmp = currentWorld->goInsideStructure( player )) != currentWorld ) + } else if ((tmp = currentWorld->goInsideStructure(player)) != currentWorld) currentWorld = tmp; break; case SDLK_LSHIFT: @@ -1099,12 +1101,12 @@ EXIT: */ case SDL_KEYUP: - if ( SDL_KEY == SDLK_ESCAPE ) { + if (SDL_KEY == SDLK_ESCAPE) { currentMenu = &pauseMenu; player->save(); return; } - switch ( SDL_KEY ) { + switch (SDL_KEY) { case SDLK_F3: debug ^= true; break; @@ -1112,13 +1114,13 @@ EXIT: weather = WorldWeather::Rain; break; case SDLK_i: - if ( isCurrentWorldIndoors() && Indoorp(currentWorld)->isFloorAbove( player ) ) { + if (isCurrentWorldIndoors() && Indoorp(currentWorld)->isFloorAbove(player)) { player->loc.y += getIndoorWorldFloorHeight(); player->ground = false; } break; case SDLK_k: - if ( isCurrentWorldIndoors() && Indoorp(currentWorld)->isFloorBelow( player ) ) { + if (isCurrentWorldIndoors() && Indoorp(currentWorld)->isFloorBelow(player)) { player->loc.y -= getIndoorWorldFloorHeight(); player->ground = false; } @@ -1151,20 +1153,20 @@ EXIT: break; case SDLK_l: currentWorld->addLight({player->loc.x + SCREEN_WIDTH/2, player->loc.y},{1.0f,1.0f,1.0f}); - currentWorld->light.back().follow(player); - currentWorld->light.back().makeFlame(); + currentWorld->getLastLight()->follow(player); + currentWorld->getLastLight()->makeFlame(); break; case SDLK_f: currentWorld->addLight({player->loc.x + SCREEN_WIDTH/2, player->loc.y},{1.0f,1.0f,1.0f}); break; case SDLK_b: - if ( debug ) + if (debug) posFlag ^= true; else { currentWorld->addStructure(FIRE_PIT, player->loc.x, player->loc.y, "", ""); currentWorld->addLight({player->loc.x + SCREEN_WIDTH/2, player->loc.y},{1.0f,1.0f,1.0f}); - currentWorld->light.back().follow(currentWorld->build.back()); - currentWorld->light.back().makeFlame(); + currentWorld->getLastLight()->follow(currentWorld->build.back()); + currentWorld->getLastLight()->makeFlame(); } break; case SDLK_F12: @@ -1196,11 +1198,11 @@ EXIT: } // Flush preloaded AI functions if necessary - if ( !dialogBoxExists && AIpreaddr.size() ) { - while ( !AIpreaddr.empty() ) { - AIpreaddr.front()->addAIFunc( AIpreload.front(), false ); - AIpreaddr.erase( AIpreaddr.begin() ); - AIpreload.erase( AIpreload.begin() ); + if (!dialogBoxExists && AIpreaddr.size()) { + while (!AIpreaddr.empty()) { + AIpreaddr.front()->addAIFunc(AIpreload.front(), false); + AIpreaddr.erase(AIpreaddr.begin()); + AIpreload.erase(AIpreload.begin()); } } } @@ -1225,9 +1227,9 @@ EXIT: fadeWhite = true; fadeFast = true; - Mix_PlayChannel( 1, battleStart, 0 ); + Mix_PlayChannel(1, battleStart, 0); } - + void takeScreenshot(GLubyte* pixels){ std::vector bgr (SCREEN_WIDTH * SCREEN_HEIGHT * 3, 0); diff --git a/src/ui_menu.cpp b/src/ui_menu.cpp index 775ea81..9c7fc9d 100644 --- a/src/ui_menu.cpp +++ b/src/ui_menu.cpp @@ -6,9 +6,9 @@ extern Menu *currentMenu; extern Menu pauseMenu; void Menu:: -gotoParent( void ) +gotoParent(void) { - if ( !parent ) { + if (!parent) { currentMenu = NULL; config::update(); } else @@ -16,7 +16,7 @@ gotoParent( void ) } void Menu:: -gotoChild( void ) +gotoChild(void) { currentMenu = child; } @@ -78,7 +78,7 @@ namespace ui { return temp; } - void draw( void ) { + void draw(void) { SDL_Event e; setFontSize(24); diff --git a/src/world.cpp b/src/world.cpp index be8e682..434f619 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -98,20 +98,20 @@ const float bgDraw[4][3]={ */ void World:: -setBackground( WorldBGType bgt ) +setBackground(WorldBGType bgt) { // load textures with a limit check - switch ( (bgType = bgt) ) { + switch ((bgType = bgt)) { case WorldBGType::Forest: - bgTex = new Texturec( bgFiles ); + bgTex = new Texturec(bgFiles); break; case WorldBGType::WoodHouse: - bgTex = new Texturec( bgFilesIndoors ); + bgTex = new Texturec(bgFilesIndoors); break; default: - UserError( "Invalid world background type" ); + UserError("Invalid world background type"); break; } } @@ -124,23 +124,23 @@ setBackground( WorldBGType bgt ) */ void World:: -setStyle( std::string pre ) +setStyle(std::string pre) { unsigned int i; // get folder prefix std::string prefix = pre.empty() ? "assets/style/classic/" : pre; - for ( i = 0; i < arrAmt(buildPaths); i++ ) - sTexLoc.push_back( prefix + buildPaths[i] ); + for (i = 0; i < arrAmt(buildPaths); i++) + sTexLoc.push_back(prefix + buildPaths[i]); prefix += "bg/"; - for ( i = 0; i < arrAmt(bgPaths[0]); i++ ) - bgFiles.push_back( prefix + bgPaths[0][i] ); + for (i = 0; i < arrAmt(bgPaths[0]); i++) + bgFiles.push_back(prefix + bgPaths[0][i]); - for ( i = 0; i < arrAmt(bgPaths[1]); i++ ) - bgFilesIndoors.push_back( prefix + bgPaths[1][i] ); + for (i = 0; i < arrAmt(bgPaths[1]); i++) + bgFilesIndoors.push_back(prefix + bgPaths[1][i]); } /** @@ -152,7 +152,7 @@ setStyle( std::string pre ) */ World:: -World( void ) +World(void) { bgmObj = NULL; } @@ -165,13 +165,10 @@ World( void ) */ void World:: -deleteEntities( void ) +deleteEntities(void) { // free mobs - while ( !mob.empty() ) { - delete mob.back(); - mob.pop_back(); - } + mob.clear(); merchant.clear(); while(!npc.empty()){ @@ -180,16 +177,13 @@ deleteEntities( void ) } // free structures - while ( !build.empty() ) { + while (!build.empty()) { delete build.back(); build.pop_back(); } // free objects - while ( !object.empty() ) { - delete object.back(); - object.pop_back(); - } + object.clear(); // clear entity array entity.clear(); @@ -201,10 +195,7 @@ deleteEntities( void ) light.clear(); // free villages - while ( !village.empty() ) { - delete village.back(); - village.pop_back(); - } + village.clear(); } /** @@ -215,7 +206,7 @@ deleteEntities( void ) */ World:: -~World( void ) +~World(void) { // sdl2_mixer's object if(bgmObj) @@ -233,7 +224,7 @@ World:: */ void World:: -generate( unsigned int width ) +generate(unsigned int width) { // iterator for `for` loops std::vector::iterator wditer; @@ -242,7 +233,7 @@ generate( unsigned int width ) float geninc = 0; // check for valid width - if ( (int)width <= 0 ) + if ((int)width <= 0) UserError("Invalid world dimensions"); // allocate space for world @@ -260,9 +251,9 @@ generate( unsigned int width ) // create slopes from the points that were just defined, populate the rest of the WorldData structure for(wditer = worldData.begin() + 1; wditer != worldData.end(); wditer++){ - if ( (*wditer).groundHeight && wditer + GROUND_HILLINESS < worldData.end() ) + if ((*wditer).groundHeight && wditer + GROUND_HILLINESS < worldData.end()) // wditer + GROUND_HILLINESS can go out of bounds (invalid read) - geninc = ( (*(wditer + GROUND_HILLINESS)).groundHeight - (*wditer).groundHeight ) / (float)GROUND_HILLINESS; + geninc = ((*(wditer + GROUND_HILLINESS)).groundHeight - (*wditer).groundHeight) / (float)GROUND_HILLINESS; else (*wditer).groundHeight = (*(wditer - 1)).groundHeight + geninc; @@ -272,12 +263,12 @@ generate( unsigned int width ) (*wditer).grassHeight[1] = (randGet() % 16) / 3 + 2; // bound checks - if ( (*wditer).groundHeight < GROUND_HEIGHT_MINIMUM ) + if ((*wditer).groundHeight < GROUND_HEIGHT_MINIMUM) (*wditer).groundHeight = GROUND_HEIGHT_MINIMUM; - else if ( (*wditer).groundHeight > GROUND_HEIGHT_MAXIMUM ) + else if ((*wditer).groundHeight > GROUND_HEIGHT_MAXIMUM) (*wditer).groundHeight = GROUND_HEIGHT_MAXIMUM; - if( (*wditer).groundHeight <= 0 ) + if((*wditer).groundHeight <= 0) (*wditer).groundHeight = GROUND_HEIGHT_MINIMUM; } @@ -286,8 +277,8 @@ generate( unsigned int width ) worldStart = (width - GROUND_HILLINESS) * HLINE / 2 * -1; // create empty star array, should be filled here as well... - star = std::vector (100, vec2 { 0, 400 } ); - for ( auto &s : star ) { + star = std::vector (100, vec2 { 0, 400 }); + for (auto &s : star) { s.x = (getRand() % (-worldStart * 2)) + worldStart; s.y = (getRand() % SCREEN_HEIGHT) + 100.0f; } @@ -300,43 +291,43 @@ generate( unsigned int width ) */ void World:: -update( Player *p, unsigned int delta ) +update(Player *p, unsigned int delta) { // update player coords p->loc.y += p->vel.y * delta; p->loc.x +=(p->vel.x * p->speed) * delta; - if ( p->loc.y > 5000 ) + if (p->loc.y > 5000) UserError("Too high for me m8."); // update entity coords - for ( auto &e : entity ) { + for (auto &e : entity) { // dont let structures move? - if ( e->type != STRUCTURET && e->canMove ) { + if (e->type != STRUCTURET && e->canMove) { e->loc.x += e->vel.x * delta; e->loc.y += e->vel.y * delta; // update boolean directions - if ( e->vel.x < 0 ) + if (e->vel.x < 0) e->left = true; - else if ( e->vel.x > 0 ) + else if (e->vel.x > 0) e->left = false; - } else if ( e->vel.y < 0 ) + } else if (e->vel.y < 0) e->loc.y += e->vel.y * delta; } // iterate through particles - particles.erase( std::remove_if( particles.begin(), particles.end(), [&delta](Particles &part){return part.kill(delta);}), particles.end()); - for ( auto part = particles.begin(); part != particles.end(); part++ ) { - if ( (*part).canMove ) { + particles.erase(std::remove_if(particles.begin(), particles.end(), [&delta](Particles &part){return part.kill(delta);}), particles.end()); + for (auto part = particles.begin(); part != particles.end(); part++) { + if ((*part).canMove) { (*part).loc.y += (*part).vel.y * delta; (*part).loc.x += (*part).vel.x * delta; - for ( auto &b : build ) { - if ( b->bsubtype == FOUNTAIN ) { - if ( (*part).loc.x >= b->loc.x && (*part).loc.x <= b->loc.x + b->width ) { - if ( (*part).loc.y <= b->loc.y + b->height * .25) - particles.erase( part ); + for (auto &b : build) { + if (b->bsubtype == FOUNTAIN) { + if ((*part).loc.x >= b->loc.x && (*part).loc.x <= b->loc.x + b->width) { + if ((*part).loc.y <= b->loc.y + b->height * .25) + particles.erase(part); } } @@ -345,9 +336,9 @@ update( Player *p, unsigned int delta ) } // handle music fades - if ( ui::dialogImportant ) { + if (ui::dialogImportant) { //Mix_FadeOutMusic(2000); - } else if( !Mix_PlayingMusic() ) + } else if(!Mix_PlayingMusic()) Mix_FadeInMusic(bgmObj,-1,2000); } @@ -359,10 +350,10 @@ update( Player *p, unsigned int delta ) */ void World:: -setBGM( std::string path ) +setBGM(std::string path) { - if( !path.empty() ) - bgmObj = Mix_LoadMUS( (bgm = path).c_str() ); + if(!path.empty()) + bgmObj = Mix_LoadMUS((bgm = path).c_str()); } /** @@ -372,18 +363,18 @@ setBGM( std::string path ) */ void World:: -bgmPlay( World *prev ) const +bgmPlay(World *prev) const { - if ( prev ) { - if ( bgm != prev->bgm ) { + if (prev) { + if (bgm != prev->bgm) { // new world, new music - Mix_FadeOutMusic( 800 ); - Mix_PlayMusic( bgmObj, -1 ); + Mix_FadeOutMusic(800); + Mix_PlayMusic(bgmObj, -1); } } else { // first call - Mix_FadeOutMusic( 800 ); - Mix_PlayMusic( bgmObj, -1 ); + Mix_FadeOutMusic(800); + Mix_PlayMusic(bgmObj, -1); } } @@ -409,22 +400,22 @@ void World::draw(Player *p){ // shade value for GLSL float shadeAmbient = -worldShade / 50.0f + 0.5f; // -0.5f to 1.5f - if ( shadeAmbient < 0 ) + if (shadeAmbient < 0) shadeAmbient = 0; - else if ( shadeAmbient > 0.9f ) + else if (shadeAmbient > 0.9f) shadeAmbient = 1; /* * Draw background images. */ - glEnable( GL_TEXTURE_2D ); + glEnable(GL_TEXTURE_2D); // the sunny wallpaper is faded with the night depending on tickCount - bgTex->bind( 0 ); + bgTex->bind(0); int alpha; - switch( weather ) { + switch(weather) { case WorldWeather::Snowy: alpha = 150; break; @@ -435,36 +426,36 @@ void World::draw(Player *p){ alpha = 255 - worldShade * 4; break; } - safeSetColorA( 255, 255, 255, alpha ); + safeSetColorA(255, 255, 255, alpha); - glBegin( GL_QUADS ); - glTexCoord2i( 0, 0 ); glVertex2i( offset.x - SCREEN_WIDTH/2-5, offset.y + SCREEN_HEIGHT/2 ); - glTexCoord2i( 1, 0 ); glVertex2i( offset.x + SCREEN_WIDTH/2+5, offset.y + SCREEN_HEIGHT/2 ); - glTexCoord2i( 1, 1 ); glVertex2i( offset.x + SCREEN_WIDTH/2+5, offset.y - SCREEN_HEIGHT/2 ); - glTexCoord2i( 0, 1 ); glVertex2i( offset.x - SCREEN_WIDTH/2-5, offset.y - SCREEN_HEIGHT/2 ); + glBegin(GL_QUADS); + glTexCoord2i(0, 0); glVertex2i(offset.x - SCREEN_WIDTH/2-5, offset.y + SCREEN_HEIGHT/2); + glTexCoord2i(1, 0); glVertex2i(offset.x + SCREEN_WIDTH/2+5, offset.y + SCREEN_HEIGHT/2); + glTexCoord2i(1, 1); glVertex2i(offset.x + SCREEN_WIDTH/2+5, offset.y - SCREEN_HEIGHT/2); + glTexCoord2i(0, 1); glVertex2i(offset.x - SCREEN_WIDTH/2-5, offset.y - SCREEN_HEIGHT/2); glEnd(); bgTex->bindNext(); - safeSetColorA( 255, 255, 255, !alpha ? 255 : worldShade * 4); + safeSetColorA(255, 255, 255, !alpha ? 255 : worldShade * 4); - glBegin( GL_QUADS ); - glTexCoord2i( 0, 0 ); glVertex2i( offset.x - SCREEN_WIDTH/2-5, offset.y + SCREEN_HEIGHT/2 ); - glTexCoord2i( 1, 0 ); glVertex2i( offset.x + SCREEN_WIDTH/2+5, offset.y + SCREEN_HEIGHT/2 ); - glTexCoord2i( 1, 1 ); glVertex2i( offset.x + SCREEN_WIDTH/2+5, offset.y - SCREEN_HEIGHT/2 ); - glTexCoord2i( 0, 1 ); glVertex2i( offset.x - SCREEN_WIDTH/2-5, offset.y - SCREEN_HEIGHT/2 ); + glBegin(GL_QUADS); + glTexCoord2i(0, 0); glVertex2i(offset.x - SCREEN_WIDTH/2-5, offset.y + SCREEN_HEIGHT/2); + glTexCoord2i(1, 0); glVertex2i(offset.x + SCREEN_WIDTH/2+5, offset.y + SCREEN_HEIGHT/2); + glTexCoord2i(1, 1); glVertex2i(offset.x + SCREEN_WIDTH/2+5, offset.y - SCREEN_HEIGHT/2); + glTexCoord2i(0, 1); glVertex2i(offset.x - SCREEN_WIDTH/2-5, offset.y - SCREEN_HEIGHT/2); glEnd(); - glDisable( GL_TEXTURE_2D ); + glDisable(GL_TEXTURE_2D); // draw the stars if the time deems it appropriate - //if (((( weather == WorldWeather::Dark ) & ( tickCount % DAY_CYCLE )) < DAY_CYCLE / 2) || - // ((( weather == WorldWeather::Sunny ) & ( tickCount % DAY_CYCLE )) > DAY_CYCLE * .75) ){ - if ( worldShade > 0 ) { + //if ((((weather == WorldWeather::Dark) & (tickCount % DAY_CYCLE)) < DAY_CYCLE / 2) || + // (((weather == WorldWeather::Sunny) & (tickCount % DAY_CYCLE)) > DAY_CYCLE * .75)){ + if (worldShade > 0) { - safeSetColorA( 255, 255, 255, 255 - (getRand() % 30 - 15) ); + safeSetColorA(255, 255, 255, 255 - (getRand() % 30 - 15)); - for ( i = 0; i < 100; i++ ) { + for (i = 0; i < 100; i++) { glRectf(star[i].x + offset.x * .9, star[i].y, star[i].x + offset.x * .9 + HLINE, @@ -475,40 +466,40 @@ void World::draw(Player *p){ // draw remaining background items - glEnable( GL_TEXTURE_2D ); + glEnable(GL_TEXTURE_2D); bgTex->bindNext(); - safeSetColorA( 150 + shadeBackground * 2, 150 + shadeBackground * 2, 150 + shadeBackground * 2, 255 ); - - glBegin( GL_QUADS ); - for ( i = 0; i <= (int)(worldData.size() * HLINE / 1920); i++ ) { - glTexCoord2i( 0, 1 ); glVertex2i( width / 2 * -1 + (1920 * i ) + offset.x * .85, GROUND_HEIGHT_MINIMUM ); - glTexCoord2i( 1, 1 ); glVertex2i( width / 2 * -1 + (1920 * (i + 1)) + offset.x * .85, GROUND_HEIGHT_MINIMUM ); - glTexCoord2i( 1, 0 ); glVertex2i( width / 2 * -1 + (1920 * (i + 1)) + offset.x * .85, GROUND_HEIGHT_MINIMUM + 1080 ); - glTexCoord2i( 0, 0 ); glVertex2i( width / 2 * -1 + (1920 * i ) + offset.x * .85, GROUND_HEIGHT_MINIMUM + 1080 ); + safeSetColorA(150 + shadeBackground * 2, 150 + shadeBackground * 2, 150 + shadeBackground * 2, 255); + + glBegin(GL_QUADS); + for (i = 0; i <= (int)(worldData.size() * HLINE / 1920); i++) { + glTexCoord2i(0, 1); glVertex2i(width / 2 * -1 + (1920 * i) + offset.x * .85, GROUND_HEIGHT_MINIMUM); + glTexCoord2i(1, 1); glVertex2i(width / 2 * -1 + (1920 * (i + 1)) + offset.x * .85, GROUND_HEIGHT_MINIMUM); + glTexCoord2i(1, 0); glVertex2i(width / 2 * -1 + (1920 * (i + 1)) + offset.x * .85, GROUND_HEIGHT_MINIMUM + 1080); + glTexCoord2i(0, 0); glVertex2i(width / 2 * -1 + (1920 * i) + offset.x * .85, GROUND_HEIGHT_MINIMUM + 1080); } glEnd(); - for ( i = 0; i < 4; i++ ) { + for (i = 0; i < 4; i++) { bgTex->bindNext(); - safeSetColorA( bgDraw[i][0] + shadeBackground * 2, bgDraw[i][0] + shadeBackground * 2, bgDraw[i][0] + shadeBackground * 2, bgDraw[i][1] ); - - glBegin( GL_QUADS ); - for( int j = worldStart; j <= -worldStart; j += 600 ){ - glTexCoord2i( 0, 1 ); glVertex2i( j + offset.x * bgDraw[i][2], GROUND_HEIGHT_MINIMUM ); - glTexCoord2i( 1, 1 ); glVertex2i( (j + 600) + offset.x * bgDraw[i][2], GROUND_HEIGHT_MINIMUM ); - glTexCoord2i( 1, 0 ); glVertex2i( (j + 600) + offset.x * bgDraw[i][2], GROUND_HEIGHT_MINIMUM + 400 ); - glTexCoord2i( 0, 0 ); glVertex2i( j + offset.x * bgDraw[i][2], GROUND_HEIGHT_MINIMUM + 400 ); + safeSetColorA(bgDraw[i][0] + shadeBackground * 2, bgDraw[i][0] + shadeBackground * 2, bgDraw[i][0] + shadeBackground * 2, bgDraw[i][1]); + + glBegin(GL_QUADS); + for(int j = worldStart; j <= -worldStart; j += 600){ + glTexCoord2i(0, 1); glVertex2i(j + offset.x * bgDraw[i][2], GROUND_HEIGHT_MINIMUM); + glTexCoord2i(1, 1); glVertex2i((j + 600) + offset.x * bgDraw[i][2], GROUND_HEIGHT_MINIMUM); + glTexCoord2i(1, 0); glVertex2i((j + 600) + offset.x * bgDraw[i][2], GROUND_HEIGHT_MINIMUM + 400); + glTexCoord2i(0, 0); glVertex2i(j + offset.x * bgDraw[i][2], GROUND_HEIGHT_MINIMUM + 400); } glEnd(); } - glDisable( GL_TEXTURE_2D ); + glDisable(GL_TEXTURE_2D); // draw black under backgrounds - glColor3ub( 0, 0, 0 ); - glRectf( worldStart, GROUND_HEIGHT_MINIMUM, -worldStart, 0 ); + glColor3ub(0, 0, 0); + glRectf(worldStart, GROUND_HEIGHT_MINIMUM, -worldStart, 0); pOffset = (offset.x + p->width / 2 - worldStart) / HLINE; @@ -534,14 +525,14 @@ void World::draw(Player *p){ glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0); glUseProgram(shaderProgram); - std::for_each( particles.begin(), particles.end(), [](Particles part) { if ( part.behind ) part.draw(); }); + std::for_each(particles.begin(), particles.end(), [](Particles part) { if (part.behind) part.draw(); }); glUseProgram(0); - for ( auto &b : build ) { - if ( b->bsubtype == STALL_MARKET ) { - for ( auto &n : npc ) { - if ( n->type == MERCHT && ((Merchant *)n)->inside == b ) { + for (auto &b : build) { + if (b->bsubtype == STALL_MARKET) { + for (auto &n : npc) { + if (n->type == MERCHT && ((Merchant *)n)->inside == b) { n->draw(); break; } @@ -552,9 +543,9 @@ void World::draw(Player *p){ // draw light elements? - glEnable( GL_TEXTURE_2D ); + glEnable(GL_TEXTURE_2D); - glActiveTexture( GL_TEXTURE0 ); + glActiveTexture(GL_TEXTURE0); bgTex->bindNext(); for(auto &l : light){ @@ -585,22 +576,22 @@ void World::draw(Player *p){ } } - for ( uint i = 0; i < light.size(); i++ ) + for (uint i = 0; i < light.size(); i++) flameArray[i] = light[i].fireFlicker; - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glUseProgram( shaderProgram ); - glUniform1i( glGetUniformLocation( shaderProgram, "sampler"), 0 ); - glUniform1f( glGetUniformLocation( shaderProgram, "amb" ), shadeAmbient ); + glUseProgram(shaderProgram); + glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0); + glUniform1f(glGetUniformLocation(shaderProgram, "amb"), shadeAmbient); - if ( light.size() == 0) - glUniform1i( glGetUniformLocation( shaderProgram, "numLight"), 0); + if (light.size() == 0) + glUniform1i(glGetUniformLocation(shaderProgram, "numLight"), 0); else { - glUniform1i ( glGetUniformLocation( shaderProgram, "numLight" ), light.size()); - glUniform2fv( glGetUniformLocation( shaderProgram, "lightLocation"), light.size(), pointArray ); - glUniform3f ( glGetUniformLocation( shaderProgram, "lightColor" ), 1.0f, 1.0f, 1.0f ); + glUniform1i (glGetUniformLocation(shaderProgram, "numLight"), light.size()); + glUniform2fv(glGetUniformLocation(shaderProgram, "lightLocation"), light.size(), pointArray); + glUniform3f (glGetUniformLocation(shaderProgram, "lightColor"), 1.0f, 1.0f, 1.0f); glUniform1fv(glGetUniformLocation(shaderProgram,"fireFlicker"), light.size(),flameArray); } @@ -608,7 +599,7 @@ void World::draw(Player *p){ * Draw the dirt. */ - glBegin( GL_QUADS ); + glBegin(GL_QUADS); // faulty /*glTexCoord2i(0 ,0);glVertex2i(pOffset - (SCREEN_WIDTH / 1.5),0); @@ -616,20 +607,20 @@ void World::draw(Player *p){ glTexCoord2i(64,1);glVertex2i(pOffset + (SCREEN_WIDTH / 1.5),GROUND_HEIGHT_MINIMUM); glTexCoord2i(0 ,1);glVertex2i(pOffset - (SCREEN_WIDTH / 1.5),GROUND_HEIGHT_MINIMUM);*/ - for ( i = iStart; i < iEnd; i++ ) { - if ( worldData[i].groundHeight <= 0 ) { + for (i = iStart; i < iEnd; i++) { + if (worldData[i].groundHeight <= 0) { worldData[i].groundHeight = GROUND_HEIGHT_MINIMUM - 1; - glColor4ub( 0, 0, 0, 255 ); + glColor4ub(0, 0, 0, 255); } else - safeSetColorA( 150, 150, 150, 255 ); + safeSetColorA(150, 150, 150, 255); - glTexCoord2i( 0, 0 ); glVertex2i(worldStart + i * HLINE , worldData[i].groundHeight - GRASS_HEIGHT ); - glTexCoord2i( 1, 0 ); glVertex2i(worldStart + i * HLINE + HLINE , worldData[i].groundHeight - GRASS_HEIGHT ); + glTexCoord2i(0, 0); glVertex2i(worldStart + i * HLINE , worldData[i].groundHeight - GRASS_HEIGHT); + glTexCoord2i(1, 0); glVertex2i(worldStart + i * HLINE + HLINE , worldData[i].groundHeight - GRASS_HEIGHT); - glTexCoord2i( 1, (int)(worldData[i].groundHeight / 64) + worldData[i].groundColor ); glVertex2i(worldStart + i * HLINE + HLINE, 0 ); - glTexCoord2i( 0, (int)(worldData[i].groundHeight / 64) + worldData[i].groundColor ); glVertex2i(worldStart + i * HLINE , 0 ); + glTexCoord2i(1, (int)(worldData[i].groundHeight / 64) + worldData[i].groundColor); glVertex2i(worldStart + i * HLINE + HLINE, 0); + glTexCoord2i(0, (int)(worldData[i].groundHeight / 64) + worldData[i].groundColor); glVertex2i(worldStart + i * HLINE , 0); - if ( worldData[i].groundHeight == GROUND_HEIGHT_MINIMUM - 1 ) + if (worldData[i].groundHeight == GROUND_HEIGHT_MINIMUM - 1) worldData[i].groundHeight = 0; } @@ -642,42 +633,42 @@ void World::draw(Player *p){ * Draw the grass/the top of the ground. */ - glEnable( GL_TEXTURE_2D ); + glEnable(GL_TEXTURE_2D); - glActiveTexture( GL_TEXTURE0 ); + glActiveTexture(GL_TEXTURE0); bgTex->bindNext(); - glUseProgram( shaderProgram ); - glUniform1i( glGetUniformLocation( shaderProgram, "sampler"), 0); + glUseProgram(shaderProgram); + glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0); float cgh[2]; - for ( i = iStart; i < iEnd - GROUND_HILLINESS; i++ ) { + for (i = iStart; i < iEnd - GROUND_HILLINESS; i++) { // load the current line's grass values - if ( worldData[i].groundHeight ) - memcpy( cgh, worldData[i].grassHeight, 2 * sizeof( float )); + if (worldData[i].groundHeight) + memcpy(cgh, worldData[i].grassHeight, 2 * sizeof(float)); else - memset( cgh, 0 , 2 * sizeof( float )); + memset(cgh, 0 , 2 * sizeof(float)); // flatten the grass if the player is standing on it. - if( !worldData[i].grassUnpressed ){ + if(!worldData[i].grassUnpressed){ cgh[0] /= 4; cgh[1] /= 4; } // actually draw the grass. - safeSetColorA( 255, 255, 255, 255 ); - - glBegin( GL_QUADS ); - glTexCoord2i( 0, 0 ); glVertex2i( worldStart + i * HLINE , worldData[i].groundHeight + cgh[0] ); - glTexCoord2i( 1, 0 ); glVertex2i( worldStart + i * HLINE + HLINE / 2, worldData[i].groundHeight + cgh[0] ); - glTexCoord2i( 1, 1 ); glVertex2i( worldStart + i * HLINE + HLINE / 2, worldData[i].groundHeight - GRASS_HEIGHT ); - glTexCoord2i( 0, 1 ); glVertex2i( worldStart + i * HLINE , worldData[i].groundHeight - GRASS_HEIGHT ); - glTexCoord2i( 0, 0 ); glVertex2i( worldStart + i * HLINE + HLINE / 2, worldData[i].groundHeight + cgh[1] ); - glTexCoord2i( 1, 0 ); glVertex2i( worldStart + i * HLINE + HLINE , worldData[i].groundHeight + cgh[1] ); - glTexCoord2i( 1, 1 ); glVertex2i( worldStart + i * HLINE + HLINE , worldData[i].groundHeight - GRASS_HEIGHT ); - glTexCoord2i( 0, 1 ); glVertex2i( worldStart + i * HLINE + HLINE / 2, worldData[i].groundHeight - GRASS_HEIGHT ); + safeSetColorA(255, 255, 255, 255); + + glBegin(GL_QUADS); + glTexCoord2i(0, 0); glVertex2i(worldStart + i * HLINE , worldData[i].groundHeight + cgh[0]); + glTexCoord2i(1, 0); glVertex2i(worldStart + i * HLINE + HLINE / 2, worldData[i].groundHeight + cgh[0]); + glTexCoord2i(1, 1); glVertex2i(worldStart + i * HLINE + HLINE / 2, worldData[i].groundHeight - GRASS_HEIGHT); + glTexCoord2i(0, 1); glVertex2i(worldStart + i * HLINE , worldData[i].groundHeight - GRASS_HEIGHT); + glTexCoord2i(0, 0); glVertex2i(worldStart + i * HLINE + HLINE / 2, worldData[i].groundHeight + cgh[1]); + glTexCoord2i(1, 0); glVertex2i(worldStart + i * HLINE + HLINE , worldData[i].groundHeight + cgh[1]); + glTexCoord2i(1, 1); glVertex2i(worldStart + i * HLINE + HLINE , worldData[i].groundHeight - GRASS_HEIGHT); + glTexCoord2i(0, 1); glVertex2i(worldStart + i * HLINE + HLINE / 2, worldData[i].groundHeight - GRASS_HEIGHT); glEnd(); } @@ -695,34 +686,34 @@ void World::draw(Player *p){ glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0); glUseProgram(shaderProgram); - std::for_each( particles.begin(), particles.end(), [](Particles part) { if ( !part.behind ) part.draw(); }); + std::for_each(particles.begin(), particles.end(), [](Particles part) { if (!part.behind) part.draw(); }); glUseProgram(0); - for ( auto &n : npc ) { - if ( n->type != MERCHT ) + for (auto &n : npc) { + if (n->type != MERCHT) n->draw(); } - for ( auto &m : mob ) - m->draw(); + for (auto &m : mob) + m.draw(); - for ( auto &o : object ) - o->draw(); + for (auto &o : object) + o.draw(); /* * Handle grass-squishing. */ // calculate the line that the player is on - int ph = ( p->loc.x + p->width / 2 - worldStart ) / HLINE; + int ph = (p->loc.x + p->width / 2 - worldStart) / HLINE; // flatten grass under the player if the player is on the ground - if ( p->ground ) { - for ( i = 0; i < (int)(worldData.size() - GROUND_HILLINESS); i++ ) - worldData[i].grassUnpressed = !( i < ph + 6 && i > ph - 6 ); + if (p->ground) { + for (i = 0; i < (int)(worldData.size() - GROUND_HILLINESS); i++) + worldData[i].grassUnpressed = !(i < ph + 6 && i > ph - 6); } else { - for ( i = 0; i < (int)(worldData.size() - GROUND_HILLINESS); i++ ) + for (i = 0; i < (int)(worldData.size() - GROUND_HILLINESS); i++) worldData[i].grassUnpressed = true; } @@ -741,7 +732,7 @@ void World::draw(Player *p){ */ void World:: -singleDetect( Entity *e ) +singleDetect(Entity *e) { std::string killed; unsigned int i,j; @@ -751,12 +742,12 @@ singleDetect( Entity *e ) * Kill any dead entities. */ - if ( e->alive && e->health <= 0 ) { + if (e->alive && e->health <= 0) { e->alive = false; e->health = 0; - for ( i = 0; i < entity.size(); i++) { - if ( entity[i] == e ){ - switch ( e->type ) { + for (i = 0; i < entity.size(); i++) { + if (entity[i] == e){ + switch (e->type) { case STRUCTURET: killed = "structure"; for(j=0;jname << "." << std::endl; - exit( 0 ); + exit(0); } // handle only living entities - if ( e->alive ) { + if (e->alive) { // forced movement gravity - if ( e->forcedMove ) { - if ( e->vel.x > .0005 || e->vel.x < -.0005 ) + if (e->forcedMove) { + if (e->vel.x > .0005 || e->vel.x < -.0005) e->vel.x *= .6; else e->forcedMove = false; } - if ( e->type == MOBT && Mobp(e)->subtype == MS_TRIGGER ) + if (e->type == MOBT && Mobp(e)->subtype == MS_TRIGGER) return; // calculate the line that this entity is currently standing on l = (e->loc.x + e->width / 2 - worldStart) / HLINE; - if ( l < 0 ) + if (l < 0) l = 0; i = l; - if ( i > lineCount - 1 ) + if (i > lineCount - 1) i = lineCount - 1; // if the entity is under the world/line, pop it back to the surface - if ( e->loc.y < worldData[i].groundHeight ) { + if (e->loc.y < worldData[i].groundHeight) { int dir = e->vel.x < 0 ? -1 : 1; - if ( i + (dir * 2) < worldData.size() && worldData[i + (dir * 2)].groundHeight - 30 > worldData[i + dir].groundHeight ) { - e->loc.x -= ( PLAYER_SPEED_CONSTANT + 2.7 ) * e->speed * 2 * dir; + if (i + (dir * 2) < worldData.size() && worldData[i + (dir * 2)].groundHeight - 30 > worldData[i + dir].groundHeight) { + e->loc.x -= (PLAYER_SPEED_CONSTANT + 2.7) * e->speed * 2 * dir; e->vel.x = 0; } else { e->loc.y = worldData[i].groundHeight - .001 * deltaTime; @@ -848,12 +838,12 @@ singleDetect( Entity *e ) // handle gravity if the entity is above the line else { - if ( e->type == STRUCTURET ) { + if (e->type == STRUCTURET) { e->loc.y = worldData[i].groundHeight; e->vel.y = 0; e->ground = true; return; - } else if ( e->vel.y > -2 ) + } else if (e->vel.y > -2) e->vel.y -= GRAVITY_CONSTANT * deltaTime; } @@ -880,37 +870,37 @@ singleDetect( Entity *e ) */ void World:: -detect( Player *p ) +detect(Player *p) { int l; // handle the player - std::thread( &World::singleDetect, this, p ).detach(); + std::thread(&World::singleDetect, this, p).detach(); // handle other entities - for ( auto &e : entity ) - std::thread( &World::singleDetect, this, e ).detach(); + for (auto &e : entity) + std::thread(&World::singleDetect, this, e).detach(); // handle particles - for ( auto &part : particles ) { + for (auto &part : particles) { // get particle's current world line l = (part.loc.x + part.width / 2 - worldStart) / HLINE; - if ( l < 0 ) + if (l < 0) l = 0; - if ( l > (int)(lineCount - 1) ) + if (l > (int)(lineCount - 1)) l = lineCount - 1; - part.update( GRAVITY_CONSTANT, worldData[l].groundHeight ); + part.update(GRAVITY_CONSTANT, worldData[l].groundHeight); } // handle particle creation - for ( auto &b : build ) { - switch ( b->bsubtype ) { + for (auto &b : build) { + switch (b->bsubtype) { case FOUNTAIN: - for ( unsigned int r = (randGet() % 25) + 11; r--; ) { + for (unsigned int r = (randGet() % 25) + 11; r--;) { addParticle(randGet() % HLINE * 3 + b->loc.x + b->width / 2, // x b->loc.y + b->height, // y HLINE * 1.25, // width @@ -926,7 +916,7 @@ detect( Player *p ) break; case FIRE_PIT: - for(unsigned int r = (randGet() % 20) + 11; r--; ) { + for(unsigned int r = (randGet() % 20) + 11; r--;) { addParticle(randGet() % (int)(b->width / 2) + b->loc.x + b->width / 4, // x b->loc.y + 3 * HLINE, // y HLINE, // width @@ -948,14 +938,14 @@ detect( Player *p ) } // draws the village welcome message if the player enters the village bounds - for ( auto &v : village ) { - if ( p->loc.x > v->start.x && p->loc.x < v->end.x ) { - if ( !v->in ) { - ui::passiveImportantText( 5000, "Welcome to %s", v->name.c_str() ); - v->in = true; + for (auto &v : village) { + if (p->loc.x > v.start.x && p->loc.x < v.end.x) { + if (!v.in) { + ui::passiveImportantText(5000, "Welcome to %s", v.name.c_str()); + v.in = true; } } else - v->in = false; + v.in = false; } } @@ -971,19 +961,26 @@ void World::addStructure(BUILD_SUB sub, float x,float y, std::string tex, std::s entity.push_back(build.back()); } +Village *World:: +addVillage(std::string name, World *world) +{ + village.emplace_back(name.c_str(), world); + return &village.back(); +} + void World::addMob(int t,float x,float y){ - mob.push_back(new Mob(t)); - mob.back()->spawn(x,y); + mob.emplace_back(t); + mob.back().spawn(x,y); - entity.push_back(mob.back()); + entity.push_back(&mob.back()); } void World::addMob(int t,float x,float y,void (*hey)(Mob *)){ - mob.push_back(new Mob(t)); - mob.back()->spawn(x,y); - mob.back()->hey = hey; + mob.emplace_back(t); + mob.back().spawn(x,y); + mob.back().hey = hey; - entity.push_back(mob.back()); + entity.push_back(&mob.back()); } void World::addNPC(float x,float y){ @@ -1001,57 +998,91 @@ void World::addMerchant(float x, float y){ entity.push_back(npc.back()); } -void World::addObject( std::string in, std::string p, float x, float y){ - object.push_back(new Object(in,p)); - object.back()->spawn(x,y); +void World::addObject(std::string in, std::string p, float x, float y){ + object.emplace_back(in, p); + object.back().spawn(x, y); - entity.push_back(object.back()); + entity.push_back(&object.back()); } void World:: -addParticle( float x, float y, float w, float h, float vx, float vy, Color color, int d ) +addParticle(float x, float y, float w, float h, float vx, float vy, Color color, int d) { - particles.emplace_back( x, y, w, h, vx, vy, color, d ); + particles.emplace_back(x, y, w, h, vx, vy, color, d); particles.back().canMove = true; } void World:: -addParticle( float x, float y, float w, float h, float vx, float vy, Color color, int d, bool gravity ) +addParticle(float x, float y, float w, float h, float vx, float vy, Color color, int d, unsigned char flags) { - particles.emplace_back( x, y, w, h, vx, vy, color, d ); + particles.emplace_back(x, y, w, h, vx, vy, color, d); particles.back().canMove = true; - particles.back().gravity = gravity; + particles.back().gravity = flags & (1 << 0); + particles.back().bounce = flags & (1 << 1); } void World:: -addLight( vec2 loc, Color color ) +addLight(vec2 loc, Color color) +{ + if (light.size() < 64) + light.push_back(Light(loc, color, 1)); +} + +Light *World:: +getLastLight(void) +{ + return &light.back(); +} + +Mob *World:: +getLastMob(void) +{ + return &mob.back(); +} + +std::string World:: +getSTextureLocation(unsigned int index) const { - if ( light.size() < 64 ) - light.push_back( Light( loc, color, 1 ) ); + if (index > sTexLoc.size()) + return ""; + + return sTexLoc[ index ]; } std::string World:: -setToLeft( std::string file ) +setToLeft(std::string file) { return (toLeft = file); } std::string World:: -setToRight( std::string file ) +setToRight(std::string file) { return (toRight = file); } +std::string World:: +getToLeft(void) const +{ + return toLeft; +} + +std::string World:: +getToRight(void) const +{ + return toRight; +} + World *World:: -goWorldLeft( Player *p ) +goWorldLeft(Player *p) { World *tmp; // check if player is at world edge - if( !toLeft.empty() && p->loc.x < worldStart + HLINE * 15.0f ) { + if(!toLeft.empty() && p->loc.x < worldStart + HLINE * 15.0f) { // load world (`toLeft` conditional confirms existance) - tmp = loadWorldFromPtr( currentWorldToLeft ); + tmp = loadWorldFromPtr(currentWorldToLeft); // adjust player location p->loc.x = tmp->worldStart + HLINE * 20; @@ -1064,10 +1095,10 @@ goWorldLeft( Player *p ) } bool World:: -goWorldLeft( NPC *e ) +goWorldLeft(NPC *e) { // check if entity is at world edge - if( !toLeft.empty() && e->loc.x < worldStart + HLINE * 15.0f ) { + if(!toLeft.empty() && e->loc.x < worldStart + HLINE * 15.0f) { currentWorldToLeft->addNPC(e->loc.x,e->loc.y); e->alive = false; @@ -1082,12 +1113,12 @@ goWorldLeft( NPC *e ) } World *World:: -goWorldRight( Player *p ) +goWorldRight(Player *p) { World *tmp; - if( !toRight.empty() && p->loc.x + p->width > -worldStart - HLINE * 15 ) { - tmp = loadWorldFromPtr( currentWorldToRight ); + if(!toRight.empty() && p->loc.x + p->width > -worldStart - HLINE * 15) { + tmp = loadWorldFromPtr(currentWorldToRight); p->loc.x = tmp->worldStart - HLINE * -15.0f; p->loc.y = GROUND_HEIGHT_MINIMUM; @@ -1099,22 +1130,22 @@ goWorldRight( Player *p ) } World *World:: -goInsideStructure( Player *p ) +goInsideStructure(Player *p) { World *tmp; std::string current; - if ( inside.empty() ) { - for ( auto &b : build ) { - if ( p->loc.x > b->loc.x && - p->loc.x + p->width < b->loc.x + b->width ) { + if (inside.empty()) { + for (auto &b : build) { + if (p->loc.x > b->loc.x && + p->loc.x + p->width < b->loc.x + b->width) { - if ( b->inside.empty() ) + if (b->inside.empty()) return this; inside.push_back(currentXML.c_str() + xmlFolder.size()); - tmp = loadWorldFromXML( b->inside ); + tmp = loadWorldFromXML(b->inside); ui::toggleBlackFast(); ui::waitForCover(); @@ -1127,9 +1158,9 @@ goInsideStructure( Player *p ) } } else { current = currentXML.c_str() + xmlFolder.size(); - tmp = loadWorldFromXML( inside.back() ); - for ( auto &b : tmp->build ) { - if ( current == b->inside ) { + tmp = loadWorldFromXML(inside.back()); + for (auto &b : tmp->build) { + if (current == b->inside) { inside.pop_back(); ui::toggleBlackFast(); @@ -1150,39 +1181,39 @@ goInsideStructure( Player *p ) } void World:: -addHole( unsigned int start, unsigned int end ) +addHole(unsigned int start, unsigned int end) { - if ( end > worldData.size() ) + if (end > worldData.size()) end = worldData.size(); - - for ( unsigned int i = start; i < end; i++ ) + + for (unsigned int i = start; i < end; i++) worldData[i].groundHeight = 0; } void World:: -addHill( const ivec2 peak, const unsigned int width ) +addHill(const ivec2 peak, const unsigned int width) { int start = peak.x - width / 2, end = start + width, offset = 0; const float thing = peak.y - worldData[start].groundHeight; const float period = PI / width; - if ( start < 0 ) { + if (start < 0) { offset = -start; start = 0; } - if ( end > (signed)worldData.size() ) + if (end > (signed)worldData.size()) end = worldData.size(); - for ( int i = start; i < end; i++ ) { + for (int i = start; i < end; i++) { worldData[i].groundHeight += thing * sin((i - start + offset) * period); - if ( worldData[i].groundHeight > peak.y ) + if (worldData[i].groundHeight > peak.y) worldData[i].groundHeight = peak.y; } } int World:: -getTheWidth( void ) const +getTheWidth(void) const { return worldStart * -2; } @@ -1207,9 +1238,9 @@ void World::save(void){ } for(auto &m : mob){ - data.append(std::to_string((int)m->loc.x) + "\n"); - data.append(std::to_string((int)m->loc.y) + "\n"); - data.append(std::to_string((int)m->alive) + "\n"); + data.append(std::to_string((int)m.loc.x) + "\n"); + data.append(std::to_string((int)m.loc.y) + "\n"); + data.append(std::to_string((int)m.alive) + "\n"); } data.append("dOnE\0"); @@ -1253,13 +1284,13 @@ void World::load(void){ for(auto &m : mob){ std::getline(iss,line); if(line == "dOnE")return; - m->loc.x = std::stoi(line); + m.loc.x = std::stoi(line); std::getline(iss,line); if(line == "dOnE")return; - m->loc.y = std::stoi(line); + m.loc.y = std::stoi(line); std::getline(iss,line); if(line == "dOnE")return; - m->alive = std::stoi(line); + m.alive = std::stoi(line); } while(std::getline(iss,line)){ @@ -1270,12 +1301,12 @@ void World::load(void){ delete[] filedata; } -float getIndoorWorldFloorHeight( void ) +float getIndoorWorldFloorHeight(void) { return INDOOR_FLOOR_HEIGHTT + INDOOR_FLOOR_THICKNESS; } -bool isCurrentWorldIndoors( void ) { +bool isCurrentWorldIndoors(void) { return !inside.empty(); } @@ -1289,28 +1320,28 @@ IndoorWorld::~IndoorWorld(void){ } void IndoorWorld:: -addFloor( unsigned int width ) +addFloor(unsigned int width) { - if ( floor.empty() ) - generate( width ); - floor.emplace_back( width, floor.size() * INDOOR_FLOOR_HEIGHTT + INDOOR_FLOOR_THICKNESS ); - fstart.push_back( 0 ); + if (floor.empty()) + generate(width); + floor.emplace_back(width, floor.size() * INDOOR_FLOOR_HEIGHTT + INDOOR_FLOOR_THICKNESS); + fstart.push_back(0); } void IndoorWorld:: -addFloor( unsigned int width, unsigned int start ) +addFloor(unsigned int width, unsigned int start) { - if ( floor.empty() ) - generate( width ); - floor.emplace_back( width, floor.size() * INDOOR_FLOOR_HEIGHTT + INDOOR_FLOOR_THICKNESS ); - fstart.push_back( start ); + if (floor.empty()) + generate(width); + floor.emplace_back(width, floor.size() * INDOOR_FLOOR_HEIGHTT + INDOOR_FLOOR_THICKNESS); + fstart.push_back(start); } bool IndoorWorld:: -moveToFloor( Entity *e, unsigned int _floor ) +moveToFloor(Entity *e, unsigned int _floor) { - if ( _floor > floor.size() ) + if (_floor > floor.size()) return false; e->loc.y = floor[_floor - 1][0]; @@ -1318,39 +1349,39 @@ moveToFloor( Entity *e, unsigned int _floor ) } bool IndoorWorld:: -isFloorAbove( Entity *e ) +isFloorAbove(Entity *e) { - for ( unsigned int i = 0; i < floor.size(); i++ ) { - if ( floor[i][0] + INDOOR_FLOOR_HEIGHTT - 100 > e->loc.y ) + for (unsigned int i = 0; i < floor.size(); i++) { + if (floor[i][0] + INDOOR_FLOOR_HEIGHTT - 100 > e->loc.y) return (i + 1) != floor.size(); } return false; } bool IndoorWorld:: -isFloorBelow( Entity *e ) +isFloorBelow(Entity *e) { - for ( unsigned int i = 0; i < floor.size(); i++ ) { - if ( floor[i][0] + INDOOR_FLOOR_HEIGHTT - 100 > e->loc.y ) + for (unsigned int i = 0; i < floor.size(); i++) { + if (floor[i][0] + INDOOR_FLOOR_HEIGHTT - 100 > e->loc.y) return i > 0; } return false; } void IndoorWorld:: -singleDetect( Entity *e ) +singleDetect(Entity *e) { unsigned int floornum = 0; float start, end; - if ( !e->alive ) + if (!e->alive) return; - if ( e->type == MOBT && Mobp(e)->subtype == MS_TRIGGER ) + if (e->type == MOBT && Mobp(e)->subtype == MS_TRIGGER) return; - for ( ; floornum < floor.size(); floornum++ ) { - if ( floor[floornum][0] + INDOOR_FLOOR_HEIGHTT - 100 > e->loc.y ) { - if ( e->loc.y < floor[floornum][0] ) { + for (; floornum < floor.size(); floornum++) { + if (floor[floornum][0] + INDOOR_FLOOR_HEIGHTT - 100 > e->loc.y) { + if (e->loc.y < floor[floornum][0]) { e->loc.y = floor[floornum][0]; e->vel.y = 0; e->ground = true; @@ -1359,21 +1390,21 @@ singleDetect( Entity *e ) } } - if ( e->vel.y > -2 ) + if (e->vel.y > -2) e->vel.y -= GRAVITY_CONSTANT * deltaTime; - if ( e->ground ) { - e->loc.y = ceil( e->loc.y ); + if (e->ground) { + e->loc.y = ceil(e->loc.y); e->vel.y = 0; } start = worldStart + fstart[floornum] * HLINE; end = start + floor[floornum].size() * HLINE; - if ( e->loc.x < start ) { + if (e->loc.x < start) { e->vel.x = 0; e->loc.x = start + HLINE / 2; - } else if ( e->loc.x + e->width + HLINE > end ) { + } else if (e->loc.x + e->width + HLINE > end) { e->vel.x = 0; e->loc.x = end - e->width - HLINE; } @@ -1381,19 +1412,19 @@ singleDetect( Entity *e ) } void IndoorWorld:: -draw( Player *p ) +draw(Player *p) { unsigned int i,f; int x; // draw lights - for ( auto &l : light ) { - if ( l.belongsTo ) { + for (auto &l : light) { + if (l.belongsTo) { l.loc.x = l.following->loc.x + SCREEN_WIDTH / 2; - l.loc.y = ( l.following->loc.y > SCREEN_HEIGHT / 2 ) ? SCREEN_HEIGHT / 2 : l.following->loc.y; + l.loc.y = (l.following->loc.y > SCREEN_HEIGHT / 2) ? SCREEN_HEIGHT / 2 : l.following->loc.y; } - if ( l.flame ) { - l.fireFlicker = .9 + ( (rand() % 2) / 10.0f ); + if (l.flame) { + l.fireFlicker = .9 + ((rand() % 2) / 10.0f); l.fireLoc.x = l.loc.x + (rand() % 2 - 1) * 3; l.fireLoc.y = l.loc.y + (rand() % 2 - 1) * 3; } else @@ -1420,16 +1451,16 @@ draw( Player *p ) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glUseProgram( shaderProgram ); + glUseProgram(shaderProgram); glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0); - glUniform1f(glGetUniformLocation(shaderProgram, "amb" ), 0.02f + light.size()/50.0f); + glUniform1f(glGetUniformLocation(shaderProgram, "amb"), 0.02f + light.size()/50.0f); - if ( light.empty() ) + if (light.empty()) glUniform1i(glGetUniformLocation(shaderProgram, "numLight"), 0); else { - glUniform1i (glGetUniformLocation(shaderProgram, "numLight" ), light.size()); + glUniform1i (glGetUniformLocation(shaderProgram, "numLight"), light.size()); glUniform2fv(glGetUniformLocation(shaderProgram, "lightLocation"), light.size(), pointArray); - glUniform3f (glGetUniformLocation(shaderProgram, "lightColor" ), 1.0f, 1.0f, 1.0f); + glUniform3f (glGetUniformLocation(shaderProgram, "lightColor"), 1.0f, 1.0f, 1.0f); glUniform1fv(glGetUniformLocation(shaderProgram, "fireFlicker"), light.size(), flameArray); } @@ -1439,10 +1470,10 @@ draw( Player *p ) glColor4ub(255,255,255,255); glBegin(GL_QUADS); - glTexCoord2i(0,1); glVertex2i( worldStart - SCREEN_WIDTH / 2,0); + glTexCoord2i(0,1); glVertex2i(worldStart - SCREEN_WIDTH / 2,0); glTexCoord2i((-worldStart*2+SCREEN_WIDTH)/512,1);glVertex2i(-worldStart + SCREEN_WIDTH / 2,0); glTexCoord2i((-worldStart*2+SCREEN_WIDTH)/512,0);glVertex2i(-worldStart + SCREEN_WIDTH / 2,SCREEN_HEIGHT); - glTexCoord2i(0,0); glVertex2i( worldStart - SCREEN_WIDTH / 2,SCREEN_HEIGHT); + glTexCoord2i(0,0); glVertex2i(worldStart - SCREEN_WIDTH / 2,SCREEN_HEIGHT); glEnd(); glUseProgram(0); @@ -1451,18 +1482,18 @@ draw( Player *p ) * Draw the ground. */ - glUseProgram( shaderProgram ); - glUniform1i( glGetUniformLocation(shaderProgram, "sampler"), 0 ); - glBegin( GL_QUADS ); - safeSetColor( 150, 100, 50 ); - for ( f = 0; f < floor.size(); f++ ) { + glUseProgram(shaderProgram); + glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0); + glBegin(GL_QUADS); + safeSetColor(150, 100, 50); + for (f = 0; f < floor.size(); f++) { i = 0; - for ( h : floor[f] ) { + for (h : floor[f]) { x = worldStart + fstart[f] * HLINE + (i * HLINE); - glVertex2i( x , h ); - glVertex2i( x + HLINE, h ); - glVertex2i( x + HLINE, h - INDOOR_FLOOR_THICKNESS ); - glVertex2i( x , h - INDOOR_FLOOR_THICKNESS ); + glVertex2i(x , h ); + glVertex2i(x + HLINE, h ); + glVertex2i(x + HLINE, h - INDOOR_FLOOR_THICKNESS); + glVertex2i(x , h - INDOOR_FLOOR_THICKNESS); i++; } } @@ -1478,14 +1509,14 @@ draw( Player *p ) glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0); glUseProgram(shaderProgram); - std::for_each( particles.begin(), particles.end(), [](Particles &part) { part.draw(); }); + std::for_each(particles.begin(), particles.end(), [](Particles &part) { part.draw(); }); glUseProgram(0); - /*for ( auto &part : particles ) + /*for (auto &part : particles) part.draw();*/ - for ( auto &e : entity ) + for (auto &e : entity) e->draw(); p->draw(); @@ -1499,8 +1530,8 @@ Arena::Arena(World *leave,Player *p,Mob *m){ mmob = m; mmob->aggressive = false; - mob.push_back(m); - entity.push_back(m); + mob.push_back(*m); + entity.push_back(&mob.back()); battleNest.push_back(leave); battleNestLoc.push_back(p->loc); @@ -1512,9 +1543,9 @@ Arena::~Arena(void){ World *Arena::exitArena(Player *p){ World *tmp; - if ( !mmob->alive && - p->loc.x + p->width / 2 > mob[0]->loc.x && - p->loc.x + p->width / 2 < mob[0]->loc.x + HLINE * 12 ) { + if (!mmob->alive && + p->loc.x + p->width / 2 > mob[0].loc.x && + p->loc.x + p->width / 2 < mob[0].loc.x + HLINE * 12) { tmp = battleNest.front(); battleNest.erase(battleNest.begin()); @@ -1534,9 +1565,9 @@ World *Arena::exitArena(Player *p){ } } -std::string getWorldWeatherStr( WorldWeather ww ) +std::string getWorldWeatherStr(WorldWeather ww) { - switch ( ww ) { + switch (ww) { case WorldWeather::Sunny: return "Sunny"; break; @@ -1556,22 +1587,22 @@ static bool loadedLeft = false; static bool loadedRight = false; World *loadWorldFromXML(std::string path){ - if ( !currentXML.empty() ) + if (!currentXML.empty()) currentWorld->save(); return loadWorldFromXMLNoSave(path); } -World *loadWorldFromPtr( World *ptr ) +World *loadWorldFromPtr(World *ptr) { World *tmp = ptr; loadedLeft = true; - currentWorldToLeft = loadWorldFromXML( tmp->toLeft ); + currentWorldToLeft = loadWorldFromXML(tmp->getToLeft()); loadedLeft = false; loadedRight = true; - currentWorldToRight = loadWorldFromXML( tmp->toRight ); + currentWorldToRight = loadWorldFromXML(tmp->getToRight()); loadedRight = false; return tmp; @@ -1582,7 +1613,7 @@ World *loadWorldFromPtr( World *ptr ) */ World * -loadWorldFromXMLNoSave( std::string path ) { +loadWorldFromXMLNoSave(std::string path) { XMLDocument xml; XMLElement *wxml; XMLElement *vil; @@ -1596,14 +1627,14 @@ loadWorldFromXMLNoSave( std::string path ) { std::string name, sptr; // no file? -> no world - if ( path.empty() ) + if (path.empty()) return NULL; currentXML = std::string(xmlFolder + path); - xml.LoadFile( currentXML.c_str() ); + xml.LoadFile(currentXML.c_str()); // attempt to load a tag - if ( (wxml = xml.FirstChildElement("World")) ) { + if ((wxml = xml.FirstChildElement("World"))) { wxml = wxml->FirstChildElement(); vil = xml.FirstChildElement("World")->FirstChildElement("village"); tmp = new World(); @@ -1611,7 +1642,7 @@ loadWorldFromXMLNoSave( std::string path ) { } // attempt to load an tag - else if( (wxml = xml.FirstChildElement("IndoorWorld")) ) { + else if((wxml = xml.FirstChildElement("IndoorWorld"))) { wxml = wxml->FirstChildElement(); vil = NULL; tmp = new IndoorWorld(); @@ -1623,39 +1654,39 @@ loadWorldFromXMLNoSave( std::string path ) { UserError("XML Error: Cannot find a or tag in " + currentXML + "!"); // iterate through world tags - while ( wxml ) { + while (wxml) { name = wxml->Name(); // world linkage - if ( name == "link" ) { + if (name == "link") { // links world to the left - if ( (ptr = wxml->Attribute("left")) ) { - tmp->setToLeft( ptr ); + if ((ptr = wxml->Attribute("left"))) { + tmp->setToLeft(ptr); // load the left world if it isn't - if ( !loadedLeft ) { + if (!loadedLeft) { loadedLeft = true; - currentWorldToLeft = loadWorldFromXMLNoSave( ptr ); + currentWorldToLeft = loadWorldFromXMLNoSave(ptr); loadedLeft = false; } } // links world to the right - else if ( (ptr = wxml->Attribute("right")) ) { - tmp->setToRight( ptr ); + else if ((ptr = wxml->Attribute("right"))) { + tmp->setToRight(ptr); // load the right world if it isn't - if ( !loadedRight ) { + if (!loadedRight) { loadedRight = true; - currentWorldToRight = loadWorldFromXMLNoSave( ptr ); + currentWorldToRight = loadWorldFromXMLNoSave(ptr); loadedRight = false; } } // tells what world is outside, if in a structure - else if ( Indoor && (ptr = wxml->Attribute("outside")) ) - inside.push_back( ptr ); + else if (Indoor && (ptr = wxml->Attribute("outside"))) + inside.push_back(ptr); // error, invalid link tag else @@ -1664,26 +1695,26 @@ loadWorldFromXMLNoSave( std::string path ) { } // style tags - else if ( name == "style" ) { + else if (name == "style") { // set style folder - tmp->setStyle( wxml->StrAttribute("folder") ); + tmp->setStyle(wxml->StrAttribute("folder")); // set background folder - if ( wxml->QueryUnsignedAttribute("background", &flooor) != XML_NO_ERROR ) + if (wxml->QueryUnsignedAttribute("background", &flooor) != XML_NO_ERROR) UserError("XML Error: No background given in