diff --git a/other/freetype/freetype.lua b/other/freetype/freetype.lua index 33ebaf286..f1abff467 100644 --- a/other/freetype/freetype.lua +++ b/other/freetype/freetype.lua @@ -28,7 +28,7 @@ FreeType = { settings.link.flags:Add("`freetype-config --libs`") elseif option.use_win32lib == true then - settings.link.libs:Add(FreeType.basepath .. "/lib/freetype2311MT") + settings.link.libs:Add(FreeType.basepath .. "/lib/freetype241MT") end end diff --git a/other/freetype/include/freetype/config/ftconfig.h b/other/freetype/include/freetype/config/ftconfig.h index 3c0b8b164..43d587e02 100644 --- a/other/freetype/include/freetype/config/ftconfig.h +++ b/other/freetype/include/freetype/config/ftconfig.h @@ -4,7 +4,7 @@ /* */ /* ANSI-specific configuration file (specification only). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2006, 2007, 2008 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2006, 2007, 2008, 2010 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -35,7 +35,6 @@ /* */ /*************************************************************************/ - #ifndef __FTCONFIG_H__ #define __FTCONFIG_H__ @@ -306,9 +305,38 @@ 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 */ +#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 ) + { + register FT_Int32 t, t2; + + + __asm + { + smull t2, t, b, a /* (lo=t2,hi=t) = a*b */ + mov a, t, asr #31 /* a = (hi >> 31) */ + add a, a, #0x8000 /* a += 0x8000 */ + adds t2, t2, a /* t2 += a */ + adc t, t, #0 /* t += carry */ + mov a, t2, lsr #16 /* a = t2 >> 16 */ + orr a, a, t, lsl #16 /* a |= t << 16 */ + } + return a; + } + +#endif /* __CC_ARM || __ARMCC__ */ + + #ifdef __GNUC__ -#if defined( __arm__ ) && !defined( __thumb__ ) +#if defined( __arm__ ) && !defined( __thumb__ ) && \ + !( defined( __CC_ARM ) || defined( __ARMCC__ ) ) #define FT_MULFIX_ASSEMBLER FT_MulFix_arm /* documentation is in freetype.h */ @@ -333,7 +361,7 @@ FT_BEGIN_HEADER return a; } -#endif /* __arm__ && !__thumb__ */ +#endif /* __arm__ && !__thumb__ && !( __CC_ARM || __ARMCC__ ) */ #if defined( i386 ) #define FT_MULFIX_ASSEMBLER FT_MulFix_i386 diff --git a/other/freetype/include/freetype/config/ftoption.h b/other/freetype/include/freetype/config/ftoption.h index 759b3a3b3..2b46259c1 100644 --- a/other/freetype/include/freetype/config/ftoption.h +++ b/other/freetype/include/freetype/config/ftoption.h @@ -4,7 +4,8 @@ /* */ /* User-selectable configuration macros (specification only). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, */ +/* 2010 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -85,9 +86,9 @@ FT_BEGIN_HEADER /* */ /* This macro has no impact on the FreeType API, only on its */ /* _implementation_. For example, using FT_RENDER_MODE_LCD when calling */ - /* FT_Render_Glyph still generates a bitmap that is 3 times larger than */ - /* the original size; the difference will be that each triplet of */ - /* subpixels has R=G=B. */ + /* FT_Render_Glyph still generates a bitmap that is 3 times wider than */ + /* the original size in case this macro isn't defined; however, each */ + /* triplet of subpixels has R=G=B. */ /* */ /* This is done to allow FreeType clients to run unmodified, forcing */ /* them to display normal gray-level anti-aliased glyphs. */ @@ -312,10 +313,11 @@ FT_BEGIN_HEADER /* */ /* Allow the use of FT_Incremental_Interface to load typefaces that */ /* contain no glyph data, but supply it via a callback function. */ - /* This allows FreeType to be used with the PostScript language, using */ - /* the GhostScript interpreter. */ + /* This is required by clients supporting document formats which */ + /* supply font data incrementally as the document is parsed, such */ + /* as the Ghostscript interpreter for the PostScript language. */ /* */ -/* #define FT_CONFIG_OPTION_INCREMENTAL */ +#define FT_CONFIG_OPTION_INCREMENTAL /*************************************************************************/ @@ -401,7 +403,7 @@ FT_BEGIN_HEADER /* Position Independent Code */ /* */ /* If this macro is set (which is _not_ the default), FreeType2 will */ - /* avoid creating constants that require address fixups. Instead the */ + /* avoid creating constants that require address fixups. Instead the */ /* constants will be moved into a struct and additional intialization */ /* code will be used. */ /* */ @@ -486,8 +488,7 @@ FT_BEGIN_HEADER /*************************************************************************/ /* */ /* Define TT_CONFIG_OPTION_BYTECODE_INTERPRETER if you want to compile */ - /* a bytecode interpreter in the TrueType driver. Note that there are */ - /* important patent issues related to the use of the interpreter. */ + /* a bytecode interpreter in the TrueType driver. */ /* */ /* By undefining this, you will only compile the code necessary to load */ /* TrueType glyphs without hinting. */ @@ -495,17 +496,20 @@ FT_BEGIN_HEADER /* Do not #undef this macro here, since the build system might */ /* define it for certain configurations only. */ /* */ -/* #define TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ +#define TT_CONFIG_OPTION_BYTECODE_INTERPRETER /*************************************************************************/ /* */ /* If you define TT_CONFIG_OPTION_UNPATENTED_HINTING, a special version */ /* of the TrueType bytecode interpreter is used that doesn't implement */ - /* any of the patented opcodes and algorithms. Note that the */ - /* TT_CONFIG_OPTION_UNPATENTED_HINTING macro is *ignored* if you define */ - /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER; in other words, either define */ - /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER or */ + /* any of the patented opcodes and algorithms. The patents related to */ + /* TrueType hinting have expired worldwide since May 2010; this option */ + /* is now deprecated. */ + /* */ + /* Note that the TT_CONFIG_OPTION_UNPATENTED_HINTING macro is *ignored* */ + /* if you define TT_CONFIG_OPTION_BYTECODE_INTERPRETER; in other words, */ + /* either define TT_CONFIG_OPTION_BYTECODE_INTERPRETER or */ /* TT_CONFIG_OPTION_UNPATENTED_HINTING but not both at the same time. */ /* */ /* This macro is only useful for a small number of font files (mostly */ @@ -542,7 +546,7 @@ FT_BEGIN_HEADER /* ... */ /* } */ /* */ -#define TT_CONFIG_OPTION_UNPATENTED_HINTING +/* #define TT_CONFIG_OPTION_UNPATENTED_HINTING */ /*************************************************************************/ @@ -688,6 +692,27 @@ FT_BEGIN_HEADER #define FT_CONFIG_OPTION_OLD_INTERNALS + /* + * To detect legacy cache-lookup call from a rogue client (<= 2.1.7), + * we restrict the number of charmaps in a font. The current API of + * FTC_CMapCache_Lookup() takes cmap_index & charcode, but old API + * takes charcode only. To determine the passed value is for cmap_index + * or charcode, the possible cmap_index is restricted not to exceed + * the minimum possible charcode by a rogue client. It is also very + * unlikely that a rogue client is interested in Unicode values 0 to 15. + * + * NOTE: The original threshold was 4 deduced from popular number of + * cmap subtables in UCS-4 TrueType fonts, but now it is not + * irregular for OpenType fonts to have more than 4 subtables, + * because variation selector subtables are available for Apple + * and Microsoft platforms. + */ + +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS +#define FT_MAX_CHARMAP_CACHEABLE 15 +#endif + + /* * This macro is defined if either unpatented or native TrueType * hinting is requested by the definitions above. diff --git a/other/freetype/include/freetype/freetype.h b/other/freetype/include/freetype/freetype.h index 9e74f1158..e2ab77437 100644 --- a/other/freetype/include/freetype/freetype.h +++ b/other/freetype/include/freetype/freetype.h @@ -4,7 +4,8 @@ /* */ /* FreeType high-level API and common types (specification only). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, */ +/* 2010 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -231,6 +232,10 @@ FT_BEGIN_HEADER /* vertAdvance :: */ /* Advance height for vertical layout. */ /* */ + /* */ + /* If not disabled with @FT_LOAD_NO_HINTING, the values represent */ + /* dimensions of the hinted glyph (in case hinting is applicable). */ + /* */ typedef struct FT_Glyph_Metrics_ { FT_Pos width; @@ -1477,8 +1482,13 @@ FT_BEGIN_HEADER /* important to perform correct WYSIWYG layout. */ /* Only relevant for outline glyphs. */ /* */ - /* advance :: This is the transformed advance width for the */ - /* glyph (in 26.6 fractional pixel format). */ + /* advance :: This shorthand is, depending on */ + /* @FT_LOAD_IGNORE_TRANSFORM, the transformed */ + /* advance width for the glyph (in 26.6 */ + /* fractional pixel format). As specified with */ + /* @FT_LOAD_VERTICAL_LAYOUT, it uses either the */ + /* `horiAdvance' or the `vertAdvance' value of */ + /* `metrics' field. */ /* */ /* format :: This field indicates the format of the image */ /* contained in the glyph slot. Typically */ @@ -1743,7 +1753,8 @@ FT_BEGIN_HEADER /* data :: A pointer to the parameter data. */ /* */ /* */ - /* The ID and function of parameters are driver-specific. */ + /* The ID and function of parameters are driver-specific. See the */ + /* various FT_PARAM_TAG_XXX flags for more information. */ /* */ typedef struct FT_Parameter_ { @@ -2986,7 +2997,7 @@ FT_BEGIN_HEADER * * @return: * The index into the array of character maps within the face to which - * `charmap' belongs. + * `charmap' belongs. If an error occurs, -1 is returned. * */ FT_EXPORT( FT_Int ) @@ -3762,8 +3773,8 @@ FT_BEGIN_HEADER * */ #define FREETYPE_MAJOR 2 -#define FREETYPE_MINOR 3 -#define FREETYPE_PATCH 11 +#define FREETYPE_MINOR 4 +#define FREETYPE_PATCH 1 /*************************************************************************/ @@ -3823,6 +3834,9 @@ FT_BEGIN_HEADER /* 1~if this is a TrueType font that uses one of the patented */ /* opcodes, 0~otherwise. */ /* */ + /* */ + /* Since May 2010, TrueType hinting is no longer patented. */ + /* */ /* */ /* 2.3.5 */ /* */ @@ -3850,6 +3864,9 @@ FT_BEGIN_HEADER /* an SFNT font, or if the unpatented hinter is not compiled in this */ /* instance of the library. */ /* */ + /* */ + /* Since May 2010, TrueType hinting is no longer patented. */ + /* */ /* */ /* 2.3.5 */ /* */ diff --git a/other/freetype/include/freetype/ftcache.h b/other/freetype/include/freetype/ftcache.h index 0916d70a3..a9e1237bc 100644 --- a/other/freetype/include/freetype/ftcache.h +++ b/other/freetype/include/freetype/ftcache.h @@ -4,7 +4,7 @@ /* */ /* FreeType Cache subsystem (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -263,10 +263,10 @@ FT_BEGIN_HEADER /* reference-counted. A node with a count of~0 might be flushed */ /* out of a full cache whenever a lookup request is performed. */ /* */ - /* If you lookup nodes, you have the ability to `acquire' them, i.e., */ - /* to increment their reference count. This will prevent the node */ - /* from being flushed out of the cache until you explicitly `release' */ - /* it (see @FTC_Node_Unref). */ + /* If you look up nodes, you have the ability to `acquire' them, */ + /* i.e., to increment their reference count. This will prevent the */ + /* node from being flushed out of the cache until you explicitly */ + /* `release' it (see @FTC_Node_Unref). */ /* */ /* See also @FTC_SBitCache_Lookup and @FTC_ImageCache_Lookup. */ /* */ diff --git a/other/freetype/include/freetype/fterrdef.h b/other/freetype/include/freetype/fterrdef.h index d7ad256bd..bf5222060 100644 --- a/other/freetype/include/freetype/fterrdef.h +++ b/other/freetype/include/freetype/fterrdef.h @@ -4,7 +4,7 @@ /* */ /* FreeType error codes (specification). */ /* */ -/* Copyright 2002, 2004, 2006, 2007 by */ +/* Copyright 2002, 2004, 2006, 2007, 2010 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -211,6 +211,9 @@ "argument stack underflow" ) FT_ERRORDEF_( Ignore, 0xA2, \ "ignore" ) + FT_ERRORDEF_( No_Unicode_Glyph_Name, 0xA3, \ + "no Unicode glyph name found" ) + /* BDF errors */ @@ -220,19 +223,21 @@ "`FONT' field missing" ) FT_ERRORDEF_( Missing_Size_Field, 0xB2, \ "`SIZE' field missing" ) - FT_ERRORDEF_( Missing_Chars_Field, 0xB3, \ + FT_ERRORDEF_( Missing_Fontboundingbox_Field, 0xB3, \ + "`FONTBOUNDINGBOX' field missing" ) + FT_ERRORDEF_( Missing_Chars_Field, 0xB4, \ "`CHARS' field missing" ) - FT_ERRORDEF_( Missing_Startchar_Field, 0xB4, \ + FT_ERRORDEF_( Missing_Startchar_Field, 0xB5, \ "`STARTCHAR' field missing" ) - FT_ERRORDEF_( Missing_Encoding_Field, 0xB5, \ + FT_ERRORDEF_( Missing_Encoding_Field, 0xB6, \ "`ENCODING' field missing" ) - FT_ERRORDEF_( Missing_Bbx_Field, 0xB6, \ + FT_ERRORDEF_( Missing_Bbx_Field, 0xB7, \ "`BBX' field missing" ) - FT_ERRORDEF_( Bbx_Too_Big, 0xB7, \ + FT_ERRORDEF_( Bbx_Too_Big, 0xB8, \ "`BBX' too big" ) - FT_ERRORDEF_( Corrupted_Font_Header, 0xB8, \ + FT_ERRORDEF_( Corrupted_Font_Header, 0xB9, \ "Font header corrupted or missing fields" ) - FT_ERRORDEF_( Corrupted_Font_Glyphs, 0xB9, \ + FT_ERRORDEF_( Corrupted_Font_Glyphs, 0xBA, \ "Font glyphs corrupted or missing fields" ) diff --git a/other/freetype/include/freetype/ftglyph.h b/other/freetype/include/freetype/ftglyph.h index cacccf025..0b8f0c044 100644 --- a/other/freetype/include/freetype/ftglyph.h +++ b/other/freetype/include/freetype/ftglyph.h @@ -468,7 +468,7 @@ FT_BEGIN_HEADER /* // convert to a bitmap (default render mode + destroying old) */ /* if ( glyph->format != FT_GLYPH_FORMAT_BITMAP ) */ /* { */ - /* error = FT_Glyph_To_Bitmap( &glyph, FT_RENDER_MODE_DEFAULT, */ + /* error = FT_Glyph_To_Bitmap( &glyph, FT_RENDER_MODE_NORMAL, */ /* 0, 1 ); */ /* if ( error ) // `glyph' unchanged */ /* ... */ diff --git a/other/freetype/include/freetype/ftimage.h b/other/freetype/include/freetype/ftimage.h index 2fcc113ad..0272e92d2 100644 --- a/other/freetype/include/freetype/ftimage.h +++ b/other/freetype/include/freetype/ftimage.h @@ -5,7 +5,8 @@ /* FreeType glyph image formats and default raster interface */ /* (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, */ +/* 2010 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -51,10 +52,9 @@ FT_BEGIN_HEADER /* FT_Pos */ /* */ /* */ - /* The type FT_Pos is a 32-bit integer used to store vectorial */ - /* coordinates. Depending on the context, these can represent */ - /* distances in integer font units, or 16.16, or 26.6 fixed float */ - /* pixel coordinates. */ + /* The type FT_Pos is used to store vectorial coordinates. Depending */ + /* on the context, these can represent distances in integer font */ + /* units, or 16.16, or 26.6 fixed float pixel coordinates. */ /* */ typedef signed long FT_Pos; @@ -99,6 +99,20 @@ FT_BEGIN_HEADER /* */ /* yMax :: The vertical maximum (top-most). */ /* */ + /* */ + /* The bounding box is specified with the coordinates of the lower */ + /* left and the upper right corner. In PostScript, those values are */ + /* often called (llx,lly) and (urx,ury), respectively. */ + /* */ + /* If `yMin' is negative, this value gives the glyph's descender. */ + /* Otherwise, the glyph doesn't descend below the baseline. */ + /* Similarly, if `ymax' is positive, this value gives the glyph's */ + /* ascender. */ + /* */ + /* `xMin' gives the horizontal distance from the glyph's origin to */ + /* the left edge of the glyph's bounding box. If `xMin' is negative, */ + /* the glyph extends to the left of the origin. */ + /* */ typedef struct FT_BBox_ { FT_Pos xMin, yMin; @@ -254,6 +268,9 @@ FT_BEGIN_HEADER /* flow. In all cases, the pitch is an offset to add */ /* to a bitmap pointer in order to go down one row. */ /* */ + /* For the B/W rasterizer, `pitch' is always an even */ + /* number. */ + /* */ /* buffer :: A typeless pointer to the bitmap buffer. This */ /* value should be aligned on 32-bit boundaries in */ /* most cases. */ @@ -563,8 +580,8 @@ FT_BEGIN_HEADER /* FT_Outline_ConicToFunc */ /* */ /* */ - /* A function pointer type use to describe the signature of a `conic */ - /* to' function during outline walking/decomposition. */ + /* A function pointer type used to describe the signature of a `conic */ + /* to' function during outline walking or decomposition. */ /* */ /* A `conic to' is emitted to indicate a second-order Bézier arc in */ /* the outline. */ @@ -596,7 +613,7 @@ FT_BEGIN_HEADER /* */ /* */ /* A function pointer type used to describe the signature of a `cubic */ - /* to' function during outline walking/decomposition. */ + /* to' function during outline walking or decomposition. */ /* */ /* A `cubic to' is emitted to indicate a third-order Bézier arc. */ /* */ @@ -629,8 +646,7 @@ FT_BEGIN_HEADER /* */ /* */ /* A structure to hold various function pointers used during outline */ - /* decomposition in order to emit segments, conic, and cubic Béziers, */ - /* as well as `move to' and `close to' operations. */ + /* decomposition in order to emit segments, conic, and cubic Béziers. */ /* */ /* */ /* move_to :: The `move to' emitter. */ @@ -657,7 +673,7 @@ FT_BEGIN_HEADER /* y' = (x << shift) - delta */ /* } */ /* */ - /* Set the value of `shift' and `delta' to~0 to get the original */ + /* Set the values of `shift' and `delta' to~0 to get the original */ /* point coordinates. */ /* */ typedef struct FT_Outline_Funcs_ diff --git a/other/freetype/include/freetype/ftincrem.h b/other/freetype/include/freetype/ftincrem.h index 96abedea7..aaf689ff1 100644 --- a/other/freetype/include/freetype/ftincrem.h +++ b/other/freetype/include/freetype/ftincrem.h @@ -4,7 +4,7 @@ /* */ /* FreeType incremental loading (specification). */ /* */ -/* Copyright 2002, 2003, 2006, 2007, 2008 by */ +/* Copyright 2002, 2003, 2006, 2007, 2008, 2010 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -101,7 +101,10 @@ FT_BEGIN_HEADER * Top bearing, in font units. * * advance :: - * Glyph advance, in font units. + * Horizontal component of glyph advance, in font units. + * + * advance_v :: + * Vertical component of glyph advance, in font units. * * @note: * These correspond to horizontal or vertical metrics depending on the @@ -114,6 +117,7 @@ FT_BEGIN_HEADER FT_Long bearing_x; FT_Long bearing_y; FT_Long advance; + FT_Long advance_v; /* since 2.3.12 */ } FT_Incremental_MetricsRec; diff --git a/other/freetype/include/freetype/ftlcdfil.h b/other/freetype/include/freetype/ftlcdfil.h index c6201b38e..e7f592714 100644 --- a/other/freetype/include/freetype/ftlcdfil.h +++ b/other/freetype/include/freetype/ftlcdfil.h @@ -5,7 +5,7 @@ /* FreeType API for color filtering of subpixel bitmap glyphs */ /* (specification). */ /* */ -/* Copyright 2006, 2007, 2008 by */ +/* Copyright 2006, 2007, 2008, 2010 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -161,6 +161,47 @@ FT_BEGIN_HEADER FT_Library_SetLcdFilter( FT_Library library, FT_LcdFilter filter ); + + /************************************************************************** + * + * @func: + * FT_Library_SetLcdFilterWeights + * + * @description: + * Use this function to override the filter weights selected by + * @FT_Library_SetLcdFilter. By default, FreeType uses the quintuple + * (0x00, 0x55, 0x56, 0x55, 0x00) for FT_LCD_FILTER_LIGHT, and (0x10, + * 0x40, 0x70, 0x40, 0x10) for FT_LCD_FILTER_DEFAULT and + * FT_LCD_FILTER_LEGACY. + * + * @input: + * library :: + * A handle to the target library instance. + * + * weights :: + * A pointer to an array; the function copies the first five bytes and + * uses them to specify the filter weights. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Due to *PATENTS* covering subpixel rendering, this function doesn't + * do anything except returning `FT_Err_Unimplemented_Feature' if the + * configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING is not + * defined in your build of the library, which should correspond to all + * default builds of FreeType. + * + * This function must be called after @FT_Library_SetLcdFilter to have + * any effect. + * + * @since: + * 2.4.0 + */ + FT_EXPORT( FT_Error ) + FT_Library_SetLcdFilterWeights( FT_Library library, + unsigned char *weights ); + /* */ diff --git a/other/freetype/include/freetype/ftlist.h b/other/freetype/include/freetype/ftlist.h index 93b05fc0d..bb6f7f119 100644 --- a/other/freetype/include/freetype/ftlist.h +++ b/other/freetype/include/freetype/ftlist.h @@ -4,7 +4,7 @@ /* */ /* Generic list support for FreeType (specification). */ /* */ -/* Copyright 1996-2001, 2003, 2007 by */ +/* Copyright 1996-2001, 2003, 2007, 2010 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -255,6 +255,10 @@ FT_BEGIN_HEADER /* user :: A user-supplied field which is passed as the last */ /* argument to the destructor. */ /* */ + /* */ + /* 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_List_Destructor destroy, diff --git a/other/freetype/include/freetype/ftmodapi.h b/other/freetype/include/freetype/ftmodapi.h index 3c9b876df..17868b2f8 100644 --- a/other/freetype/include/freetype/ftmodapi.h +++ b/other/freetype/include/freetype/ftmodapi.h @@ -4,7 +4,7 @@ /* */ /* FreeType modules public interface (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2006, 2008, 2009 by */ +/* Copyright 1996-2001, 2002, 2003, 2006, 2008, 2009, 2010 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -263,6 +263,9 @@ FT_BEGIN_HEADER /* @FT_Add_Default_Modules or a series of calls to @FT_Add_Module) */ /* instead of @FT_Init_FreeType to initialize the FreeType library. */ /* */ + /* Don't use @FT_Done_FreeType but @FT_Done_Library to destroy a */ + /* library instance. */ + /* */ /* */ /* memory :: A handle to the original memory object. */ /* */ @@ -394,8 +397,8 @@ FT_BEGIN_HEADER * * FT_TRUETYPE_ENGINE_TYPE_PATENTED :: * The library implements a bytecode interpreter that covers - * the full instruction set of the TrueType virtual machine. - * See the file `docs/PATENTS' for legal aspects. + * the full instruction set of the TrueType virtual machine (this + * was governed by patents until May 2010, hence the name). * * @since: * 2.2 diff --git a/other/freetype/include/freetype/ftoutln.h b/other/freetype/include/freetype/ftoutln.h index d7d01e827..2829a05ca 100644 --- a/other/freetype/include/freetype/ftoutln.h +++ b/other/freetype/include/freetype/ftoutln.h @@ -5,7 +5,7 @@ /* Support for the FT_Outline type used to store glyph shapes of */ /* most scalable font formats (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2005, 2006, 2007, 2008, 2009 by */ +/* Copyright 1996-2001, 2002, 2003, 2005, 2006, 2007, 2008, 2009, 2010 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -85,9 +85,8 @@ FT_BEGIN_HEADER /* */ /* */ /* Walk over an outline's structure to decompose it into individual */ - /* segments and Bézier arcs. This function is also able to emit */ - /* `move to' and `close to' operations to indicate the start and end */ - /* of new contours in the outline. */ + /* segments and Bézier arcs. This function also emits `move to' */ + /* operations to indicate the start of new contours in the outline. */ /* */ /* */ /* outline :: A pointer to the source target. */ diff --git a/other/freetype/include/freetype/ftrender.h b/other/freetype/include/freetype/ftrender.h index 41c31eac4..e06a8142e 100644 --- a/other/freetype/include/freetype/ftrender.h +++ b/other/freetype/include/freetype/ftrender.h @@ -4,7 +4,7 @@ /* */ /* FreeType renderer modules public interface (specification). */ /* */ -/* Copyright 1996-2001, 2005, 2006 by */ +/* Copyright 1996-2001, 2005, 2006, 2010 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -141,10 +141,6 @@ FT_BEGIN_HEADER /* raster_class :: For @FT_GLYPH_FORMAT_OUTLINE renderers only. */ /* This is a pointer to its raster's class. */ /* */ - /* raster :: For @FT_GLYPH_FORMAT_OUTLINE renderers only. */ - /* This is a pointer to the corresponding raster */ - /* object, if any. */ - /* */ typedef struct FT_Renderer_Class_ { FT_Module_Class root; diff --git a/other/freetype/include/freetype/ftsnames.h b/other/freetype/include/freetype/ftsnames.h index f20b4099d..485e4e162 100644 --- a/other/freetype/include/freetype/ftsnames.h +++ b/other/freetype/include/freetype/ftsnames.h @@ -7,7 +7,7 @@ /* */ /* This is _not_ used to retrieve glyph names! */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2006, 2009 by */ +/* Copyright 1996-2001, 2002, 2003, 2006, 2009, 2010 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -160,6 +160,35 @@ FT_BEGIN_HEADER FT_SfntName *aname ); + /*************************************************************************** + * + * @constant: + * FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY + * + * @description: + * A constant used as the tag of @FT_Parameter structures to make + * FT_Open_Face() ignore preferred family subfamily names in `name' + * table since OpenType version 1.4. For backwards compatibility with + * legacy systems which has 4-face-per-family restriction. + * + */ +#define FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY FT_MAKE_TAG( 'i', 'g', 'p', 'f' ) + + + /*************************************************************************** + * + * @constant: + * FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY + * + * @description: + * A constant used as the tag of @FT_Parameter structures to make + * FT_Open_Face() ignore preferred subfamily names in `name' table since + * OpenType version 1.4. For backwards compatibility with legacy + * systems which has 4-face-per-family restriction. + * + */ +#define FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY FT_MAKE_TAG( 'i', 'g', 'p', 's' ) + /* */ diff --git a/other/freetype/include/freetype/ftsystem.h b/other/freetype/include/freetype/ftsystem.h index a95b2c76b..e07460c55 100644 --- a/other/freetype/include/freetype/ftsystem.h +++ b/other/freetype/include/freetype/ftsystem.h @@ -4,7 +4,7 @@ /* */ /* FreeType low-level system interface definition (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2005 by */ +/* Copyright 1996-2001, 2002, 2005, 2010 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -240,7 +240,8 @@ FT_BEGIN_HEADER * * @note: * This function might be called to perform a seek or skip operation - * with a `count' of~0. + * with a `count' of~0. A non-zero return value then indicates an + * error. * */ typedef unsigned long @@ -301,7 +302,7 @@ FT_BEGIN_HEADER * The stream's input function. * * close :: - * The stream;s close function. + * The stream's close function. * * memory :: * The memory manager to use to preload frames. This is set diff --git a/other/freetype/include/freetype/internal/ftmemory.h b/other/freetype/include/freetype/internal/ftmemory.h index 2010ca90d..026aa63ea 100644 --- a/other/freetype/include/freetype/internal/ftmemory.h +++ b/other/freetype/include/freetype/internal/ftmemory.h @@ -4,7 +4,7 @@ /* */ /* The FreeType memory management macros (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2004, 2005, 2006, 2007 by */ +/* Copyright 1996-2001, 2002, 2004, 2005, 2006, 2007, 2010 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -58,15 +58,27 @@ FT_BEGIN_HEADER /* - * C++ refuses to handle statements like p = (void*)anything; where `p' - * is a typed pointer. Since we don't have a `typeof' operator in - * standard C++, we have to use ugly casts. + * C++ refuses to handle statements like p = (void*)anything, with `p' a + * typed pointer. Since we don't have a `typeof' operator in standard + * C++, we have to use a template to emulate it. */ #ifdef __cplusplus -#define FT_ASSIGNP( p, val ) *((void**)&(p)) = (val) + + extern "C++" + template inline T* + cplusplus_typeof( T*, + void *v ) + { + return static_cast ( v ); + } + +#define FT_ASSIGNP( p, val ) (p) = cplusplus_typeof( (p), (val) ) + #else + #define FT_ASSIGNP( p, val ) (p) = (val) + #endif diff --git a/other/freetype/include/freetype/ttnameid.h b/other/freetype/include/freetype/ttnameid.h index cbeac78db..66aef0432 100644 --- a/other/freetype/include/freetype/ttnameid.h +++ b/other/freetype/include/freetype/ttnameid.h @@ -64,7 +64,7 @@ FT_BEGIN_HEADER * MacOS systems (even if they contain a Microsoft charmap as well). * * TT_PLATFORM_ISO :: - * This value was used to specify Unicode charmaps. It is however + * This value was used to specify ISO/IEC 10646 charmaps. It is however * now deprecated. See @TT_ISO_ID_XXX for a list of corresponding * `encoding_id' values. * diff --git a/other/freetype/include/freetype/tttables.h b/other/freetype/include/freetype/tttables.h index c12b17268..4610e501f 100644 --- a/other/freetype/include/freetype/tttables.h +++ b/other/freetype/include/freetype/tttables.h @@ -5,7 +5,7 @@ /* Basic SFNT/TrueType tables definitions and interface */ /* (specification only). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2008, 2009 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2008, 2009, 2010 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -557,13 +557,13 @@ FT_BEGIN_HEADER /* */ typedef enum FT_Sfnt_Tag_ { - ft_sfnt_head = 0, - ft_sfnt_maxp = 1, - ft_sfnt_os2 = 2, - ft_sfnt_hhea = 3, - ft_sfnt_vhea = 4, - ft_sfnt_post = 5, - ft_sfnt_pclt = 6, + ft_sfnt_head = 0, /* TT_Header */ + ft_sfnt_maxp = 1, /* TT_MaxProfile */ + ft_sfnt_os2 = 2, /* TT_OS2 */ + ft_sfnt_hhea = 3, /* TT_HoriHeader */ + ft_sfnt_vhea = 4, /* TT_VertHeader */ + ft_sfnt_post = 5, /* TT_Postscript */ + ft_sfnt_pclt = 6, /* TT_PCLT */ sfnt_max /* internal end mark */ @@ -590,6 +590,9 @@ FT_BEGIN_HEADER /* error, or if the corresponding table was not found *OR* loaded */ /* from the file. */ /* */ + /* Use a typecast according to `tag' to access the structure */ + /* elements. */ + /* */ /* */ /* The table is owned by the face object and disappears with it. */ /* */ diff --git a/other/freetype/lib/freetype2311MT.lib b/other/freetype/lib/freetype2311MT.lib deleted file mode 100644 index 828137fa4..000000000 Binary files a/other/freetype/lib/freetype2311MT.lib and /dev/null differ diff --git a/other/freetype/lib/freetype241MT.lib b/other/freetype/lib/freetype241MT.lib new file mode 100644 index 000000000..c05a30cb8 Binary files /dev/null and b/other/freetype/lib/freetype241MT.lib differ diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 925904721..4ab8ee603 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -1613,6 +1613,9 @@ void CClient::Run() Input()->MouseModeRelative(); + // process pending commands + m_pConsole->StoreCommands(false); + while (1) { int64 FrameStartTime = time_get(); @@ -1899,28 +1902,23 @@ void CClient::Con_StopRecord(IConsole::IResult *pResult, void *pUserData) pSelf->m_DemoRecorder.Stop(); } -void CClient::Con_ServerDummy(IConsole::IResult *pResult, void *pUserData) -{ - dbg_msg("client", "this command is not available on the client"); -} - void CClient::RegisterCommands() { m_pConsole = Kernel()->RequestInterface(); // register server dummy commands for tab completion - m_pConsole->Register("kick", "i", CFGFLAG_SERVER, Con_ServerDummy, this, "Kick player with specified id"); - m_pConsole->Register("ban", "s?i", CFGFLAG_SERVER, Con_ServerDummy, this, "Ban player with ip/id for x minutes"); - m_pConsole->Register("unban", "s", CFGFLAG_SERVER, Con_ServerDummy, this, "Unban ip"); - m_pConsole->Register("bans", "", CFGFLAG_SERVER, Con_ServerDummy, this, "Show banlist"); - m_pConsole->Register("status", "", CFGFLAG_SERVER, Con_ServerDummy, this, "List players"); - m_pConsole->Register("shutdown", "", CFGFLAG_SERVER, Con_ServerDummy, this, "Shut down"); - m_pConsole->Register("record", "s", CFGFLAG_SERVER, Con_ServerDummy, this, "Record to a file"); - m_pConsole->Register("stoprecord", "", CFGFLAG_SERVER, Con_ServerDummy, this, "Stop recording"); - m_pConsole->Register("reload", "", CFGFLAG_SERVER, Con_ServerDummy, this, "Reload the map"); + m_pConsole->Register("kick", "i", CFGFLAG_SERVER, 0, 0, "Kick player with specified id"); + m_pConsole->Register("ban", "s?i", CFGFLAG_SERVER, 0, 0, "Ban player with ip/id for x minutes"); + m_pConsole->Register("unban", "s", CFGFLAG_SERVER, 0, 0, "Unban ip"); + m_pConsole->Register("bans", "", CFGFLAG_SERVER, 0, 0, "Show banlist"); + m_pConsole->Register("status", "", CFGFLAG_SERVER, 0, 0, "List players"); + m_pConsole->Register("shutdown", "", CFGFLAG_SERVER, 0, 0, "Shut down"); + m_pConsole->Register("record", "s", CFGFLAG_SERVER, 0, 0, "Record to a file"); + m_pConsole->Register("stoprecord", "", CFGFLAG_SERVER, 0, 0, "Stop recording"); + m_pConsole->Register("reload", "", CFGFLAG_SERVER, 0, 0, "Reload the map"); m_pConsole->Register("quit", "", CFGFLAG_CLIENT, Con_Quit, this, "Quit Teeworlds"); m_pConsole->Register("exit", "", CFGFLAG_CLIENT, Con_Quit, this, "Quit Teeworlds"); - m_pConsole->Register("minimize", "", CFGFLAG_CLIENT, Con_Minimize, this, "Minimize Teeworlds"); + m_pConsole->Register("minimize", "", CFGFLAG_CLIENT|CFGFLAG_STORE, Con_Minimize, this, "Minimize Teeworlds"); m_pConsole->Register("connect", "s", CFGFLAG_CLIENT, Con_Connect, this, "Connect to the specified host/ip"); m_pConsole->Register("disconnect", "", CFGFLAG_CLIENT, Con_Disconnect, this, "Disconnect from the server"); m_pConsole->Register("ping", "", CFGFLAG_CLIENT, Con_Ping, this, "Ping the current server"); @@ -1964,7 +1962,7 @@ int main(int argc, const char **argv) // ignore_convention // create the components IConsole *pConsole = CreateConsole(CFGFLAG_CLIENT); - IStorage *pStorage = CreateStorage("Teeworlds", argv[0]); // ignore_convention + IStorage *pStorage = CreateStorage("Teeworlds", argc, argv); // ignore_convention IConfig *pConfig = CreateConfig(); IEngineGraphics *pEngineGraphics = CreateEngineGraphics(); IEngineSound *pEngineSound = CreateEngineSound(); @@ -2017,6 +2015,9 @@ int main(int argc, const char **argv) // ignore_convention // init client's interfaces m_Client.InitInterfaces(); + // execute config file + pConsole->ExecuteFile("settings.cfg"); + // execute autoexec file pConsole->ExecuteFile("autoexec.cfg"); @@ -2024,8 +2025,7 @@ int main(int argc, const char **argv) // ignore_convention if(argc > 1) // ignore_convention pConsole->ParseArguments(argc-1, &argv[1]); // ignore_convention - // execute config file - pConsole->ExecuteFile("settings.cfg"); + m_Client.Engine()->InitLogfile(); // run the client m_Client.Run(); diff --git a/src/engine/client/client.h b/src/engine/client/client.h index c7174f858..9698abbbb 100644 --- a/src/engine/client/client.h +++ b/src/engine/client/client.h @@ -280,7 +280,6 @@ public: static void Con_Play(IConsole::IResult *pResult, void *pUserData); static void Con_Record(IConsole::IResult *pResult, void *pUserData); static void Con_StopRecord(IConsole::IResult *pResult, void *pUserData); - static void Con_ServerDummy(IConsole::IResult *pResult, void *pUserData); void RegisterCommands(); diff --git a/src/engine/client/graphics.cpp b/src/engine/client/graphics.cpp index bf3f42eac..09ee4784b 100644 --- a/src/engine/client/graphics.cpp +++ b/src/engine/client/graphics.cpp @@ -103,7 +103,7 @@ void CGraphics_OpenGL::AddVertices(int Count) Flush(); } -void CGraphics_OpenGL::Rotate4(CPoint *pCenter, CVertex *pPoints) +void CGraphics_OpenGL::Rotate4(const CPoint &rCenter, CVertex *pPoints) { float c = cosf(m_Rotation); float s = sinf(m_Rotation); @@ -112,10 +112,10 @@ void CGraphics_OpenGL::Rotate4(CPoint *pCenter, CVertex *pPoints) for(i = 0; i < 4; i++) { - x = pPoints[i].m_Pos.x - pCenter->x; - y = pPoints[i].m_Pos.y - pCenter->y; - pPoints[i].m_Pos.x = x * c - y * s + pCenter->x; - pPoints[i].m_Pos.y = x * s + y * c + pCenter->y; + x = pPoints[i].m_Pos.x - rCenter.x; + y = pPoints[i].m_Pos.y - rCenter.y; + pPoints[i].m_Pos.x = x * c - y * s + rCenter.x; + pPoints[i].m_Pos.y = x * s + y * c + rCenter.y; } } @@ -558,15 +558,12 @@ void CGraphics_OpenGL::QuadsDraw(CQuadItem *pArray, int Num) void CGraphics_OpenGL::QuadsDrawTL(const CQuadItem *pArray, int Num) { CPoint Center; + Center.z = 0; dbg_assert(m_Drawing == DRAWING_QUADS, "called quads_draw without begin"); for(int i = 0; i < Num; ++i) { - Center.x = pArray[i].m_X + pArray[i].m_Width/2; - Center.y = pArray[i].m_Y + pArray[i].m_Height/2; - Center.z = 0; - m_aVertices[m_NumVertices + 4*i].m_Pos.x = pArray[i].m_X; m_aVertices[m_NumVertices + 4*i].m_Pos.y = pArray[i].m_Y; m_aVertices[m_NumVertices + 4*i].m_Tex = m_aTexture[0]; @@ -588,7 +585,12 @@ void CGraphics_OpenGL::QuadsDrawTL(const CQuadItem *pArray, int Num) m_aVertices[m_NumVertices + 4*i + 3].m_Color = m_aColor[3]; if(m_Rotation != 0) - Rotate4(&Center, &m_aVertices[m_NumVertices + 4*i]); + { + Center.x = pArray[i].m_X + pArray[i].m_Width/2; + Center.y = pArray[i].m_Y + pArray[i].m_Height/2; + + Rotate4(Center, &m_aVertices[m_NumVertices + 4*i]); + } } AddVertices(4*Num); diff --git a/src/engine/client/graphics.h b/src/engine/client/graphics.h index ff4c35629..cb8681f39 100644 --- a/src/engine/client/graphics.h +++ b/src/engine/client/graphics.h @@ -60,7 +60,7 @@ protected: void Flush(); void AddVertices(int Count); - void Rotate4(CPoint *pCenter, CVertex *pPoints); + void Rotate4(const CPoint &rCenter, CVertex *pPoints); static unsigned char Sample(int w, int h, const unsigned char *pData, int u, int v, int Offset); public: diff --git a/src/engine/console.h b/src/engine/console.h index a5785faab..9a745d153 100644 --- a/src/engine/console.h +++ b/src/engine/console.h @@ -45,6 +45,7 @@ public: virtual void Register(const char *pName, const char *pParams, int Flags, FCommandCallback pfnFunc, void *pUser, const char *pHelp, const int Level) = 0; virtual void Chain(const char *pName, FChainCommandCallback pfnChainFunc, void *pUser) = 0; + virtual void StoreCommands(bool Store, int ClientId) = 0; virtual void ExecuteLine(const char *Sptr, const int ClientLevel, const int ClientId) = 0; virtual void ExecuteLineStroked(int Stroke, const char *pStr, const int ClientLevel, const int ClientId) = 0; diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index 36ccbf2a5..3aa0e6cb5 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -1215,6 +1215,9 @@ int CServer::Run() GameServer()->OnInit(); dbg_msg("server", "version %s", GameServer()->NetVersion()); + // process pending commands + m_pConsole->StoreCommands(false,-1); + // start game { int64 ReportTime = time_get(); @@ -1398,7 +1401,7 @@ void CServer::ConBan(IConsole::IResult *pResult, void *pUser, int ClientId1) return; } - NETADDR Addr = ((CServer *)pUser)->m_NetServer.ClientAddr(ClientId); + Addr = ((CServer *)pUser)->m_NetServer.ClientAddr(ClientId); ((CServer *)pUser)->BanAdd(Addr, Minutes*60, Bufz); } @@ -1530,15 +1533,12 @@ void CServer::RegisterCommands() Console()->Register("kick", "i", CFGFLAG_SERVER, ConKick, this, "", 2); Console()->Register("ban", "s?i?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s?s", CFGFLAG_SERVER, ConBan, this, "Ban player",2); //horrible long string - Console()->Register("unban", "s", CFGFLAG_SERVER, ConUnban, this, "", 3); Console()->Register("bans", "", CFGFLAG_SERVER, ConBans, this, "", 2); Console()->Register("status", "", CFGFLAG_SERVER, ConStatus, this, "", 1); Console()->Register("shutdown", "", CFGFLAG_SERVER, ConShutdown, this, "", 3); - Console()->Register("record", "s", CFGFLAG_SERVER, ConRecord, this, "", 3); Console()->Register("stoprecord", "", CFGFLAG_SERVER, ConStopRecord, this, "", 3); - Console()->Register("reload", "", CFGFLAG_SERVER, ConMapReload, this, "", 3); Console()->Chain("sv_name", ConchainSpecialInfoupdate, this); @@ -1598,7 +1598,7 @@ int main(int argc, const char **argv) // ignore_convention IGameServer *pGameServer = CreateGameServer(); IConsole *pConsole = CreateConsole(CFGFLAG_SERVER); IEngineMasterServer *pEngineMasterServer = CreateEngineMasterServer(); - IStorage *pStorage = CreateStorage("Teeworlds", argv[0]); // ignore_convention + IStorage *pStorage = CreateStorage("Teeworlds", argc, argv); // ignore_convention IConfig *pConfig = CreateConfig(); pServer->InitRegister(&pServer->m_NetServer, pEngineMasterServer); @@ -1644,6 +1644,7 @@ int main(int argc, const char **argv) // ignore_convention if(argc > 1) // ignore_convention pConsole->ParseArguments(argc-1, &argv[1]); // ignore_convention + pServer->Engine()->InitLogfile(); if(g_Config.m_SvExternalRecords == 1) { char pathBuf[512]; str_format(pathBuf, sizeof(pathBuf), "%s/records", pStorage->ApplicationSavePath()); diff --git a/src/engine/shared/config.h b/src/engine/shared/config.h index 10a540045..ccece08c4 100644 --- a/src/engine/shared/config.h +++ b/src/engine/shared/config.h @@ -16,7 +16,8 @@ enum { CFGFLAG_SAVE=1, CFGFLAG_CLIENT=2, - CFGFLAG_SERVER=4 + CFGFLAG_SERVER=4, + CFGFLAG_STORE=8 }; #endif diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h index 37c552ad0..7cd69b3b5 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -64,7 +64,7 @@ MACRO_CONFIG_INT(SvRegister, sv_register, 1, 0, 1, CFGFLAG_SERVER, "Register ser MACRO_CONFIG_STR(PlayerName, player_name, 24, "nameless tee", CFGFLAG_SAVE|CFGFLAG_CLIENT, "Name of the player") MACRO_CONFIG_STR(ClanName, clan_name, 32, "", CFGFLAG_SAVE|CFGFLAG_CLIENT, "(not used)") MACRO_CONFIG_STR(Password, password, 32, "", CFGFLAG_CLIENT|CFGFLAG_SERVER, "Password to the server") -MACRO_CONFIG_STR(Logfile, logfile, 128, "", CFGFLAG_SAVE|CFGFLAG_CLIENT, "Filename to log all output to") +MACRO_CONFIG_STR(Logfile, logfile, 128, "", CFGFLAG_SAVE|CFGFLAG_CLIENT|CFGFLAG_SERVER, "Filename to log all output to") MACRO_CONFIG_INT(ClCpuThrottle, cl_cpu_throttle, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "") MACRO_CONFIG_INT(ClEditor, cl_editor, 0, 0, 1, CFGFLAG_CLIENT, "") diff --git a/src/engine/shared/console.cpp b/src/engine/shared/console.cpp index e38b2930c..5cf5271bf 100644 --- a/src/engine/shared/console.cpp +++ b/src/engine/shared/console.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -172,12 +173,8 @@ void CConsole::Print(const char *pStr) void CConsole::ExecuteLineStroked(int Stroke, const char *pStr, const int ClientLevel, const int ClientId) { - CResult Result; + CResult *pResult = new(&m_ExecutionQueue.m_pLast->m_Result) CResult; - char aStrokeStr[2] = {'0', 0}; - if(Stroke) - aStrokeStr[0] = '1'; - while(pStr && *pStr) { const char *pEnd = pStr; @@ -207,31 +204,31 @@ void CConsole::ExecuteLineStroked(int Stroke, const char *pStr, const int Client pEnd++; } - if(ParseStart(&Result, pStr, (pEnd-pStr) + 1) != 0) + if(ParseStart(pResult, pStr, (pEnd-pStr) + 1) != 0) return; - CCommand *pCommand = FindCommand(Result.m_pCommand, m_FlagMask); + CCommand *pCommand = FindCommand(pResult->m_pCommand, m_FlagMask); if(pCommand) { int IsStrokeCommand = 0; - if(Result.m_pCommand[0] == '+') + if(pResult->m_pCommand[0] == '+') { // insert the stroke direction token - Result.AddArgument(aStrokeStr); + pResult->AddArgument(m_paStrokeStr[Stroke]); IsStrokeCommand = 1; } if(Stroke || IsStrokeCommand) { - if(ParseArgs(&Result, pCommand->m_pParams)) + if(ParseArgs(pResult, pCommand->m_pParams)) { char aBuf[256]; str_format(aBuf, sizeof(aBuf), "Invalid arguments... Usage: %s %s", pCommand->m_pName, pCommand->m_pParams); Print(aBuf); } if (pCommand->m_Level <= ClientLevel) { - pCommand->m_pfnCallback(&Result, pCommand->m_pUserData, ClientId); + pCommand->m_pfnCallback(pResult, pCommand->m_pUserData, ClientId); } else { char aBuf[256]; if (pCommand->m_Level == 100 && ClientLevel < 100) @@ -247,7 +244,7 @@ void CConsole::ExecuteLineStroked(int Stroke, const char *pStr, const int Client else if(Stroke) { char aBuf[256]; - str_format(aBuf, sizeof(aBuf), "No such command: %s.", Result.m_pCommand); + str_format(aBuf, sizeof(aBuf), "No such command: %s.", pResult->m_pCommand); Print(aBuf); } @@ -400,6 +397,10 @@ static void StrVariableCommand(IConsole::IResult *pResult, void *pUserData, int CConsole::CConsole(int FlagMask) { m_FlagMask = FlagMask; + m_StoreCommands = true; + m_paStrokeStr[0] = "0"; + m_paStrokeStr[1] = "1"; + m_ExecutionQueue.Reset(); m_pFirstCommand = 0; m_pFirstExec = 0; m_pPrintCallbackUserdata = 0; @@ -493,6 +494,17 @@ void CConsole::Chain(const char *pName, FChainCommandCallback pfnChainFunc, void pCommand->m_pUserData = pChainInfo; } +void CConsole::StoreCommands(bool Store, int ClientId) +{ + if(!Store) + { + for(CExecutionQueue::CQueueEntry *pEntry = m_ExecutionQueue.m_pFirst; pEntry != m_ExecutionQueue.m_pLast; pEntry = pEntry->m_pNext) + pEntry->m_pfnCommandCallback(&pEntry->m_Result, pEntry->m_pCommandUserData, ClientId); + m_ExecutionQueue.Reset(); + } + m_StoreCommands = Store; +} + IConsole::CCommandInfo *CConsole::GetCommandInfo(const char *pName, int FlagMask) { diff --git a/src/engine/shared/console.h b/src/engine/shared/console.h index 17907cc94..8d4edbac2 100644 --- a/src/engine/shared/console.h +++ b/src/engine/shared/console.h @@ -2,6 +2,7 @@ #define ENGINE_SHARED_CONSOLE_H #include +#include "memheap.h" class CConsole : public IConsole { @@ -25,6 +26,8 @@ class CConsole : public IConsole }; int m_FlagMask; + bool m_StoreCommands; + const char *m_paStrokeStr[2]; CCommand *m_pFirstCommand; class CExecFile @@ -75,6 +78,34 @@ class CConsole : public IConsole int ParseStart(CResult *pResult, const char *pString, int Length); int ParseArgs(CResult *pResult, const char *pFormat); + class CExecutionQueue + { + CHeap m_Queue; + + public: + struct CQueueEntry + { + CQueueEntry *m_pNext; + FCommandCallback m_pfnCommandCallback; + void *m_pCommandUserData; + CResult m_Result; + } *m_pFirst, *m_pLast; + + void AddEntry() + { + CQueueEntry *pEntry = static_cast(m_Queue.Allocate(sizeof(CQueueEntry))); + pEntry->m_pNext = 0; + m_pLast->m_pNext = pEntry; + m_pLast = pEntry; + } + void Reset() + { + m_Queue.Reset(); + m_pFirst = m_pLast = static_cast(m_Queue.Allocate(sizeof(CQueueEntry))); + m_pLast->m_pNext = 0; + } + } m_ExecutionQueue; + CCommand *FindCommand(const char *pName, int FlagMask); public: @@ -86,6 +117,7 @@ public: virtual void ParseArguments(int NumArgs, const char **ppArguments); virtual void Register(const char *pName, const char *pParams, int Flags, FCommandCallback pfnFunc, void *pUser, const char *pHelp, const int Level); virtual void Chain(const char *pName, FChainCommandCallback pfnChainFunc, void *pUser); + virtual void StoreCommands(bool Store, int ClientId); virtual void ExecuteLine(const char *pStr, const int ClientLevel, const int ClientId); virtual void ExecuteFile(const char *pFilename); diff --git a/src/engine/shared/engine.cpp b/src/engine/shared/engine.cpp index 5cd50cf02..14fb3391b 100644 --- a/src/engine/shared/engine.cpp +++ b/src/engine/shared/engine.cpp @@ -61,6 +61,12 @@ void CEngine::Init(const char *pAppname) //config_reset(); } +void CEngine::InitLogfile() +{ + // open logfile if needed + if(g_Config.m_Logfile[0]) + dbg_logger_file(g_Config.m_Logfile); +} static int HostLookupThread(void *pUser) { diff --git a/src/engine/shared/engine.h b/src/engine/shared/engine.h index ad266ae44..22d03d42e 100644 --- a/src/engine/shared/engine.h +++ b/src/engine/shared/engine.h @@ -17,6 +17,7 @@ class CEngine public: void Init(const char *pAppname); + void InitLogfile(); void HostLookup(CHostLookup *pLookup, const char *pHostname); }; diff --git a/src/engine/shared/kernel.cpp b/src/engine/shared/kernel.cpp index 2c2c7a8b9..bc1cadef9 100644 --- a/src/engine/shared/kernel.cpp +++ b/src/engine/shared/kernel.cpp @@ -45,6 +45,12 @@ public: virtual bool RegisterInterfaceImpl(const char *pName, IInterface *pInterface) { // TODO: More error checks here + if(!pInterface) + { + dbg_msg("kernel", "ERROR: couldn't register interface %s. null pointer given", pName); + return false; + } + if(m_NumInterfaces == MAX_INTERFACES) { dbg_msg("kernel", "ERROR: couldn't register interface '%s'. maximum of interfaces reached", pName); @@ -53,7 +59,7 @@ public: if(FindInterfaceInfo(pName) != 0) { - dbg_msg("kernel", "ERROR: couldn't register interface '%s'. interface already exists"); + dbg_msg("kernel", "ERROR: couldn't register interface '%s'. interface already exists", pName); return false; } diff --git a/src/engine/shared/storage.cpp b/src/engine/shared/storage.cpp index 643198350..7820c5007 100644 --- a/src/engine/shared/storage.cpp +++ b/src/engine/shared/storage.cpp @@ -18,7 +18,7 @@ public: m_aDatadir[0] = 0; } - int Init(const char *pApplicationName, const char *pArgv0) + int Init(const char *pApplicationName, int NumArgs, const char **ppArguments) { char aPath[1024] = {0}; fs_storage_path(pApplicationName, m_aApplicationSavePath, sizeof(m_aApplicationSavePath)); @@ -39,8 +39,7 @@ public: str_format(aPath, sizeof(aPath), "%s/demos", m_aApplicationSavePath); fs_makedir(aPath); } - - return FindDatadir(pArgv0); + return FindDatadir(ppArguments[0]); } int FindDatadir(const char *pArgv0) @@ -184,10 +183,10 @@ public: return 0; } - static IStorage *Create(const char *pApplicationName, const char *pArgv0) + static IStorage *Create(const char *pApplicationName, int NumArgs, const char **ppArguments) { CStorage *p = new CStorage(); - if(p->Init(pApplicationName, pArgv0)) + if(p && p->Init(pApplicationName, NumArgs, ppArguments)) { delete p; p = 0; @@ -200,4 +199,4 @@ public: } }; -IStorage *CreateStorage(const char *pApplicationName, const char *pArgv0) { return CStorage::Create(pApplicationName, pArgv0); } +IStorage *CreateStorage(const char *pApplicationName, int NumArgs, const char **ppArguments) { return CStorage::Create(pApplicationName, NumArgs, ppArguments); } diff --git a/src/engine/storage.h b/src/engine/storage.h index 9b24f42e5..cbb299713 100644 --- a/src/engine/storage.h +++ b/src/engine/storage.h @@ -20,7 +20,7 @@ public: virtual const char* ApplicationSavePath() = 0; }; -extern IStorage *CreateStorage(const char *pApplicationName, const char *pArgv0); +extern IStorage *CreateStorage(const char *pApplicationName, int NumArgs, const char **ppArguments); #endif diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index 7d9c9d7ee..c1ad18f28 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -63,6 +63,8 @@ void CMenus::RenderServerbrowserServerList(CUIRect View) {-1, -1, " ", 1, 10.0f, 0, {0}, {0}}, {COL_PING, IServerBrowser::SORT_PING, "Ping", 1, 40.0f, FIXED, {0}, {0}}, }; + // This is just for scripts/update_localization.py to work correctly (all other strings are already Localize()'d somewhere else). Don't remove! + // Localize("Type"); int NumCols = sizeof(s_aCols)/sizeof(CColumn); diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp index f8cf8e4f3..231cd83a5 100644 --- a/src/game/client/components/menus_demo.cpp +++ b/src/game/client/components/menus_demo.cpp @@ -490,7 +490,7 @@ void CMenus::RenderDemoList(CUIRect MainView) { const char *pError = Client()->DemoPlayer_Play(m_lDemos[s_SelectedItem].m_aFilename); if(pError) - PopupMessage(Localize("Error"), Localize(pError), Localize("Ok")); + PopupMessage(Localize("Error"), str_comp(pError, "error loading demo") ? pError : Localize("error loading demo"), Localize("Ok")); } } } diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 6d9bf5ef9..364d0b82e 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -139,7 +139,10 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView) Button.VSplitLeft(100.0f, 0, &Button); str_format(aBuf, sizeof(aBuf), "%s", g_Config.m_PlayerSkin); - UI()->DoLabel(&Button, aBuf, 14.0, -1); + CTextCursor Cursor; + TextRender()->SetCursor(&Cursor, Button.x, Button.y, 14.0f, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END); + Cursor.m_LineWidth = SkinRect.w-(Button.x-SkinRect.x)-5.0f; + TextRender()->TextEx(&Cursor, aBuf, -1); } RightView.HSplitTop(20.0f, &Button, &RightView); @@ -285,7 +288,6 @@ typedef struct static CKeyInfo gs_aKeys[] = { - // we need to do localize so the scripts can pickup the string { "Move left", "+left", 0}, // Localize - these strings are localized within CLocConstString { "Move right", "+right", 0 }, { "Jump", "+jump", 0 }, @@ -309,6 +311,12 @@ static CKeyInfo gs_aKeys[] = { "Screenshot", "screenshot", 0 }, { "Scoreboard", "+scoreboard", 0 }, }; +/* This is for scripts/update_localization.py to work, don't remove! + Localize("Move left");Localize("Move right");Localize("Jump");Localize("Fire");Localize("Hook");Localize("Hammer"); + Localize("Pistol");Localize("Shotgun");Localize("Grenade");Localize("Rifle");Localize("Next weapon");Localize("Prev. weapon"); + Localize("Vote yes");Localize("Vote no");Localize("Chat");Localize("Team chat");Localize("Show chat");Localize("Emoticon"); + Localize("Console");Localize("Remote console");Localize("Screenshot");Localize("Scoreboard"); +*/ const int g_KeyCount = sizeof(gs_aKeys) / sizeof(CKeyInfo); @@ -625,15 +633,16 @@ void CMenus::RenderSettingsSound(CUIRect MainView) } } -struct LANGUAGE +class CLanguage { - LANGUAGE() {} - LANGUAGE(const char *n, const char *f) : m_Name(n), m_FileName(f) {} +public: + CLanguage() {} + CLanguage(const char *n, const char *f) : m_Name(n), m_FileName(f) {} string m_Name; string m_FileName; - bool operator<(const LANGUAGE &Other) { return m_Name < Other.m_Name; } + bool operator<(const CLanguage &Other) { return m_Name < Other.m_Name; } }; @@ -644,7 +653,7 @@ void GatherLanguages(const char *pName, int IsDir, void *pUser) if(IsDir || pName[0] == '.') return; - sorted_array &Languages = *((sorted_array *)pUser); + sorted_array &Languages = *((sorted_array *)pUser); char aFileName[128]; str_format(aFileName, sizeof(aFileName), "data/languages/%s", pName); @@ -657,19 +666,19 @@ void GatherLanguages(const char *pName, int IsDir, void *pUser) if(*p == '.') *p = 0; - Languages.add(LANGUAGE(NiceName, aFileName)); + Languages.add(CLanguage(NiceName, aFileName)); } void CMenus::RenderSettingsGeneral(CUIRect MainView) { static int s_LanguageList = 0; static int s_SelectedLanguage = 0; - static sorted_array s_Languages; + static sorted_array s_Languages; static float s_ScrollValue = 0; if(s_Languages.size() == 0) { - s_Languages.add(LANGUAGE("English", "")); + s_Languages.add(CLanguage("English", "")); fs_listdir("data/languages", GatherLanguages, &s_Languages); for(int i = 0; i < s_Languages.size(); i++) if(str_comp(s_Languages[i].m_FileName, g_Config.m_ClLanguagefile) == 0) @@ -684,7 +693,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView) CUIRect List = MainView; UiDoListboxStart(&s_LanguageList , &List, 24.0f, Localize("Language"), "", s_Languages.size(), 1, s_SelectedLanguage, s_ScrollValue); - for(sorted_array::range r = s_Languages.all(); !r.empty(); r.pop_front()) + for(sorted_array::range r = s_Languages.all(); !r.empty(); r.pop_front()) { CListboxItem Item = UiDoListboxNextItem(&r.front()); diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index a3f618abe..2b47af1fe 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -99,11 +99,6 @@ static int gs_LoadTotal; } }*/ -static void ConServerDummy(IConsole::IResult *pResult, void *pUserData) -{ - dbg_msg("client", "this command is not available on the client"); -} - #include const char *CGameClient::Version() { return GAME_VERSION; } @@ -187,16 +182,16 @@ void CGameClient::OnConsoleInit() Console()->Register("kill", "", CFGFLAG_CLIENT, ConKill, this, "Kill yourself"); // register server dummy commands for tab completion - Console()->Register("tune", "si", CFGFLAG_SERVER, ConServerDummy, 0, "Tune variable to value"); - Console()->Register("tune_reset", "", CFGFLAG_SERVER, ConServerDummy, 0, "Reset tuning"); - Console()->Register("tune_dump", "", CFGFLAG_SERVER, ConServerDummy, 0, "Dump tuning"); - Console()->Register("change_map", "r", CFGFLAG_SERVER, ConServerDummy, 0, "Change map"); - Console()->Register("restart", "?i", CFGFLAG_SERVER, ConServerDummy, 0, "Restart in x seconds"); - Console()->Register("broadcast", "r", CFGFLAG_SERVER, ConServerDummy, 0, "Broadcast message"); - //MACRO_REGISTER_COMMAND("say", "r", CFGFLAG_SERVER, con_serverdummy, 0); - Console()->Register("set_team", "ii", CFGFLAG_SERVER, ConServerDummy, 0, "Set team of player to team"); - Console()->Register("addvote", "r", CFGFLAG_SERVER, ConServerDummy, 0, "Add a voting option"); - //MACRO_REGISTER_COMMAND("vote", "", CFGFLAG_SERVER, con_serverdummy, 0); + Console()->Register("tune", "si", CFGFLAG_SERVER, 0, 0, "Tune variable to value"); + Console()->Register("tune_reset", "", CFGFLAG_SERVER, 0, 0, "Reset tuning"); + Console()->Register("tune_dump", "", CFGFLAG_SERVER, 0, 0, "Dump tuning"); + Console()->Register("change_map", "r", CFGFLAG_SERVER, 0, 0, "Change map"); + Console()->Register("restart", "?i", CFGFLAG_SERVER, 0, 0, "Restart in x seconds"); + Console()->Register("broadcast", "r", CFGFLAG_SERVER, 0, 0, "Broadcast message"); + Console()->Register("say", "r", CFGFLAG_SERVER, 0, 0, "Say in chat"); + Console()->Register("set_team", "ii", CFGFLAG_SERVER, 0, 0, "Set team of player to team"); + Console()->Register("addvote", "r", CFGFLAG_SERVER, 0, 0, "Add a voting option"); + Console()->Register("vote", "r", CFGFLAG_SERVER, 0, 0, "Force a vote to yes/no"); // propagate pointers diff --git a/src/game/client/render.cpp b/src/game/client/render.cpp index ee4dc9d9a..2b773112a 100644 --- a/src/game/client/render.cpp +++ b/src/game/client/render.cpp @@ -292,8 +292,8 @@ void CRenderTools::MapscreenToWorld(float CenterX, float CenterY, float Parallax Height *= Zoom; pPoints[0] = OffsetX+CenterX-Width/2; pPoints[1] = OffsetY+CenterY-Height/2; - pPoints[2] = OffsetX+CenterX+Width/2; - pPoints[3] = OffsetY+CenterY+Height/2; + pPoints[2] = pPoints[0]+Width; + pPoints[3] = pPoints[1]+Height; } void CRenderTools::RenderTilemapGenerateSkip(class CLayers *pLayers) diff --git a/src/game/client/render_map.cpp b/src/game/client/render_map.cpp index 0354b9d54..2d0875caf 100644 --- a/src/game/client/render_map.cpp +++ b/src/game/client/render_map.cpp @@ -241,8 +241,8 @@ void CRenderTools::RenderTilemap(CTile *pTiles, int w, int h, float Scale, vec4 int ty = Index/16; int Px0 = tx*(1024/16); int Py0 = ty*(1024/16); - int Px1 = (tx+1)*(1024/16)-1; - int Py1 = (ty+1)*(1024/16)-1; + int Px1 = Px0+(1024/16)-1; + int Py1 = Py0+(1024/16)-1; float u0 = Nudge + Px0/TexSize+Frac; float v0 = Nudge + Py0/TexSize+Frac; diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp index 015b9946d..3b1a01e0b 100644 --- a/src/game/editor/ed_editor.cpp +++ b/src/game/editor/ed_editor.cpp @@ -626,7 +626,7 @@ void CEditor::DoToolbar(CUIRect ToolBar) // animation button TB_Top.VSplitLeft(40.0f, &Button, &TB_Top); static int s_AnimateButton = 0; - if(DoButton_Editor(&s_AnimateButton, Localize("Anim"), m_Animate, &Button, 0, ("[ctrl+m] Toggle animation")) || + if(DoButton_Editor(&s_AnimateButton, Localize("Anim"), m_Animate, &Button, 0, Localize("[ctrl+m] Toggle animation")) || (Input()->KeyDown('m') && (Input()->KeyPressed(KEY_LCTRL) || Input()->KeyPressed(KEY_RCTRL)))) { m_AnimateStart = time_get(); @@ -1718,12 +1718,12 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) { LayersBox.HSplitTop(12.0f, &Slot, &LayersBox); Slot.VSplitLeft(12, &VisibleToggle, &Slot); - if(DoButton_Ex(&m_Map.m_lGroups[g]->m_Visible, m_Map.m_lGroups[g]->m_Visible?"V":"H", 0, &VisibleToggle, 0, "Toggle group visibility", CUI::CORNER_L)) + if(DoButton_Ex(&m_Map.m_lGroups[g]->m_Visible, m_Map.m_lGroups[g]->m_Visible?"V":"H", 0, &VisibleToggle, 0, Localize("Toggle group visibility"), CUI::CORNER_L)) m_Map.m_lGroups[g]->m_Visible = !m_Map.m_lGroups[g]->m_Visible; str_format(aBuf, sizeof(aBuf),"#%d %s", g, m_Map.m_lGroups[g]->m_pName); if(int Result = DoButton_Ex(&m_Map.m_lGroups[g], aBuf, g==m_SelectedGroup, &Slot, - BUTTON_CONTEXT, "Select group. Right click for properties.", CUI::CORNER_R)) + BUTTON_CONTEXT, Localize("Select group. Right click for properties."), CUI::CORNER_R)) { m_SelectedGroup = g; m_SelectedLayer = 0; @@ -2286,31 +2286,18 @@ void CEditor::RenderStatusbar(CUIRect View) void CEditor::RenderEnvelopeEditor(CUIRect View) { if(m_SelectedEnvelope < 0) m_SelectedEnvelope = 0; - if(m_SelectedEnvelope >= m_Map.m_lEnvelopes.size()) m_SelectedEnvelope--; + if(m_SelectedEnvelope >= m_Map.m_lEnvelopes.size()) m_SelectedEnvelope = m_Map.m_lEnvelopes.size()-1; CEnvelope *pEnvelope = 0; if(m_SelectedEnvelope >= 0 && m_SelectedEnvelope < m_Map.m_lEnvelopes.size()) pEnvelope = m_Map.m_lEnvelopes[m_SelectedEnvelope]; - bool ShowColorBar = false; - if(pEnvelope && pEnvelope->m_Channels == 4) - ShowColorBar = true; - CUIRect ToolBar, CurveBar, ColorBar; View.HSplitTop(15.0f, &ToolBar, &View); View.HSplitTop(15.0f, &CurveBar, &View); ToolBar.Margin(2.0f, &ToolBar); CurveBar.Margin(2.0f, &CurveBar); - if(ShowColorBar) - { - View.HSplitTop(20.0f, &ColorBar, &View); - ColorBar.Margin(2.0f, &ColorBar); - RenderBackground(ColorBar, ms_CheckerTexture, 16.0f, 1.0f); - } - - RenderBackground(View, ms_CheckerTexture, 32.0f, 0.1f); - // do the toolbar { CUIRect Button; @@ -2327,6 +2314,21 @@ void CEditor::RenderEnvelopeEditor(CUIRect View) if(DoButton_Editor(&s_New2dButton, Localize("Pos.+"), 0, &Button, 0, Localize("Creates a new pos envelope"))) pNewEnv = m_Map.NewEnvelope(3); + // Delete button + if(m_SelectedEnvelope >= 0) + { + ToolBar.VSplitRight(10.0f, &ToolBar, &Button); + ToolBar.VSplitRight(50.0f, &ToolBar, &Button); + static int s_DelButton = 0; + if(DoButton_Editor(&s_DelButton, Localize("Delete"), 0, &Button, 0, Localize("Delete this envelope"))) + { + m_Map.DeleteEnvelope(m_SelectedEnvelope); + if(m_SelectedEnvelope >= m_Map.m_lEnvelopes.size()) + m_SelectedEnvelope = m_Map.m_lEnvelopes.size()-1; + pEnvelope = m_SelectedEnvelope >= 0 ? m_Map.m_lEnvelopes[m_SelectedEnvelope] : 0; + } + } + if(pNewEnv) // add the default points { if(pNewEnv->m_Channels == 4) @@ -2371,6 +2373,17 @@ void CEditor::RenderEnvelopeEditor(CUIRect View) } } + bool ShowColorBar = false; + if(pEnvelope && pEnvelope->m_Channels == 4) + { + ShowColorBar = true; + View.HSplitTop(20.0f, &ColorBar, &View); + ColorBar.Margin(2.0f, &ColorBar); + RenderBackground(ColorBar, ms_CheckerTexture, 16.0f, 1.0f); + } + + RenderBackground(View, ms_CheckerTexture, 32.0f, 0.1f); + if(pEnvelope) { static array Selection; @@ -2692,7 +2705,7 @@ int CEditor::PopupMenuFile(CEditor *pEditor, CUIRect View) if(pEditor->m_aFileName[0]) CallbackSaveMap(pEditor->m_aFileName, pEditor); else - pEditor->InvokeFileDialog(IStorage::TYPE_SAVE, Localize("Save Map"), Localize("Save"), "maps/", "", CallbackSaveMap, pEditor); + pEditor->InvokeFileDialog(IStorage::TYPE_SAVE, Localize("Save map"), Localize("Save"), "maps/", "", CallbackSaveMap, pEditor); return 1; } @@ -2700,7 +2713,7 @@ int CEditor::PopupMenuFile(CEditor *pEditor, CUIRect View) View.HSplitTop(12.0f, &Slot, &View); if(pEditor->DoButton_MenuItem(&s_SaveAsButton, Localize("Save As"), 0, &Slot, 0, Localize("Saves the current map under a new name"))) { - pEditor->InvokeFileDialog(IStorage::TYPE_SAVE, Localize("Save Map"), Localize("Save"), "maps/", "", CallbackSaveMap, pEditor); + pEditor->InvokeFileDialog(IStorage::TYPE_SAVE, Localize("Save map"), Localize("Save"), "maps/", "", CallbackSaveMap, pEditor); return 1; } @@ -2900,6 +2913,33 @@ void CEditor::Reset(bool CreateDefault) m_MouseDeltaWy = 0; } +void CEditorMap::DeleteEnvelope(int Index) +{ + if(Index < 0 || Index >= m_lEnvelopes.size()) + return; + + // fix links between envelopes and quads + for(int i = 0; i < m_lGroups.size(); ++i) + for(int j = 0; j < m_lGroups[i]->m_lLayers.size(); ++j) + if(m_lGroups[i]->m_lLayers[j]->m_Type == LAYERTYPE_QUADS) + { + CLayerQuads *Layer = static_cast(m_lGroups[i]->m_lLayers[j]); + for(int k = 0; k < Layer->m_lQuads.size(); ++k) + { + if(Layer->m_lQuads[k].m_PosEnv == Index) + Layer->m_lQuads[k].m_PosEnv = -1; + else if(Layer->m_lQuads[k].m_PosEnv > Index) + Layer->m_lQuads[k].m_PosEnv--; + if(Layer->m_lQuads[k].m_ColorEnv == Index) + Layer->m_lQuads[k].m_ColorEnv = -1; + else if(Layer->m_lQuads[k].m_ColorEnv > Index) + Layer->m_lQuads[k].m_ColorEnv--; + } + } + + m_lEnvelopes.remove_index(Index); +} + void CEditorMap::MakeGameLayer(CLayer *pLayer) { m_pGameLayer = (CLayerGame *)pLayer; diff --git a/src/game/editor/ed_editor.h b/src/game/editor/ed_editor.h index a7d742a86..e459e70f8 100644 --- a/src/game/editor/ed_editor.h +++ b/src/game/editor/ed_editor.h @@ -272,6 +272,8 @@ public: m_lEnvelopes.add(e); return e; } + + void DeleteEnvelope(int Index); CLayerGroup *NewGroup() { diff --git a/src/game/editor/ed_io.cpp b/src/game/editor/ed_io.cpp index c26661385..4d5140514 100644 --- a/src/game/editor/ed_io.cpp +++ b/src/game/editor/ed_io.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "ed_editor.h" template @@ -323,7 +324,7 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName) Item.m_Channels = m_lEnvelopes[e]->m_Channels; Item.m_StartPoint = PointCount; Item.m_NumPoints = m_lEnvelopes[e]->m_lPoints.size(); - Item.m_Name = -1; + StrToInts(Item.m_aName, sizeof(Item.m_aName)/sizeof(int), m_lEnvelopes[e]->m_aName); df.AddItem(MAPITEMTYPE_ENVELOPE, e, sizeof(Item), &Item); PointCount += Item.m_NumPoints; @@ -552,6 +553,8 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName) CEnvelope *pEnv = new CEnvelope(pItem->m_Channels); pEnv->m_lPoints.set_size(pItem->m_NumPoints); mem_copy(pEnv->m_lPoints.base_ptr(), &pPoints[pItem->m_StartPoint], sizeof(CEnvPoint)*pItem->m_NumPoints); + if(pItem->m_aName[0] != -1) // compatibility with old maps + IntsToStr(pItem->m_aName, sizeof(pItem->m_aName)/sizeof(int), pEnv->m_aName); m_lEnvelopes.add(pEnv); } } diff --git a/src/game/editor/ed_layer_tiles.cpp b/src/game/editor/ed_layer_tiles.cpp index d093cab24..e7751d099 100644 --- a/src/game/editor/ed_layer_tiles.cpp +++ b/src/game/editor/ed_layer_tiles.cpp @@ -292,8 +292,8 @@ int CLayerTiles::RenderProperties(CUIRect *pToolBox) }; CProperty aProps[] = { - {Localize("Width"), m_Width, PROPTYPE_INT_STEP, 1, 1000000000}, - {Localize("Height"), m_Height, PROPTYPE_INT_STEP, 1, 1000000000}, + {Localize("Width"), m_Width, PROPTYPE_INT_SCROLL, 1, 1000000000}, + {Localize("Height"), m_Height, PROPTYPE_INT_SCROLL, 1, 1000000000}, {Localize("Image"), m_Image, PROPTYPE_IMAGE, 0, 0}, {0}, }; diff --git a/src/game/mapitems.h b/src/game/mapitems.h index ff66b6ce6..1f70652aa 100644 --- a/src/game/mapitems.h +++ b/src/game/mapitems.h @@ -242,7 +242,7 @@ struct CMapItemEnvelope int m_Channels; int m_StartPoint; int m_NumPoints; - int m_Name; + int m_aName[8]; } ; #endif diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 0bf91010e..3e4e6f1ed 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -1006,7 +1006,7 @@ void CCharacter::Snap(int SnappingClient) CNetObj_Character *Character = static_cast(Server()->SnapNewItem(NETOBJTYPE_CHARACTER, m_pPlayer->GetCID(), sizeof(CNetObj_Character))); // write down the m_Core - if(GameServer()->m_World.m_Paused) + if(!m_ReckoningTick || GameServer()->m_World.m_Paused) { // no dead reckoning when paused because the client doesn't know // how far to perform the reckoning diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 83ad6fb5a..55ce9d7db 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -756,6 +756,12 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId) int64 Now = Server()->Tick(); p->m_Last_VoteTry = Now; + if(p->GetTeam() == -1) + { + SendChatTarget(ClientId, "Spectators aren't allowed to start a vote."); + return; + } + if(m_VoteCloseTime) { SendChatTarget(ClientId, "Wait for current vote to end before calling a new one."); diff --git a/src/tools/map_resave.cpp b/src/tools/map_resave.cpp index a6c55c43d..ce17e336e 100644 --- a/src/tools/map_resave.cpp +++ b/src/tools/map_resave.cpp @@ -5,14 +5,14 @@ int main(int argc, const char **argv) { - IStorage *pStorage = CreateStorage("Teeworlds", argv[0]); + IStorage *pStorage = CreateStorage("Teeworlds", argc, argv); int Index, Id = 0, Type = 0, Size; void *pPtr; char aFileName[1024]; CDataFileReader DataFile; CDataFileWriter df; - if(argc != 3) + if(!pStorage || argc != 3) return -1; str_format(aFileName, sizeof(aFileName), "maps/%s", argv[2]);