Commit Graph

280 Commits (48ae42f87e82f26e696ba62c1f4de82d90949522)

Author SHA1 Message Date
Armin Burgmeier 2cf11a1d6a Pre-compute Z values before face ordering (#984)
Pre-computed floating point numbers can be safely used in the comparison
function, whereas recomputation every time the sort function is called might
lead to a crash when the computed number is slightly differently every time,
because the sort function would return different results for the same faces.
2013-12-16 11:55:29 +01:00
Armin Burgmeier eddbbe3857 Make sure we never create mesh instances with 0 faces 2013-12-16 08:13:59 +01:00
Tobias Zwick fe2a400c02 replace global function GetTime() with class function C4TimeMilliseconds::Now() 2013-12-07 21:27:01 +07:00
Tobias Zwick 94c618d153 add new type C4TimeMilliseconds for time measurements to solve problems when GetTime() overflows (#251)
The new type C4TimeMilliseconds behaves for the most part like a uint32_t but is overflow-proof in comparisons.
In some places, a 0-value (or uint_max) of the variable storing the time had the special meaning "not set yet". This has been resolved by having it as a pointer to C4TimeMilliseconds with NULL meaning that it has not been set yet.
2013-12-04 19:35:07 +07:00
Tobias Zwick a8a8322dfb use %u to format unsigned ints (times) 2013-12-04 12:51:46 +07:00
Sven Eberhardt 6407c7cd2b Some more fixes for time_t change.
Some format strings had to be adjusted and clients always had ping timeout on join. Let's hope this fixes it.
2013-12-01 16:34:47 +01:00
Nicolas Hake 52fd2679cd Fix line endings broken by ecf538c, 7b9c1d5, and ceca8b8 2013-11-29 14:18:48 +01:00
Tobias Zwick ecf538cd1f refactor: consistently use time_t t... variables for times in sound system, stats, application and player controls 2013-11-29 14:16:14 +07:00
David Dormagen fe28104f98 prevent crash when StdSubMeshInstance face count is 0, added assertion though, because this should not happen to my knowledge
I believe a possible cause for this is a object's model with a very low completion. However, I am not sure where the right place is to make sure everything goes alright in that case.
2013-11-26 21:25:07 +01:00
Tim Blume 32968f2735 Remove more mentions of D3D 2013-11-25 14:35:51 +01:00
Nicolas Hake e753bf8168 Replace ResTable with a proper dictionary
ResTable (the main system string table) was a home-grown hashmap that
did not cope with collisions at all. Since we already have a proper
dictionary in C4LangStringTable, use that instead.
2013-10-19 19:28:54 +02:00
Nicolas Hake 58a39e972f Improve C4Object const correctness 2013-08-31 23:23:35 +02:00
Nicolas Hake 9ceb69236b Remove unused Base64 codec 2013-08-04 18:10:10 +02:00
Sven Eberhardt 49c16723a9 Change Random() on negative values to always return zero.
Before, it would return huge, positive values (e.g. Random(-20) could produce 47384782) which leads to all kinds of trouble in script (like #968)
2013-07-02 21:16:59 +02:00
Martin Plicht 405453aed3 Merge branch 'debugrecoption' 2013-05-31 14:39:16 +02:00
Armin Burgmeier 695a9a88c3 Add TransformBone and SetAnimationBoneTransform script functions 2013-05-27 21:33:29 +02:00
Armin Burgmeier 90ee4d2380 Fix crash when an object whose mesh is attached to another mesh is removed 2013-05-27 15:55:18 +02:00
Martin Plicht 524fe879aa Make DEBUGREC define a commandline option 2013-05-25 22:51:32 +02:00
Günther Brammer 74eda19838 Round C4Fixed towards positive infinity instead of away from zero
The movement code relies on itofix(a + 1) == itofix(a) + 1, which requires
always rounding in the same direction. Since negative numbers are rounded
less often (Objects rarely are outside the landscape), change the behavior
for them.
2013-05-25 18:44:05 +02:00
Günther Brammer bf130d664d Use a less convoluted way to avoid overflow when rounding large C4Fixeds
Instead of using a special path for the numbers that would overflow, make
use of the available bits to avoid overflow entirely.
2013-05-25 18:44:05 +02:00
Sven Eberhardt 3e56ae6757 Fix saving of zeroes in vertex data that was nonzero in the definition. 2013-04-01 00:46:14 +02:00
Armin Burgmeier 90fbabd20f Implement depth_check for material scripts 2013-03-31 17:14:13 +02:00
Nicolas Hake 459fce0758 Replace std::auto_ptr with std::unique_ptr
std::auto_ptr has awkward copy semantics and is deprecated in C++11.
2013-03-26 15:43:01 +01:00
Sven Eberhardt 57e63a5275 Added support for scripted maps (Map.c) and documentation. 2013-03-19 00:36:06 +01:00
Günther Brammer b19259a22c Switch to a better random number generator
This is already used in C4Landscape::ChunkyRandom, where it produces good
results.
2013-03-10 17:37:30 +01:00
Nicolas Hake 365d72fee1 Fix incorrect reloading of animations (#837)
Animation nodes accidentally did not have the correct
animation parent set when they were deserialized.

Closes #837, #872, #916.
2013-02-04 19:06:08 +01:00
Armin Burgmeier 43a2836279 Implement texture unit blending in material scripts with a shader
This might make the rendering a bit quicker, since the whole texture
environment setup that we do every frame is no longer required --
instead only the shader is bound and a few variables uploaded. However,
this was not the main motivation behind this change.

It also simplifies the code a bit. The texture environment setup is
replaced by GLSL code generation. Another small benefit is that for
texture units in material scripts that do not use an actual texture
image no hardware TIU is being used. This reduces the number of hardware
TIUs required for rendering the Clonk from 3 to 2.

The main benefit of this change, however, is that material specific
and clonk specific color variations can be applied correctly. This mainly
concerns ClrModulation and MOD2 drawing. Before, the ClrModulation was
mixed with the material color, which could lead to incorrect results
depending on what the texture units were doing. Now it is being applied
by the shader after all texture units in the material scripts have been
processed.

Another motivation of this change is to implement support for custom
shaders, which is already foreseen by OGRE material scripts. The
specification has only to be implemented. With this change in place,
both custom shaders and "fixed" processing can share the same code in
the engine, since both end up using a shader for the mesh rendering.

The shader currently works only for directional lights, but should be
easy to extend to also support point lights.
2013-02-03 16:26:01 +01:00
Martin Plicht 379cd1c210 StdStrBuf::AppendFormatV: Pass copied va_list to vsnprintf so the second iteration of the while loop does not crash 2013-01-13 11:31:13 +01:00
Günther Brammer 864c5c7ea8 copyright notices update 2012 2013-01-12 16:31:40 +01:00
Günther Brammer 6a6190564f Remove some forward declarations that are already in C4Prototypes.h 2012-12-31 22:03:12 +01:00
Günther Brammer 7967d94a59 Merge StdFont.cpp and C4Fonts.cpp 2012-11-12 02:30:16 +01:00
Günther Brammer a5b83665af Store all channels of a color together in CStdPalette
This mostly simplifies things, since most other places use an 32 bit
integer to store colors, but might even improve performance through better
cache locality.
2012-08-16 00:45:27 +02:00
Armin Burgmeier 1660ed310a Add support for the OGRE 1.8 binary mesh format 2012-10-08 21:50:20 +02:00
Armin Burgmeier 6661f8b8cb Fix a crash when attaching a mesh by definition fails 2012-06-30 22:04:48 +02:00
Günther Brammer 15b07ca717 Start counting lines and columns in text files with 1
I checked two text editors, and they did that, too.
Also implement the special rules for tab stops, assuming a tab width of 8.
2012-05-16 23:21:14 +02:00
Nicolas Hake 1711b72baf Return U+FFFD REPLACEMENT CHARACTER instead of question mark for invalid utf8
Since U+003F QUESTION MARK is a potentially valid character in a unicode string,
have the text iterator return U+FFFD if it can't decode its input instead. This
way the caller can be certain that the input isn't a proper question mark and
doesn't accidentally use it, e.g. as a wildcard.
2012-05-04 18:12:35 +02:00
Armin Burgmeier 04af38622d Use 64 bit integers to multiply fixpoint numbers
gcc 4.6 generates better code for FIXED_EMULATE_64BIT disablen for both
32 and 64 bit. It properly recognizes that the 32,32->64 multiplication
instruction of the x86 is the right choice for the job whereas the more
complicated FIXED_EMULATE_64BIT version requires multiple multiplications

Thanks Günther for checking this! :)
2012-05-01 23:05:40 +02:00
Armin Burgmeier 5d96ca83c9 Fix overflow in C4Fixed multiplication
This would happen when the product of the lower significant part, which is
between 0 and 65535 (even though C4Fixed is a signed data type!) exceeds
2^31, for example for val=36864, fVal2=61440.
2012-05-01 22:59:55 +02:00
Günther Brammer 1a29f8625d Reorder engine source file organization a bit
This mostly consists of flattening the hierarchy, splitting the
graphics stuff out of platform, and a few smaller cleanups.
2012-04-27 19:04:43 +02:00
Günther Brammer b4fd8fcd15 linux: Add O_CLOEXEC to various open calls
This should prevent some file descriptor leakage from forks that
some libraries we use do.
2012-03-05 01:33:02 +01:00
Günther Brammer dfea0914a9 Merge the functions pointer branch 2012-03-09 17:42:48 +01:00
Armin Burgmeier 7f5f916e76 Draw only partial set of faces for buildings in construction 2012-02-26 01:09:42 +01:00
Armin Burgmeier 9d94b1da6e For scaled sprite graphics, don't interpret Picture coordinates as scaled
Otherwise an object with a scale of 5 and a picture of 64x64 (such as the
Metal and the GoldBar objects) cannot properly set the picture rectangle.
2012-02-25 17:35:24 +01:00
Armin Burgmeier 9dc9ad4ca7 Fix initialization of AlphaToCoverage material property 2012-02-19 17:45:01 +01:00
Günther Brammer cd46cf9914 C4SimpleLog defaults to on 2012-02-17 00:25:20 +01:00
Nicolas Hake db9ff85116 Binary mesh loader: Do not reject meshes with multi texturing
We don't support multi texturing in the rendering code, so emit a warning when
this happens
2012-02-16 00:45:48 +01:00
Nicolas Hake ac8edd6e20 Binary mesh loader: Support animations without tracks 2012-02-16 00:34:31 +01:00
Armin Burgmeier 8dae8c111d Implement XML loading support for geometry shared between submeshes
The new OGRE blender exporter (2.6) creates meshes which make use of this
feature.
2012-02-15 23:04:19 +01:00
Armin Burgmeier e52d914638 Read but ignore some more "pass" options in material scripts
These are the ones that the blender 2.6 exporter sets automatically. We don't
support them yet but we want to be able to load the material script
nevertheless. Many of the additional options are set to their default values
anyway.
2012-02-13 23:40:47 +01:00
Armin Burgmeier 0749dcdb9d Replace std::sort by timsort for Face ordering
The usage of timsort instead of std::sort at this point is twofold.  First,
it's faster in our case where the array is already sorted in many cases
(remember this is called at least once a frame). And it's not just a bit
faster either but a lot. I have measured a factor of 7 on my system.

Second, in our Windows autobuilds there is a crash within std::sort which is
very hard to debug because it's hardly reproducible with anything other than
the autobuilds (I tried hard). If the crash goes away with timsort then
great, if not then maybe it's easier to debug since the code is in our tree.
2012-02-01 22:11:46 +01:00
Felix Wagner d468862159 Player options dialogue, let the player choose a clonk skin 2012-01-29 02:16:22 +00:00
Armin Burgmeier b032b6c3e3 Use std::sort again instead of a custom implemantion for debugging purposes
This was committed accidentally. I blame hg for having a crappy ui.
Fixes the display of trees again.
2012-01-28 21:48:07 +01:00
Armin Burgmeier a1370c2954 Rename our custom gz* functions to avoid conflicts with zlib.dll
This fixes the build with native mingw for me.
2012-01-28 17:02:37 +01:00
Armin Burgmeier 7e532c2bd6 Split math functions into StdMeshMath.{h,cpp} 2011-12-29 15:41:52 +01:00
Peter Wortmann 638cb919d4 Fixed line drawing coordinate rounding 2011-11-08 16:22:39 +00:00
Günther Brammer ccbf4d1d45 Consolidate duplicated simple Log functions
The various small utilities do not use the engine Log implementation but
one that simply prints to stdout. Instead of duplicating that one, link a
common one into the utilities.
2011-11-02 21:36:39 +01:00
Günther Brammer b911630578 Replace OpenSSL SHA1 implementation with one copied from boost/uuid
Although the code already uses boost, boost/uuid hides the sha1
implementation in a deeply nested namespace, which is just too bizarre to
use. Also the name of that namespace suggests that it is just an
implementation detail that could go away without notice.
2011-01-10 21:30:40 +01:00
Günther Brammer 5f2f995852 Unify the #include blocks a little bit
One line for C4Include.h, one for the .h corresponding to the .cpp, one
empty line, the other C4* includes, another empty line, external headers.
2011-11-01 23:17:41 +01:00
Nicolas Hake 7c34fa9121 Replace RGB player color selection with an HSV chooser (#679) 2011-10-30 20:43:45 +01:00
Armin Burgmeier e44b216230 Enable face ordering individually for all submeshes 2011-10-15 21:35:39 +02:00
Armin Burgmeier f67b20f3f2 Fix a crash when a mirrored animation has a track for only one pair of bones 2011-10-12 21:13:13 +02:00
Armin Burgmeier 8b3a96dcdb Apply animation mirror to bone translation of all keyframes 2011-10-12 20:50:27 +02:00
Nicolas Hake 5ae60485fc Make OC build again 2011-10-09 20:52:13 +02:00
Peter Wortmann 6835b7939d Fixed some warnings, security 2011-10-08 13:02:15 +01:00
Sven Eberhardt e22049c245 Fix writing of Record.log 2011-10-09 20:11:39 +02:00
Armin Burgmeier b532e77872 Fix the build when building against libpng 1.5 2011-10-09 11:15:02 +02:00
Günther Brammer 1cafba4be8 Rename files implementing C4AbstractApp and C4Window 2011-10-03 17:19:24 +02:00
Günther Brammer c2908d5bd5 Rename CStdDDraw to C4Draw 2011-10-03 16:34:08 +02:00
Günther Brammer 2b6f4432de Rename lpDDraw to pDraw 2011-10-03 16:30:18 +02:00
Günther Brammer ad89e12a2c Rename CTexMgr and CTexRef to C4TexMgr and C4TexRef 2011-10-03 16:16:38 +02:00
Günther Brammer 68d6b34f72 Replace SURFACE with C4Surface * 2011-10-03 16:07:07 +02:00
Günther Brammer 55f6bc8d0f Replace CSurface and C4Surface with just C4Surface
The methods that previously were on C4Surface still are in a separate
file.
2011-10-03 16:06:41 +02:00
Günther Brammer efed250aa7 Rename CMarkup to C4Markup 2011-08-27 21:13:15 +02:00
Günther Brammer 156a502289 Rename CClrModAddMap to C4FogOfWar 2011-08-27 16:41:26 +02:00
Günther Brammer f4ff47239f Rename CBltTransform, CBltVertex, CBltData, CPattern and CGammaControl 2011-09-30 22:15:51 +02:00
Günther Brammer f055ed27e8 Draw PXS Sprites a little bit smoother 2011-05-26 15:03:51 +02:00
Günther Brammer 562816cfe5 Clean up some unused variables and obsolete FIXMEs 2011-09-28 01:09:56 +02:00
Nicolas Hake 3200fdb088 base64: Replaced char literals by hex literals
The base64 decoding lookup table uses '\xff' to denote an invalid
value. On compilers where char is signed, this results in a value of
-1, which cannot be converted to an unsigned char in an aggregate
initializer [dcl.init.aggr p2].
2011-09-28 00:48:00 +02:00
Günther Brammer 9bc61db360 copyright notices update 2011 2011-09-01 16:58:52 +02:00
Sven Eberhardt 3161904bf4 fix C4DrawTransform::IsIdentity 2011-09-01 15:35:12 +02:00
Armin Burgmeier 6c156a22a7 Implement mesh update on definition reload (#76) 2011-08-20 00:01:08 +02:00
Tobias Zwick 532cea1abe removed Cursor graphics in different sizes 2011-08-18 19:06:49 +02:00
Armin Burgmeier e9415252bc Build fix
Apparently std::map::erase does not return an iterator for some STLs.
2011-08-18 00:17:43 +02:00
Armin Burgmeier 771163be4b Correctly reload mesh materials on definition reload
This does not fix #76 yet, but it's a first step.
2011-08-17 23:50:33 +02:00
Nicolas Hake 0f4e6e8ccd win32: Use wide variants of CRT file access APIs 2011-08-11 15:46:06 +02:00
Nicolas Hake 5f923b0b98 win32: Generate wide strings for OutputDebugString 2011-08-11 15:42:00 +02:00
Sven Eberhardt dcb7e4e54d fix memory leak in binary mesh loader 2011-08-08 16:06:16 +02:00
Benjamin Herr 29aa76dd19 fix loading of scaled graphics again 2011-08-06 20:22:55 +02:00
Sven Eberhardt 8c4e08531e fix loading of scaled graphics (Graphics.*.png) 2011-08-05 20:16:08 +02:00
Tobias Zwick 4a517e06b6 #394 - Separate graphic for "Mouse Over" for main-menu buttons and Icons 2011-08-05 14:24:41 +02:00
Tobias Zwick 221aae1bf5 fixed some ridiculous formatting of consts 2011-08-04 01:30:37 +02:00
Günther Brammer 505b616404 Remove obsolete CStdFile::Load/Save 2011-06-19 16:35:06 +02:00
Peter Wortmann 53247e3c26 Increment RandomCount for non-debugrec builds as well 2011-07-17 13:37:27 +01:00
Armin Burgmeier 5cba420382 Make sure [ChildInstance] named section always exists
Otherwise loading a savegame with an attached def mesh fails if the mesh
has neither attached meshes or animation nodes since the [ChildInstance]
section ends up empty in which case StdCompilerIniWrite does not write the
section at all.
2011-06-05 14:12:02 +02:00
Nicolas Hake 23f67b4c8d #606: Accept CSM_Mesh_Bone_Assignment chunks in CSM_Mesh 2011-06-03 21:41:39 +02:00
Peter Wortmann a02ccafc4d Shader landscape rendering, first simple version (scaler, shading) 2011-05-24 00:12:19 +01:00
Nicolas Hake 02416caec5 IsValidUtf8: Obey string length parameter when checking continuation bytes
This fixes a bug where sequences were incorrectly accepted when they ended with
a multibyte sequence, the end of which was beyond the passed string length.
2011-05-17 17:55:27 +02:00
Nicolas Hake 1ba02a610b IsValidUtf8: Correctly mask start byte before calculating code point value
This fixes a bug where valid sequences were incorrectly rejected as having
a value beyond the valid Unicode codepoint range.
2011-05-17 17:53:21 +02:00
Nicolas Hake e791b14af9 Fix #600 (Unable to change resolution and Fullscreen fails)
MultiByteToWideChar doesn't do anything when it gets a buffer length of 0,
so it doesn't nullterminate the memory, so EnumerateDisplayModes fails because
of an invalid monitor id.
2011-05-15 16:06:14 +02:00
Günther Brammer fadacd3bb4 Move StrToI32 to lib/ 2011-05-01 18:55:02 +02:00