When I made the texture array changes I forgot to test the texture
detail feature which caused some visual corruption when using a texture
detail which was less than the maximum. This should fix that.
The minimum and maximum values were not initialized correctly which
caused code which relied on those values to fail unexpectedly.
This assigns the value properly and adds a documentation note which
clarifies when the values are valid.
This is probably a bug from when I changed how those functions worked.
The function is supposed to return if it successfully retreived a value
from the Lua stack but instead of returning true if it was, it returned
the value it just retrieved. This works fine if that value is true but
causes issues if it was false.
The previous fix to the weapon orientation failed to account for the
change from local to global space for the weapon position. This fixes
that by rotating the model positions to world space before submitting
the render call.
This fixes#1647.
The rendering material used by the model render list was reused by
multiple draw call submissions so a non-transparent mesh would reset the
fog value set before which would break meshes submitted after that.
There are still some issues with how the fog is rendered which causes
differences between how opaque and transparent meshes are drawn but I
will fix that in another pull request.
This fixes#1645.
With the recent changes to how fog is handled in nebulas it is now
possible to render decals correctly in a nebula environment so there is
no need to disable decals when the mission is in a nebula.
This changes the decal system so that it is able to modify the normal
map of the scene. I tested this with some existing normal maps but I am
not entirely sure if the tangent matrix I construct uses the right
values so some additional testing with normal maps made specifically for
decals would be good.
This also fixed the issues introduced by the changes to how directional
lighting was handled. Now a decal can have a diffuse and a glow map. The
diffuse map is used to change the values of the color buffer and also
supports ambient lighting. The glow map renders into the emissive buffer
and should be used for effects that should not receive lighting.
The previous method of rendering nebula fog didn't work correctly with
deferred shading since it changed the color of the material which
obviously caused some issues when it received light from a beam or a
weapon. This wasn't very noticable before because the directional lights
were handled correctly but since all the lighting operations have been
moved into the deferred shading phase it is very obvious that something
is wrong with our nebula rendering.
This fixes that by introducing a new shader which does a fullscreen pass
after resolving all the lights. It applies the usual fog formula based
on the depth of the fragment but it can only use a fixed distance range.
FSO support specifying a range for every object type but the default
range I chose should work properly for all ship types.
The new code only applies to opaque meshes. Transparent meshes are
fogged using the standard formula.
There were actually multiple issues here. The addition of color mask and
stencil state to the material system overwrote the state set by the
hardpoint renderer so the stencil buffer was never written or read
correctly. I fixed this by introducing three new model render flags
(there were a few open slots in the bit mask so I used those) which set
the correct state using the material system. That also makes setting up
the rendering environment much easier.
Second, gr_opengl_stencil_set used mixed up parameter values which were
probably broken when I introduced more detailed stencil state tracking.
I restored those values to how they were in 3.8.
This fixes the other issue reported in #1640.
The code previously used the matrix stack for handling the orientation
or the weapon models. That is no longer supported by the model renderer
(since it would make handling the transforms harder for no real reason).
I fixed the issue by passing the object orientation directory to the
model render function.
This is a fix for one of the problems mentioned in #1640.
This can happen if a script tries to determine the length of a sound
before actually playing it. This fixes the assertion by loading the
sound when it is necessary.
The emissive part of the lighting was not using the fog values properly
so ships didn't rendered right in nebulas. This fixes that by applying
the standard fog color transform to the emissive part of the scene.
This is a minor cleanup of how the engine passes vertex attribute data
from one shader stage to the next. The current code uses standalone
attribute variables which require a unique name over the entire shader
program which means that the variable names need to be different when a
geometry shader is used which makes the code more complicated and harder
to understand.
The previous version used NanoVG which caused quite a serious FPS drop.
This adds a buffer batching class which groups line drawing operations
together and submits them to the GPU with a single draw call.
This moves all lighting operations into the deferred shading phase of
the rendering pipeline. Previously, directional lights were applied to
all objects while they were being rendered. This was probably done to
avoid doing multiple full screen passes later but caused some problems
since the color information in the G-buffers was not correct for doing
later lighting operations.
This was especially noticable in dark scenes where point lights would
appear to ignore the color of the rendered objects. This should be fixed
with these changes.
I did some performance testing and to my surprise this actually improves
performance in very demanding scenes. My guess would be that applying
the shadows while rendering the objects caused a lot of overdraw which
is not the case anymore since shadows are only computed for visible
pixels. In simple scenes the opposite happens which leads to decreased
performance in those cases but in my opinion the improvement in
demanding scenes outweights this performance decrease.
Specifying the fog rendering options is now handled by the materials
system and the implementation of gr_set_fog was pretty much empty so I
removed it.
This is mostly intended for total conversions to allow them to set
themselves apart from FS2 based mods. It uses the new in-memory
filesystem to support a default icon in case no icon was specified by
the mod.
By making parse_ai_profiles_tbl() actually check the return value of skip_to_start_of_string_either() (and break if the appropriate characters aren't found), AI profile tables should no longer keep parsing past the end of the file and into invalid memory, until they either find an "#End" in memory somewhere or just plain crash.
As a pleasant bonus, a missing "#End" should now generate an appropriate error message.
There was a slight difference between the GGX function from the main
shader and the deferred shader. The deferred shader didn't use the
fresnel value stored in the G-buffer for some reason.
This can be used for keeping code for common functionality in one file
(e.g. lighting functions). The code which detects include statements is
pretty simple so it may break if it is used in a more complicated.
Circular includes are detected and treated as an error.
This fixes a warning caused by parsing the default ai_profiles table
twice. The default table was moved out of the data/tables folder and
into a special builtin category which will not be included in CFile.
This allows to use more complex file structures in the executable
without requiring that those exist as real files. The rest of the code
does not need to handle the difference between a default file and a real
file anymore which means that it's now possible to embed image files
into the executable since bmpman only needs to use the standard CFile
API.
I added two tests which check if the default file can be found and
opened and if a mod file overrides the default file which should always
be possible.
This assertion could be hit if the player died and the engine tried to
play a sound for the now destroyed ship. Since the existing code already
had a check for the case that the object is an observer I just added
another case for OBJ_GHOST.
This changes the model loading code such that all index and vertex data
is packed in a single GPU buffer for each data type (index and vertex
data are still in separate buffers). This reduces the amount of buffer
rebinding needed when rendering a scene which will reduce the CPU
overhead. Furthermore, this opens up possibilities of future
improvements for which it is beneficial if all data is in the same
buffer (e.g. MultiDrawIndirect rendering).
To manage where to put the data in the GPU buffer I implemented a
custom HeapAllocator which manages where data can be put. It uses a very
primitive first-fit algorithm but that is sufficient for this usage
type. This does add quite a lot of overhead while allocating GPU model
data (I did some tracing and some allocation calls took as long as
130ms).
This fixes#1457.
This allows to render screen space decals into the deferred lighting
buffers no matter how complex the underlying geometry is.
Currently there is only limited support for using this in the engine.
Only weapon impact decals are supported at the moment for testing
purposes.
When Unicode_text_mode was false, unicode::num_codepoints() would return (the size_t equivalent of) a negative number, because it was checking the distance from end to start instead of the distance from start to end.
There are a few new warnings in GCC7 so this makes sure that no warning
gets missed by our CI setup. The new configuration should be updated to
the newest GCC version whenever possible.
The crash described in #1561 was caused by a NULL ai profile. The
profile was not set because the lab system already had a loaded ship
object (see line 2230). These changes make sure that the loaded ship
object is deleted before closing the lab system which ensures that the
ai profile is set the next time the lab is initialized.
This fixes#1561.
While debugging a performance issue reported on Discord I noticed that
the HUD rendering code does not have any tracing scopes. This adds a few
tracing scopes to that code to make performance debugging a bit easier.
Previously the campaign room caused a heap-use-after-free error
(detected by AddressSanitizer) when loading the campaign failed two
times. This fixes the error by resetting the text pointers to their
default values when freeing the campaign list data.
This should be the correct way to set the combined depth/stencil buffer.
This has not been tested yet since I do not have a GPU which causes
these issues.
This fixes#1555.
The normally faster version that was used before misbehaved if that
texture unit already used the specified texture object which caused the
glTexSubImage3D to cause out of bounds issues some times.
This fixes#1554.
This caused a warning in GCC7 which is fixed by this. This will also
initialize the array properly since the previous version may not have
worked correctly even if the entire array woudld have been written (on
all supported platform it would have worked since repeating -1 on all 4
bytes of an int will still produce -1).
The previous code could only handle ASCII data correctly but this new
code is also able to handle UTF-8 data correctly by using the Windows
API function MultiByteToWideChar. Since the conversion only happens in
Windows-only code this is not a portability issue.
This fixes an issue reported on the forums where non-ASCII text was not
spoken correctly by the TTS system.
This add a system for adding generic instances of the DynamicSEXP class
to the SEXP system. The only implementation at the moment is the LuaSEXP
which is used by the mn.addSEXP lua API to allow Lua to add new SEXPs.
Since this requires that FRED also runs lua scripts I added a mod table
option to enable scripting in FRED. Since the current scripts are not
built with FRED in mind it would likely break all these scripts if FRED
would be opened with normal scripting enabled.
This fixes#1320.
I forgot to set the alpha blend mode in the NanoVG changes which meant
that the code used additive blending by default which is not good if the
color in use is black. This sets the blend mode to the value that
corresponds to the values used by the NanoVG reference code.
This was reported by chief1983 on Discord. The standalone server crashed
with a SIGBUS error caused by an invalid socket file handle in
FS2NetD_DataReady(). This should fix that by adding additional checks
where necessary to make sure that our socket is valid when the socket
functions are used.
This was an issue since UTF-8 encoded text can contain -128 as part of
an encoding sequence which causes a lot of issues for the parsing code.
I could not find any indication why the original code didn't use null
bytes from the start and I also couldn't find any code that would break
because of this. If anyone knows why this was done like this please let
me know.
This will remove the dependency on a system version of OpenAL and also
enable the advanced sound code for everyone. This removes the ability to
use a custom OpenAL version but removing the only system dependency we
currently have is worth a lot more than being able to use a custom
OpenAL version.
This adds support for displaying subtitles embedded in movie files. This
supports files with multiple subtitle streams where each stream contains
the subtitles for one language. When the movie file is opened, the
stream for the currently active language will be used and displayed.
This resolves one of the points mentioned in #1522.
This also depends on PR #1484.
This moves all the cutscene specific code out of the movie player code
and into the cutscene code so that the movie player can be reused for
usage in other environments.
This is required for #1041 since an implementation of that feature would
reuse the movie player code of the cutscene code but without all the
main loop stuff.
This allows to set string variables to localized values which will make
translating missions much easier.
This resolves one of the points mentioned in #1522.
If the previous rendering operation left the color mask in any other
state than completely enabled then the clear will only affect the
enabled channels. This makes sure that all channels are enabled before
doing the clear.
This fixes an issue reported on the forums:
https://www.hard-light.net/forums/index.php?topic=94200.msg1859118#msg1859118
This allows to use the XSTR mechanism in script to make translating
script text possible. This is compatible with the existing XSTR format
so automatic tstrings.tbl generator tools should work fine with this.
This resolves point 2 of #1522.
One of the main points of contention when adding the NanoVG based
TrueType text rendering was that it required an external Opengl
renderer which may interfere with our rendering engine by changing
OpenGL state without telling the rest of the engine. Since the rendering
interface for NanoVG is abstract and can be easily replaced, I did just
that and replaced it with an implementation that uses only generic
graphics functions without relying on the specific graphics API.
This will improve the interoperability of NanoVG with our engine and
should make later changes to the rendering engine easier since there is
no external rendering code which may interfere with our own code.
This was an issue since a lot of mods used wrong sounds and after the
FFmpeg changes the code would display a warning for those sounds by
default. This will restore the old behavior of printing the warning to
the log where it is easier to ignore if the mod does not explicitly
support 3.8.0.
This adds proper Unicode support by allowing the parse system to read
UTF-8 encoded files. The new mode is controlled by a mod option which
allows older mods to continue using the legacy text encoding.
That option changes the behavior of several systems in FSO. It disallows
the usage of Volition fonts since they don't support Unicode encoding
and changes a few usages of special characters to their unicode
counterparts of generic rendering solutions.
This fixes#1415.
The previous version used PATH instead of LD_LIBRARY_PATH which may have
caused some issues if the system is configured in a way that depends on
the value of LD_LIBRARY_PATH. It also broke launchers that tried to fix
library issues by changing LD_LIBRARY_PATH.
This changes the batched transform code so that instead of using discard
in the fragment shader it uses the built-in clipping capabilities of
OpenGL for removing invisible sub models. This improves performance in
GPU-limited scenes by ~1ms if shadows are enabled.
The original OpenGL Core changes only used a single vertex array object
for specifying the data layout of our vertex data. This uses the OpenGL
extension GL_ARB_vertex_attrib_binding to extend that so that each
vertex_layout uses a separate vertex array object which should improve
performance by reducing the CPU overhead while switching the vertex
layout. Since we need to use offsets into the vertex buffers at some
points this can not be done with the core functions since those do not
support specifying an offset when binding a vertex buffer.
GL_ARB_vertex_attrib_binding does support that and also features an
improved API for specifying the vertex layout. If that extension is not
available then the rendering engine will fall back to the current code.
In CPU intensive scenes I observed a frametime improvement of 1-2 ms.
Now that BMPMAN dynamically allocates the bm_bitmaps array, and deallocates it in bm_close(), which is explicitly called by gr_close(), FRED generates an exception on close because of trying to release bitmap handles after bm_bitmaps has been deallocated and set to null. This is because gr_close() is called by CFREDView::OnDestroy(), but the mission textures aren't fully paged out until CMainFrame::OnClose() (well, technically, CMainFrame::OnClose() calls CFrameWnd::OnClose(), which calls CWinApp::CloseAllDocuments(), which calls CDocManager::CloseAllDocuments(), which calls CDocTemplate::CloseAllDocuments(), which calls CDocument::OnCloseDocument(), which calls CFREDDoc::DeleteContents(), which calls CFREDDoc::editor_init_mission(), which calls reset_mission(), which calls clear_mission(), which calls model_free_all(), which calls model_instance_free_all(), which calls model_unload() for every model, which calls model_page_out_textures(), which *finally* calls the crashing bm_release()). This commit moves the gr_close() call to CMainFrame::OnClose(), *after* it calls CFrameWnd::OnClose(), which avoids the exception as bm_bitmaps is still intact long enough for those final textures to be freed from it.
FSO now allows the window title to be specified via game_settings.tbl, some never-used function arguments were pruned at the same time, and fred.rc now receives version information (for the About dialogue and the title bar) from a cmake-generated header, so the version numbers get filled in properly. Speaking of FRED's About dialogue, it now displays the copyright symbol properly.
In-mission events (SEXP chains that are used for directives and all mission logic) can sometimes call "training SEXPs", which depend on special variables set in the game_do_training_checks() function. However, this function was called near the end of game_frame(), well after mission_eval_goals() (which processes all mission events). This means that most training SEXPs wouldn't actually evaluate as true until the frame after whatever condition they were checking became fulfilled. This, combined with PR #1388 making the "targeted" SEXP actually use the appropriate variables (Players_target and Players_targeted_subsys), means that Diaspora's very first training mission's very first instruction (after launching from the launch tube, anyway) could not be completed, because the mission logic assumed that "key-pressed" and "targeted" would both return true on the same frame (which, after PR #1388, they did not).
This commit moves game_do_training_checks() to be called immediately before mission_eval_goals(), and therefore immediately after obj_move_all(), meaning Training_context_speed_set can become set the same frame the player's ship reaches the appropriate velocity and the relevant SEXPs can operate on the most up-to-date data available.
This will output the flags data in a better format than the current
binary format. For determining if the JSON output should be used this
uses an optional parameter for -get_flags. The command line parsing does
not cause an error if a parameter is specified for an option that does
not support them. This way, the launcher can just pass "json_v1" to the
option and an old build will just silently ignore it and use the binary
format.
For some reason, commit 8b43ed823c moved the consumption of the "#Soundtrack End" token out of parse_soundtrack(), when if a soundtrack needs to be skipped (e.g. because it's in a .tbm, flagged with +nocreate, and the original doesn't exist), it will skip straight past "#Soundtrack End" to reach the next "#Soundtrack Start". It also changed how music tables are parsed so that they'll skip any junk data that happens to be between sections, which is atypical of how tables are parsed. This commit changes both of these things: "Soundtrack End" is once again consumed near the end of parse_soundtrack(), and the while loop uses check_for_string() instead of skipping to the start of a section.
Even if bm_init() gets called more than once, for whatever reason. Unless bm_close() is called first, in which case it will re-allocate, potentially with a different MAX_BITMAPS (but it's okay, because there shouldn't be any active handles to worry about if bm_close() was called).
The texture array changes introduced the default material which is
similar to the passthrough shader but allows to use texture arrays. The
vertex shader is the same as for the passthrough shader so that shader
also supports clipping planes.
*Homing conditions are now consistant with in-frame checks
*Swarm missiles will now only change their homing pos during a change frame. This'll reduce their hit rate if SWARM_FRAME_STOP_SWARMING is too low, but will make their pathing more cinematic.
This adds support for specifying multiple sounds for a single game sound
entry. The engine then selects which sound will be played based on the
strategy provided by the game data. This required a few changes to some
of the game code since previously every game sound had exactly one sound
file attached to it. The most notable change is that it is no longer
possible to determine the exact duration a sound can have so instead the
new code computes the maximum duration a sound can have and uses that
where appropriate.
This also adds support for randomizing the pitch and volume of the sound
to provide a more varied experience even if only a single sound is used.
One possible issue that exists is that the "sequential" strategy only
works globally at the moment so if two sources use the same game sound
concurrently then the two sources will share the sequence of sounds
since there is no sound instance data at the moment. That can be added
in a future change but should not present a huge issue for most
use-cases.
Visual Studio on Appveyor somehow causes deprecation error on _our_
definition of vsprintf. I have no idea why these changes introduced this
warning but I won't debug Visual Studio compiler bugs that I can't
reproduce with my Visual Studio version so I just disabled those
warnings.
The code probably tried to check if the sound is available but since the
sounds vector is not long enough if the sound is not specified in the
table it would cause an out-of-bounds failure if the sound was missing
from the table. Furthermore, the current code would only have worked if
the sound was preloaded since the id is -1 until the sound is loaded for
the first time.
Previously, the source orientation was always aligned to the world so it
couldn't adapt to a weapon that changes direction. This fixes that by
introducing a "relative" mode for source orientations that is enabled by
default and disabled if the direction is set explicitly.
The particle sources of the beams were missing multiple properties
(direction and impact normals) and the generic shape effect didn't have
any way of controlling how long the source was active. This fixes that
by introducing an effect timing field similar to the single particle
effect.
Shield impact sounds now re-use the shield quadrant calculated by the collision code instead of naively recalculating based on global hitpos, allowing the hull impact sound to play if the shot pierces shields or was fired from within the shield mesh, and simplifying the relevant calculations in the process.
The function previously used glFramebufferTexture3D which caused issues
on the Mesa drivers and probably also with other drivers. This fixes
that by using glFramebufferTextureLayer which is the right function for
this use case.
This was previously not enforced and some code did not call this
function at the correct time which caused crashes since data was not
initialized correctly. This adds a check to ensure that the function was
called and fixes the code that uses the model_draw_list.
In previous versions of FSO the GPU data of a model was stored in
various different layouts depending on what data was required for
rendering that model. Since the transform batching code was added to the
model loading code this wasn't the case anymore since all data had to
use the same vertex stride even if the data wasn't used.
This made these changes possible where a standard C-struct is now used
for managing the layout of the data in GPU memory. This makes the code
easier to read and also easier to extend in the future since all layout
data is available in the struct.
This fixes a CTD when FRED is started since the graphics function
pointers are not valid at that point which causes a null pointer
dereference when starting FRED. This fixes that by checking if the
graphics system has been initialized before calling that function.
This fixes#1483.
I split this from #1331 to make reviewing these two changesets easier.
These changes convert all usages of const char* to SCP_string in the
static SEXP arrays so that the dynamic SEXP system can use SCP_strings
instead of having to allocate the strings and then somehow figure out
which strings must be freed at the end of the program.
This also converts the SEXP arrays to vectors so that new SEXP operators
can be added at runtime later.
This uses UBOs for building a buffer object of uniform data before
using that data to draw objects. This should reduce the CPU overhead by
reducing the amount of glUniform calls required for executing a single
draw call. This is especially useful if rendering is limited by the CPU
which should help performance for people with slower CPUs.
This fixes#910.
This restores the behavior from before the matrix system changes. The
observed behavior is more or less the desired behavior sinde setting the
2D projection matrix resets the model matrix stack but it happens to
work with the previous movie code since the 2D matrix is not set if no
perspective projection matrix was set before. This would need to be
fixed if the movie player should ever work within a mission but for now
this will fix the reported bug.
There is nothing specific to OpenGL in that code anymore since it's all
handled in the shaders at this point. This will make the lighting
information available in the normal graphics code which allows to use
those values when filling the uniform buffer for the model rendering.
This provides ~10% to 20% of an improvement if shadows are enabled. The
required features are not available in our OpenGL target version so I
added a fallback meachanism that will continue to use the standard
instancing method.
With an RX 480 and these changes I can play/watch the BP2 Icarus
cutscene at a consistent 60FPS which wasn't possible before.
This was requested by Axem for improving the usability of FSO
screenshots. This will remove the need to convert the TGA files to PNG
before uploading them to an online image hoster.
All transformations are now handled by shaders so there is nothing
special going on in the graphics API specific code anymore. Since model
uniform buffers require access to these matrices I moved the matrix
handling out of the graphics API code.
The PCX loader requires this or else the data isn't loaded correctly.
This matches what the code did before the texture array merge but it
only does it for PCX textures now since the other formats handle 32 and
24 bits per pixel correctly.
This fixes#1472.
If a 32-bit color shadow framebuffer is not supported this will first
try to fall back to 16-bit and if that still doesn't work it will
disable shadows completely. This should fix the rendering artifacts
reported on the forums here:
http://www.hard-light.net/forums/index.php?topic=93867.msg1854164#msg1854164
This adds empty lines to the beginning of the Lua source passed to the
interpreter so that the interpreter sees the lines in the source as they
appear in the table.
This might slow down parsing a bit since get_line_num is quite slow but
it should not be noticable in most instances since the script tables
tend to be quite short.
This fixes#1469.
Since the system already tracks if a buffer is still in use by the GPU
the buffer updates can assume that there will be no synchronization
issues if the buffer is mapped into memory.
This converts the deferred lighting shader to use uniform buffers for
the dynamic data sent to the GPU while rendering the lighting effects.
This doesn't affect performance but the deferred lighting code is a
nicely isolated piece of rendering code where I could test how the
rendering code could use the uniform buffers.
This is related to #910.
Back when I added the "same emp time for capships" flag in SVN r9540, I neglected to multiply the EMP time by 1000, as the EMP disruption time for fighters is specified in seconds but the time for capships is specified in milliseconds. So, using this flag would cause capships to suffer EMP disruption for almost no time at all.
This PR fixes that, and also extends the explosion-effect sexp to specify this parameter. And I also cleaned up the fireball section by calling eval_num(n) just once instead of several times.
Since 4500 strings are not enough for some mods there was a request for
removing that limit. I chose to use an unordered map for storing the
entries since the indices are not guaranteed to be sequential.
This fixes Mantis 3199.
When the OPF_NUMBER and OPF_POSITIVE behaviors were made more robust, it exposed a latent bug in the play-sound sexps. These had OPF_POSITIVE where they should have had OPF_NUMBER. With this fix, sounds can now play from all coordinates, positive or negative.
There is a bug where, when displaying an error message with a sexp node that contains a variable, the code will trigger an Assertion in the process of printing the error message. This is because it tries to transcode the sexp variable from name to index, when that has already been done further up the pipeline. This fixes that by adding a quick test to see if the expected variable name is an integer.
I changed those lines in another PR and forgot to revert these before I
submitted it. This will fix the OpenGL errors that appeared when shadows
were enabled.
Time-undocked will cause FSO to freeze unless you know what you're doing, so this PR fixes some gotcha areas. Inspired by The E's rant on Discord which, while not 100% correct, did indicate some areas for improvement.
1) Set the default "number of times docked" argument to 1 when the sexp is created in FRED, same as with the has-[un]docked-delay sexps
2) Catch any <= 0 counts when the sexp is called in FRED and set them to 1. (This was done for other sexps which used mission_log_get_time_indexed, but was not done for time-[un]docked for some reason.)
3) Add an assertion to mission_log_get_time_indexed as a last resort to guard against invalid counts.
This introduces a new function in the OpenGL state tracker which
combines setting the active texture unit and enabling a texture. The
reason this is a good idea is that this new function can filter out
unneeded calls to glActiveTexture if the texture is already enabled on
that specific unit. This happens very often when rendering several
submodels of a model which share their textures.
This is unlikely to yield significant performance improvements but
avoiding unneded OpenGL calls is always a good idea.
The code did not use the right method for calculating the required size
of the memory. This was never noticed before because the old OpenGL
texture loading code only used 16-bit textures for interface data but
the new code uses 32-bit textures which exhausted the available memory.
This was found and reported by @chief1983.
Since our target version is only OpenGL 3.2 all additional functionality
should only be used through their respective extensions to avoid
accidentially using a function not available in our minimum target
environment.
This converts all usages of bmpman textures to OpenGL texture arrays.
That means that all frames of an animation are stored in a single OpenGL
texture object and can be accessed at the same time in a single draw
call. This should significantly reduce the overhead of drawing lots of
particles since all particles of a single animation can be drawn with a
single draw call.
This fixes#1169.
Thanks to the new material system, it's now possible to easily make the
2D functions independent of the underlying graphics API which allows to
reduce the size of the gr_screen 2D API.
beam_pause_sounds() "pauses" looping beam sounds by setting their volume to 0; beam_unpause_sounds() "unpaused" by calling beam_recalc_sounds(), which only set the volume correctly when -no_3d_sound is set; 3D sound updates the sound's position without changing its volume. This PR just makes beam_unpause_sounds() perform the inverse operation of beam_pause_sounds() if 3D sounds are enabled.
Adds a new "+Pulse Interval:" countermeasure field that enables the new behavior; all countermeasures that don't have this field defined still use the old behavior of the global frame counter.
This changes countermeasure logic quite a bit, but I attempted to mitigate performance implications by re-using an existing traversal of the object list in order to build the list of active countermeasures each frame. If any countermeasures are actively pulsing in a frame, the object list is traversed again, looking for homing weapons. Each homing weapon then goes through the active countermeasure list and checks to see if it got decoyed. Most of this central logic is unchanged from the old behavior, although no longer separated into two functions, and it should be more efficient since it's using a prepared list of active countermeasures instead of traversing the object list looking for countermeasures for every homing missile (which are themselves found by traversing the object list).
It serves no purpose there since it's a message specifically designed to
be seen by modders and most times the stack trace doesn't even contain
useful information since there are no debug symbols present.
If the asteroid split rules were used and the asteroid speed happened to be 0 (for example if the field has an average speed of 0), the code would try to normalize a null vector. Now, a random vector is chosen in those cases.
Currently, the graphics code does some color remapping on 8
bit-per-pixel textures since those textures use special 4-bit pixel
values. These changes move that conversion out of the graphics code and
into the image loading/font bitmap creation code.
The reason this is needed is because this conversion breaks 8-bit
textures that try to use the full range of colors. I need to do exactly
that for moving the cutscene renderer to our generic rendering interface
which I can't do at the moment since the existing color conversion
corrupts the video data.
I have tested this with retail data and could not find any visual
changes after applying these changes.
SDL_HapticStopAll stops all effects, including the spring effect so the
joystick goes limp after one mission (joy_ff_stop_effects gets called at
the end of each mission).
This restarts the spring effect which should fix that issue.
This fixes#1417.
Any branch starting with "test/" will cause test builds to be compiled
and uploaded to fs2downloads. This will only work for the main
repository since the secure variables for the FTP credentials only work
for that repository.
This adds a small system for letting a mod specify which version of FSO
was designed for. That would allow us to introduce code which would
normally break backwards-compatibility by putting it in an if block
which checks if the mod supports the FSO version which ontroduced the
behavioral change.
There is currently no code which uses the new functions yet so I added a
few tests to verify that the options do what they are designed to do.
This fixes#1389.
In commit 735f5e199b randomtiger changed how anim_load() worked in seemingly-bizarre ways, for reasons unclear to me. In brief, a condition's logic was reversed, a three-value enum was created of which only one value was used, and as a result loose files passed to anim_load() (and only loose files) would be opened as "memory-mapped", one consequence of which is that they'd keep a cfile block open until the corresponding call to anim_free() (which means that, if a mission had enough different loose animations, the cfile block limit could be reached). Since files in packfiles behaved the same way they always had (namely, being loaded into memory and then closed, thereby not taking up a cfile block), apparently nobody noticed the difference, and this inconsistent code has stayed for the past 13-and-a-half years.
This commit changes the condition after the one changed in the older commit so that they both match, then changes the enum so that the seemingly-meaningless third value is removed, and the other two values are swapped (and the default value of the file_mapped parameter to anim_load() changed) so that the original Volition behavior is restored.
This also introduces the new generic dialog system which should allow
the mission code to open specific dialogs without depending on the
actual Qt implementation.
When streaming an ANI file, first anim_load() is called, then init_anim_instance(). The latter increments the animation's instance_count. If anim_free() is called on an animation that still has instances, it refuses to free the animation. generic_anim_unload() first called anim_free(), then free_anim_instance().
The fact that ANI files would ever unload at all seems to be because some code would unload twice. I can only assume that, combined with the fact that the bug only applies to ANI files, explains how this bug went undetected since November of 2009 (commit b43417882f seems to be when it was added, from a quick glance at git blame).
If we tell it to free up the animation, I think it should happen regardless of whether or not the HUD_TALKING_HEAD gauge is currently active or not. Also, unloading an animation shouldn't crash even if one wasn't loaded in the first place... and if it does, we should probably fix that instead of slapping a band-aid on the calling function.
The old code is not able to handle multi-threaded events so this change
simply filters out all the events that originated from another thread.
This fixes an Assertion caused by an invalid event.
This fixes weird misplaced special characters since the TTF strings
weren't rendered at the right position. This should fix that.
This fixes an issue reported on the forums by Novachen.
This could happen if the user enabled "Point to" and selected "Object"
without having an object selected. This can only happen when there is
only one object in the mission so it's only a minor bug but still
something worth fixing.
This was reported by @AxemP who wanted to have leading tabs in a text
line. However, split_str removed those characters by default since it
ignores leading whitespace. To fix that unexpected behavior of
gr.drawString I added a new paramter to split_str which disabled
whitespace removal and enabled that flag for the scripting function.
That should not be a problem for existing scripts since the expected
behavior would be that leading whitespace remains in place and since we
have not received any bug reports about missing white space I'm going to
assume that no one has used the function like this before removed those
characters by default since it ignores leading whitespace. To fix that
unexpected behavior of gr.drawString I added a new paramter to split_str
which disabled whitespace removal and enabled that flag for the
scripting function.
That should not be a problem for existing scripts since the expected
behavior would be that leading whitespace remains in place and since we
have not received any bug reports about missing white space I'm going to
assume that no one has used the function like this before.
At least on NVidia drivers, the medium-severity warning "Framebuffer unsupported. Framebuffer object Scene framebuffer is unsupported because the depth and stencil attachments are mismatched." would get repeatedly output to the debug log. @SamuelCho suggested this change, which gets rid of the warnings and doesn't appear to have introduced any graphical glitches.
Fixes#1382.
This assertion could apparently be hit if a ship was vanished (e.g. with ship-vanish) in the middle of talking. Rather than making the vanishing code aware of (and responsible for) Message_shipnum, it seemed simpler to just make hud_show_message_sender() clear the invalid shipnum itself.
The flagset changes probably broke this behavior by not respecting the "inconsistent" value set by the OnInit function when ships have inconsistent values for a specific flag. This should fix that and restore the 3.7.4 behavior.
Cutscene audio decoding was accidentally named "FFmpeg decode video", causing some minor problems in the profiling code (because the same name is used for actual video decoding, resulting in an assertion firing).
sexp_manipulate_colgroup() was using logical NOT when it should've been using bitwise NOT, meaning that removing any collision group would remove all collision groups.
This moves all the data related to the editor state that is not directly
connected to the renderer into its own class and file. This should
resemble the fredrenderer <-> fredview separation in the original FRED.
Also adds AVX2 autodetection so that AVX2-capable processors will generate AVX2 projects by default. To my surprise, there is actually a noticeable performance increase between AVX and AVX2 builds.
If framebuffer shockwaves were enabled and a 3D shockwave was created, FSO would use a hardcoded reference to the second slot of the Shockwave_info vector to generate the framebuffer shockwave for it. This only makes sense if and only if:
- the 3D shockwave command-line flag is also enabled
- the default 3D shockwave and default 2D shockwave are both present and loaded
- its the first mission of the session (because after that any shockwave not in the 0th index got unloaded)
I've changed the code so that which index the default 2D shockwave got loaded into gets tracked and used instead of a hardcoded index... and if both default shockwaves are loaded, the first two Shockwave_info indices are both kept between missions instead of just the first. This should allow framebuffer shockwaves to work with 3D shockwaves, regardless of whether or not it's the first mission of the session and whether or not a custom 2D shockwave was loaded (and happened to wind up at index 1). Slight downside in that missing the default 2D shockwave file, but having a custom 2D shockwave loaded, will now result in framebuffer shockwaves not being drawn at all, rather than using the custom 2D shockwave by accident; not sure that's really all that much of a problem, though.
Prior to APNG support, a regular non-animated PNG could be used as a still-frame command briefing animation. This started causing a crash when APNG support was added because any PNGs sent through generic_anim_stream() would get ga->type set to BM_TYPE_PNG, then sent through the APNG code... which would determine that they weren't APNGs, throw an ApngException, and generic_anim_stream() would return -1... except that BM_TYPE_PNG would still be set, so that when it later came time to render the still frame in generic_frame_render(), it would be sent through generic_anim_render_variable_frame_delay()... which expected a fully-formed APNG, tried to dereference ga->png.anim, and crashed.
This commit is a simple fix to reset ga->type to BM_TYPE_NONE if APNG processing fails, allowing the still-frame PNG to go through generic_anim_render_fixed_frame_delay(), the code path it used to take, and allowing it to display properly instead of crashing.
After someone tripped an assertion in the shockwave code which provided no details, I found some... questionable vector-related code. I changed all the code I could find that looped through the vector with iterator-based code, converted most Asserts into Assertions for more informative debugging, and added a couple Assertions to check previously-unchecked assumptions (which theoretically should never be tripped, but we'll see). A test build with the vector fixes resulted in the assertion no longer tripping so I'm fairly sure the improper erasure of the vector was causing problems (leftover data from a previous mission with a model number that no longer made sense because the model was unloaded).
The gun convergence code would detect if the target was within the minimum distance and move the predicted target point farther away if so, but wouldn't also alter the dist_to_aim variable to match; since predicted_target_pos is used by the autoaim code while dist_to_aim is what automatic convergence uses, this meant automatic convergence didn't respect the minimum distance at all.
Looks like this was broken in 7bb10d8408.
SND_MISSILE_START_LOAD and SND_BALLISTIC_START_LOAD (indices 33 and 200, respectively) could never actually play due to a logic error (they checked that a variable was true and the loop was on the last bank, when those conditions being met earlier in the function set that same variable to false). As far as I can tell, this broke back in 2006 with commit f300716e93.
This should make it possible to have both DLL version installed at the
same time without causing conflicts.
Combined with the new DLL, this will finally fix#974.
There's a bit of debug code that checks to make sure all ranks are in ascending point order; if this check fails, FSO calls Int3() instead of trying to describe the problem. I've changed it to a Warning that actually explains the problem, so the modder can fix it.
os_init_cmdline() contains the legacy-mode codepath in a conditional, but then doesn't put the non-legacy mode code in an else branch, resulting in cmdline_fso.cfg getting processed twice, leading to e.g. every mod getting loaded twice (which can cause all kinds of issues). This just wraps the non-legacy code in an else branch so that FSO running in legacy mode won't do both.
This renames the functions exposed by flagset so that it's clear that
64-bit values are returned. This also cleans up usages of wrong format
specified when that value is printed which caused some issues in the
past.
This should also fix#1336.
I encrypted those values using my user instead of our SirKnightly
account which meant that the values failed to decrypt. These new values
were encrypted using the SirKnightly user which should allow Appveyor to
upload the nightly builds to our FTP servers.
Since BinTray may be unreliable as our nightly host @chief1983 and I
decided that it would be best to return hosting to our dedeicated FTP
servers. These changes implement that together with a pending pull
request for the nightly script.
While searching for the cause of the rate-limiting of our BinTray
organization, I revoked the API key used by the CI servers in case the
key got compromised somehow. These are the updated keys which should
allow us to upload nightly builds again.
@chief1983 and I are working on a nightly solution which does not
require BinTray but until that works we need these updated keys.
fa60c666bc tried to fix an issue reported
by Coverity which was an intentional "issue". This restores the original
behavior which will cause a new coverity issue which can be ignored.
This fixes Mantis 3195.
The problem was caused by an oversight in 07107ce9b2 (namely, that changing some strings from being passed directly to string-formatting to being passed as arguments to a "%s" format-specifier meant that "%%" was no longer needed to get a plain "%" out the other side).
The iterator known as _L, besides having an absurdly poor name,
clashes with standard headers on OpenBSD -current at the time
of writing. This commit is the minimum needed to build on
OpenBSD with an updated C++ standard library.
This adds support for using clipping planes with the passthrough shader
by passing through the clip equation of the specified plane and then
using gl_ClipDistance for using the built-in clipping capabilities.
Invalid values previously corrupted the internal position counter which
caused crashes on some platforms because the position counter would
overflow in the next read operation. I added some assertions to track
the position counter corruption and it's probably a good idea to leave
them in to catch possible future errors early.
The actual fix was to just ensure that the seek position it always valid
for the file.
This fixes#1059.
This makes it easier to determine what takes the most time while loading
the mission (loading models) and how we could optimize that load time
(optimize model loading).
This is not a bug fix but it also shouldn't cause any regressions since
there are no actual code changes so this could be merged before the
release of 3.8.
The current shaders compute the clip values in the vertex shader and
then discard fragments if those values say that the fragment is clipped.
I don't know why this was done but, as far as I can tell, this behavior
can be fully replaced by using the built-in OpenGL clip-plane feature
which should also reduce the amount of fragment shader invocations. This
won't affect performance too much since we rarely use clip planes but it
seems like the correct thing to do.
This should make sure that the environment map is only redrawn if
necessary. In my case that should improve frame times by around 1ms for
the normal case when the environment map doesn't need to be redrawn.
The updated values for the distortion map were rendered too close to the
edge of the screen so they were clipped which meant that there was no
distortion data available. This fixes that by moving the rendered
primitives farther away from the edge. I'm not sure why this worked in
3.7.4, maybe the fixed function rendering used some slightly different
matrix.
I also don't know why this wouldn't work consistently across GPU vendors
but maybe the rasterization rules vary a bit across drivers.
This fixes#1307.
FotG needs a tint shader for a feature; basically toggle screen tinting
when a key is pressed as a visual indicator of which mode your ship it
in. Was previously done in a custom shader.
Immediately clearing the z-buffer is definitely not a good way of
saving it for later use. This fixes the lightshaft rendering (which was
broken by my fix in #1282) by removing the depth buffer clear from the
z-buffer restore function. The z-Buffer is cleared anyway before
rendering into it so it shouldn't make a difference.
I'm pretty sure that this is a bug since the documentation of
std::string::copy says that it doesn't append a 0 byte so our code would
need to do it manually. Instead, the code appended the 0 byte to the
input buffer which also conflicts with const-correctness (the function
was used on a lua-string buffer which should be const outside Lua).
Due to some initialization order issues the original header string
wasn't printed to the log anymore. This fixes that by initializing
outwnd_inited before doing the initial outwnd_print.
The briefing icon lables previously just wrote the label string to the
mission files without surrounding it with an XSTR which made is
impossible to translate them. I fixed that by using the right function
call when saving the value.
This fixes Mantis 3193.
Previously, the key text would use the localized key name which made it
hard for scripts to consistently handle key presses across different
languages. This changes that interface so that it always returns the
english name of the key.
As described in #1278, the current scripting system has issues with
handling non-trivial C++ types. Since fixing that deficiency is too much
work, especially since we are in a feature freeze, I decided to simply
enforce the usage of trivial types for scripting handles. Fortunately,
only two handles used non-trivial types so it was relatively easy to fix
those instances by dynamically allocating those and only storing the
pointers in the lua memory.
This fixes a bug in JAD-XA where the game would crash at the last boss.
Also, I noticed that the HudGauge handle used a copy of the hud gauge
rather than a pointer to the actual instance so I'm pretty sure that any
scripting changes to a custom HUD gauge simply didn't work before.
The DRADIS has two icon types, one where the color is scaled with the
IFF color and once which isn't. Due to a regression, both icons were
previously scaled with the IFF color which made the icons look bad. This
fixes that.
If the descripting of a weapon is too long it would currently cause a
very unhelpful assertion message. This fixes that by checking the length
of the lines when parsing the weapon description. I removed the
assertions since the string is just cut of if it is too long so that
fixes the actual assertion.
I also added two unit tests for making sure that too long descriptions
cause warnings.
I found this issue while debugging the JAD gauntlet where a script calls
getSignature() on an invalid object. However, object_h does not see the
object as invalid even though its signature is 0 which is defined to be
an invalid sigature. This should fix that by making sure that
object_h::isValid returns false if the saved signature is not valid.
I just encountered this assertion while debugging another issue. As far
as I can tell, this can happen if the ship dies the same frame that
change_ship_class is called. Since a negative hull_strength value is a
valid value this assert is invalid. The CLAMP should ensure that the
following code still behaves as expected.
The generated shields did not respect the display offset specified in
the table so they were drawn out of the clipping bounds of the gauge
which meant that they were not visible. This fixes that by respecting
the specified display offset when rendering the shield icons.
I added the "allow high DPI windows" SDL-flag while investigating #998
but since that flag isn't used on Windows we can safely remove it again
without causing issues.
Since the rendering code always accesses all four frames it must be
ensured that they are all present. Currently, there is a bmpman
assertion about an invalid handle if the animation does not have enough
frames. This fixes that by warning about that and then resetting the
bitmap handle to -1 so that the rendering code doesn't try to use the
handle.
This sets the dpiAware flag which should improve the compatibility with
High-DPI displays. It also sets a few values for specfying what Windows
versions we support and it also enabled the nicer dialog boxes which
makes the error and warning dialogs look a bit nicer.
One of the nightly builds failed to compile with an error saying that it
had run out of heap space. This adds the suggested flag which should
hopefully fix this issue.
The C++ standard allows to have no return in a function but in most
cases that is not the desired behavior. There are currently no instances
of this warning in our code but I encountered this error while
developing something else.
The flag was previously used to restrict searching of mission files to
the root directory of the mod. Since the SDL merge changed what the
default root directory is (now it's the mod folder in the user folder)
this broke the mission editor and it didn't show any missions anymore.
This fixes that by altering how Skip_packfile_search affects the file
search. Now that causes the search to skip files in VPs but it still
includes all other files that are present on the disk.
I also fixed some inconsistent behavior in the various file enumeration
functions since they weren't doing the same thing.
This changes the original behavior slightly since new files aren't found
in this search since the file list is only initialized when CFile is
started so if a new file is added after that, it is not reflected in the
mission list. Since that is pretty rare we can probably ignore that
here.
This fixes#1224.
Cotire (the CMake module we use for handling precompiled headers) can
auotmaically generate a prefix header by examining the includes of the
project. However, if a system include changes, the prefix header may
change as well which triggers a complete project rebuild. To avoid this
and to add the ability to customize the prefix header, I added a
manually maintaned header which will be used by all platforms and which
will only change if that file is manually changed.
A piece of debris spawned from a ship will say what class of ship it came from. If that ship has an alternate class name defined in FRED, that's used instead. If the ship class table entry specifies an "$Alt name:", however, that isn't used, which could potentially be confusing. This fixes that oversight.
This fixes a bug whereby creating a pilot in the barracks screen (not the initial pilot selection screen) would effectively clone the variable vector from whatever pilot was selected beforehand.
If FSO runs for a very long time (5 hours to be exact) then the SDL
performance counter reaches a value so hight that rescaling it to
microseconds causes an overflow which is bad.
This fixes that by implementing the rescaling by computing the factor in
the timer initialization code and then multiplying the SDL time with
that. This uses the same principle as the changes done by @TheMatthew in #1082.
According to the tests done by @chief1983, this fixes#1237.
Previously, the hud gauge was hidden if the player ship had taken no
damage. However, this made it impossible to see if subsystems have been
damaged.
These changes make sure that the subsystem values are shown even if the
hull integrity is at 100%. This is done by first collecting all the
necessary information about each line in the gauge and then, if that list
is non-empty, rendering it. This is necessary since the gauge code can't
decide if anything will be visible before looking at the entire
subsystem list.
There is a minor behavior change with how popups are handled.
Previously, the code would return if the HUD gauge was a popup and its
strength was at 100%. However, I think that this was dead code anyway
since that condition could never be true at that point because the code
would have returned earlier if there was no damage.
This fixes Mantis 3183.
In large mods this caused memory issues since we reached the 32-bit
memory limit when loading all models of a large mod (e.g. Blue Planet).
I fixed that by explicitly unloading the loaded model once the code is
done with it.
This fixes Mantis 3177.
This regression was introduced with the new model draw list which separates
collecting the drawing information and actually drawing the objects.
Previously, the scripting hook was always executed and the override
condition was used to determine if the normal rendering should happen.
Since 3.7.4, the scripting code is only executed if the condition was
overridden by Lua and if that override is active then the model isn't
rendered at all.
This executes the scripting hook in all cases and then checks if the
scripting system specified if rendering of that object should be
skipped. This introduces some slight changes in behavior since, when the
scripting hook is executed, the object isn't actually being rendered but
instead it's added to the draw list. IMO, that is not a major issue for
any existing application or else we would have heard about that until
now.
This fixes Mantis 3175.
The code wrongly used return instead of continue. This caused a second
sun to disappear if the bitmap of the first sun wasn't drawn.
This fixes Mantis 3188.
This happened in BtA where a script changed the font after rendering its
UI. Since the briefing code didn't account for that, the word wrapping
code used the wrong font for calculating how long a line would be which
made the display look wrong.
Fixes a subtle problem with vm_test_parallel() wherein a relative error
was accidentally converted into an absolute error.
Instead of comparing the result of the cross product to the zero vector,
the two calculated components of the cross product are compared against
each other. This permits vectors whose cross product is a large number
but whose cross product partials are within relative error of each other
to be treated as parallel.
For example, the following two vectors may now be considered as parallel
whereas before they were not:
v1 = (1000004.0, 1.0, 1.0)
v2 = (1000000.0, 1.0, 1.0)
The relative difference between them is sufficiently small according to
vm_vec_equal() for them to be considered equal, but their cross product
would have elements whose magnitudes would be near 4.0 which would
otherwise indicate that they are not parallel. By comparing the partials
instead, a higher degree of consistency is maintained.
Signed-off-by: Peter Mitsis <[email protected]>
This fixes#1051 by explicity telling SDL to create the window in the
display corner instead of centering the window. This has caused some
problems because the window borders aren't visible anymore in this case
which lead to some confusion.
PNGs can have 16 bits per channel but we always tell libpng to reduce
that to 8 bits per channel. However, we do not tell the caller of
png_read_header that this will happen so instead of 32-bits per pixel,
we tell bmpman that the image has 64 bits per pixel which causes some
issues.
The specific issue I fixed was the system map of BtA where the jump
nodes used a 16-bit PNG which broke the alpha blending of those bitmaps
since bmpan though that the image had no alpha channel.
Previously, if a mod used an upper case "Data" folder (which is the case
for the Diaspora development files) the file enumeration would fail on
case sensitive platforms (e.g. Linux) since FSO searched for a path with
a lower case "data". These changes make it so that FSO looks for all
instances of the path type name regeardless of case. Since the real path
was also needed elsewhere I added a new cf_file field which stores the
actual path which can then be used by fopen operations.
This fixes#1182.
If the object number is set for the render info the renderer uses the
instance information of that object to render the model. That is not
correct for the lab since the instance data is handled by the lab code
in that case.
This fixes#643.
If there was only one object and that got deleted the code that keeps
track of the highest object index would cause a negativ array index. I
added a check to make sure that the index was positive but that still
means that Highest_object_index will be negativ after that function
returns. I looked at the usages of the value and that value seems to be
fine with that code so I think this should be safe.
The HDR changes made the nebula bitmaps a lot less visible. This fixes
that by boosting the color of the bitmaps when they are rendered.
I choose 3 since that gives a similar look to 3.7.4 but that can be
further tweaked if desired.
I also added two debug scopes to help track down where that stuff was
actually rendered.
This fixes#712.
The code the test was testing isn't used by anyway so we don't loose
test coverage. I'm also quite certain that the failure is caused by some
sort of compiler bug or wrong standard library implementation.
THe flagset changes misplaced the post-parsing flag processing so that
it was only executed if a special flag was found. That was not the case
previously and this restores that behavior. I also simplified the code a
bit while I was at it.
This fixes#1191.
Since the cubmap loading code explicitly states that it doesn't support
resizing it's only logical to skip that if the bitmap that is currently
being loaded is a cube map.
This fixes#611.
Since Unix is case senssitive this should make sure that case errors are
cought early in mod development. This is an Error and not a Warning
since a mod with such a folder structure would never work under Unix and
as such it's justified to break mods that currently use this.
The root issue of #976 was that the code that reset the depth buffer of
the scene framebuffer was actually setting the depth buffer of the bloom
framebuffer since that didn't get reset properly. To fix this I
introduced a system in our GL_state which keeps track of a stack of
"bound" framebuffers which allows us to return to the previous
framebuffer with a simple function call.
I also added support for GL_KHR_debug since that help me while debugging
which texture was in use. In the future I'll probably extend that to
other areas of the OpenGL code as needed.
This fixes#976.
Fixes pointer access violation when docked ships warp out by moving dock_undock_all call to red_alert_delete.
It was previously thought that dock_undock_all() was supposed to be within ship_cleanup() and was safe to do so. Nope.
dock_evaluate_all_docked_objects makes the assumption that the dock_list is still valid, so if the function called by it happens to nuke the dock_list (like with ship_cleanup) then it'll work with invalid pointer values.
It was previously thought that dock_undock_all() was supposed to be within ship_cleanup() and was safe to do so. Nope.
dock_evaluate_all_docked_objects makes the assumption that the dock_list is still valid, so if the function called by it happens to nuke the dock_list (like with ship_cleanup) then it'll work with invalid pointer values.
This is a bit complicated to explain, so stick with me.
When transferring energy from shields to weapons (or vice versa), the values modified are the so-called "target deltas" rather than directly modifying the shield strength or weapon energy values. The ship_chase_shield_energy_targets() function carries out actually meeting these targets without exceeding a change of ETS_RECHARGE_RATE percent per second. At least, that's what it's supposed to do, and obviously works that way when the target delta is positive.
When the target delta is negative, however, a logic error with the conditional meant to limit the rate of change instead functions backwards; if the amount of desired change exceeds the per-frame limit, the amount of change is set to the total desired change, and if the amount of desired change is smaller than the per-frame limit, than the amount of change is the per-frame limit (even though that's more than the amount that's supposed to be drained).
Since the target delta is modified by the amount by which the value changed, this leads to an interesting consequence whereby the "extra" amount taken away is added back in the next frame... which has another interesting side-effect if the "extra" drain tried to reduce shields below 0. Namely, the shield code doesn't let it, while ship_chase_shield_energy_targets() remains blissfully unaware that the actual change was smaller than requested. So on the next frame, you spontaneously get some fraction of a percent of your shields back. Which, naturally, you can then transfer energy from to your weapons ad infinitum; the amount is small, but you can continually transfer it, so you're getting weapon energy out of nowhere.
Now, straight-up fixing the logic error would be a major retail balance change; if transferring energy from your shields to your weapons only gradually reduced your shields, instead of taking a huge chunk at the start, it would be a much safer option. Therefore, the only non-balance-changing fix is to just remove the broken conditional entirely (so that it always drains the full amount instantaneously, regardless of how big or small it is).
I've left the fixed conditional commented out so that somebody, when we're not in a feature freeze, can add an AI profile or mod table flag to restore the check, allowing for slow energy transfers.
A conditional originally added to shield_add_strength() to make shields not recharge beyond the recharge limit forgot to check that the amount shields are changing by was positive (unlike a couple other conditionals added/modified around the same time), so a call to shield_add_strength() with a negative delta (e.g. when transferring energy from shields to weapons) when the current shield strength is at or above the recharge limit (i.e. full strength when a recharge limit isn't specified) would immediately return without doing anything. This would, of course, result in no change to shield strength... so if you had full shields and had drained your weapon batteries dry, you could get free energy by hitting the button to transfer energy from your shields.
Same as the GLSL version checks, these conditions were always true since
we only support OpenGL 3.2 now.
There was also an assertion condition that didn't make sense so I fixed
that.
These checks were from a time when we supported lower OpenGL version
than 3.2. Since we don't do that anymore and show an error if the
drivers don't support that, these conditions always evaluated to true
and could be removed.
secondary_animation_position wasn't being set by the ship_weapon constructor, which could cause potential issues with whatever uninitialized data it wound up being set to (like, say, being unable to fire any weapons in the second secondary bank until you've cycled through it once). Since it depended on uninitialized data, the behavior could even change between 32-bit and 64-bit builds (and Release/Debug, of course).
While I was at it, I also noticed some variables were getting set twice; in one instance (primary_animation_done_time), it was even being set to the wrong value the second time (according to the pre-flagset code that used memset() on it and then overrode some values that shouldn't have been zero). Not sure what problems that could've caused; possibly some issues with animations and primary weapons, I guess, if the "done" timestamp was invalid when it shouldn't have been.
* Adds a warning for debug users when an unknown ship_state is passed to red_alert_delete.
* Removes commented-out code
* Doxy's ship_cleanup()
*Conform to each file's style.
*Extend ship_cleanup to better handle red-alert deletion.
*Also treat cleanup_mode as a flagset, instead of an enum as it was previously.
*Use existing methods to determine dock status and find the head of the dock list.
*Fixes a derp with dock_dead_undock_all()
*Doccument some docking methods in object.h
*Address requested changes.
* Looks like a shallow copy wasn't enough, so this fix creates ship_weapons::clear() which is called by ship_weapons's constructor and by ship::clear().
In ship::clear(), The E removed
memset(&weapons, 0, sizeof(ship_weapon));
but did not add a corresponding
weapons = ship_weapon();
This fixes that. Additionally, this PR removes one of the two uses of ship::clear() by tweaking hud_observer_init. Originally, the code used memcpy, but if the assignment operator works for ai_info, it should be suitable for ship too.
vm_vector_2_matrix was improperly guarded against bad parameters. In the
case I encountered the uvec was the negative of fvec which produced a
null vector when the cross product of the two vector was constructed.
These changes should fix that bug by ignoring the uvec parameter. Since
vm_vector_2_matrix and vm_vector_2_matrix_norm are basically the same, I
converted the former into an alias of the latter and only fixed that
code.
Changes a few windows (tech room, campaign room, medal case, and HUD config menu) to issue Warnings instead of Errors if certain pieces of interface art are missing. If their mask bitmap is missing, they automatically close themselves and display the old "Sorry, this feature is available only in the retail version" popup from the demo, allowing FSO to run the demo data without crashing when you click on the wrong button.
It also restores the special demo popup for the campaign room, which allows you to at least restart the demo campaign without deleting and recreating your pilot.
Initialization of the medal window locks the mask twice (once directly and once indirectly, through set_mask_bmap()), then closing the medal window tries to release it after only unlocking it once. bm_release() will refuse to do anything if the BMPMAN entry is still locked, though, so the first release therefore does nothing, and since it will then only be released once (indirectly, by Medals_window.destroy()) after being loaded twice, the mask stays loaded in memory until FSO exits. By moving the release until after Medals_window is destroyed, the mask should be successfully released when the medals window closes.
The demo doesn't include techroom art because the demo doesn't have a techroom (or a campaign room, or a HUD config menu), but it still otherwise works with the higher-resolution interface.
If an event with a directive contains both an is-destroyed/is-destroyed-delay for a wing with multiple waves AND the event's Sexp_useful_number is 0 (either the event contains an "is-event-*" SEXP (or one of the "-delay" ones with the optional third argument not set), and that SEXP didn't return true, or some part of the event evaluated to SEXP_CANT_EVAL) AND the wing currently has 0 ships in the mission (so Directive_count gets set to DIRECTIVE_WING_ZERO to mark the directive as being "temporarily" true, until the next wave arrives), then the directive winds up in the list of displayed directives without actually having a born_on_date set, so it fails this assertion. Since this is caused by the data supplied (in the mission) rather than a coding mistake, and since this assertion doesn't actually seem to be guarding against anything (because nothing bad happens if the comparison happens anyway, just with a born_on_date of 0), and it behaves just fine in Release builds where the assertion isn't checked, the simplest solution would seem to be to just remove the assertions altogether.
Found this issue while testing with demo data, so blame whatever Canadian wrote the first demo mission to make the "Destroy Libra" event check for either Libra being destroyed OR an event (that can't ever become true until after at least one wave of Libra gets destroyed) becoming true.
Somewhat related to the previous commit: if, in the future, we have another instance of trying to unload a nonexistent graphic, it would make much more sense if BMPMAN returned -1 (like it already does for other failure conditions, like trying to unload an unused slot) rather than tripping the "n >= 0" assertion down below (calling with -2 or other negative values that can still trip that assertion unaccounted for, because those would definitely be mistakes in the code).
If Fade_anim.first_frame was -1 (like, for instance, if the animation did not exist, which it doesn't in the demo data), the briefing code would still try to do stuff with it, and then unload it when it closed. This seems like a bad idea in general.
It defaults to an empty string (resulting in no music) anyway, so there's no harm in it being missing, and the demo's mainhall.tbl doesn't contain these lines, so this change makes it possible to reach the mainhall with demo data.
This makes the debug window resizable and also reduces the default size
to ~80% of the used display. This also makes sure that the main window
has input focus after the debug window was created.
Currently there are multiple locations in the code where the version is
constructed by printing the individual numbers together. This is mostly
sufficient but it hides information such as the commit hash or the build
name (e.g. RC1). These changes unify that behavior by always using the
version string generated by CMake.
This allows to show the debug output in a second window in real time.
This system could be expanded further to allow more interactivity but
the current status is good enough.
When the function was rewritten as part of the TrueType PR, its logic was also unintentionally changed so that it expected timestamps in milliseconds when everything calling it provides "fix"es, which represent 65536ths of a second.
This changes some functionality but it shouldn't cause too many issues
since the previous functionality was kind of a hack anyway.
This also adds a simulation conditional hook that has only been
available through global hooks before.
This adds a utility library for handling all the nasty lua referencing
stuff. It also provides functions for convienent usage of lua objects
such as tables and functions which allows to use them directly from C++
code without using the ugly Lua C-API.
Not resizing the Messages vector here was leading to a debug error about an out-of-range vector subscript, and who knows what other problems were being caused by overwriting whatever memory was after the Messages vector. There's no equivalent problem when parsing, because as each message is parsed, it gets pushed onto the back of the vector instead of assigned directly to an index.
Makes beams inherit their firing ship's collision group if "$Weapons inherit parent collision group:" is enabled, and adds a collision group check to beam/ship collisions (and only beam/ship collisions, since collision groups are only currently checked for ship/ship and ship/weapon collisions).
This shouldn't break any existing mods, since usage of collision groups is surprisingly rare, and so is usage of weapons inheriting their parent's collision groups, and this change should only affect mods that do both at the same time; from a (very quick, non-representative) survey of modders, it's entirely possible that the mod requesting this change is the only one that does so (theoretically, there could be a mod out there that uses scripting to explicitly set the collision group of a beam object, but if they did so and then relied on it not actually doing anything, that's incredibly silly of them).
The timers on Windows apparently have a lower resolution than Linux
which causes issues with overlapping events. These changes apply an
offset to all timestamps if the same timestamp is detected while
processing the buffered events.
This is basically the old code but it has been ported to the new tracing
system.
There is still some weirdness with the percentages but I have no idea
where that comes from since I don't know the code.
This is a feature for developers that is not needed in FastDebug builds.
This should speed up these builds a bit since iterator debugging causes
quite a performance penalty.
Swaps the order of the scripting call block and the cycle-to-next-bank-if-out-of-ammo block so that e.g. "$On Weapon Fired:" scripts for a specific weapon type (which checks the currently-selected bank) will work properly when firing the last missile in the bank. Fixes issue #1091.
Since there are so many member I decided it would be better to use the
new member assignment syntax since that automatically guarantees the
right initialization order.
Before, they were assuming any joystick had at least 1 hat; this way, they now treat it similarly to buttons. If requesting the status of a button the joystick doesn't have, they return 0. If the joystick doesn't have a hat, querying a hat position will likewise now also return 0. This code will obviously need changed when we get around to proper (e.g. multiple) hat support.
When this line was converted by the bitset flags PR, it was accidentally changed from setting the flag to reading the flag, making it a do-nothing line and causing the flag to be cleared on mission load.
Before, if any parsing call failed it would throw an exception which
would have been propagated to the exception handler in main() which
terminates the program. This should fix that.
Upgrades and deprecates the original jettison-cargo-delay sexp by removing the unused delay parameter and adding a new parameter to control the speed of jettisoning. It further fixes the physics calculations by using the dockpoint normal instead of the vector between the center of the host ship to the center of the cargo.
See also the thread on HLP: http://www.hard-light.net/forums/index.php?topic=92844.0
This creates a factor that is used to multiply the timestamp. It will
overflow less, (once every 300 years or so) and not lose as much precision
as the previous implementation.
The performance is slightly improved, there are no more branches and one
floating point multiply.
Note: this relies on long double having a 64 bit mantissa. This is the
case on x86 Windows, Linux, and Mac OS. However, it is unconfirmed to
work on other architechtures.
Signed-off-by: Matthew Khouzam <[email protected]>
GL_EXT_gpu_shader4 is part of the GLSL 1.50 language standard so the
FXAA shader doesn't need to check against that. I also added a
conditional define for FXAA_GATHER4_ALPHA if the GLSL version supports
it which is the case when it's >= 4.00.
The other issue was a minor change from inout to out where Mesa
complained that the target variable might not have been initialized.
The new design is centered around the Event Trace JSON format but it
should still be possible to adapt it for other profiling tools. The old
profiling system has been removed.
Previous fixed used a logical NOT (!) instead of a bitwise NOT (~), derp!
In addition, the LE_VM_INTERNAL state now ignores VM_CENTERING, so it won't go false if the camera is returning to center.
primative_batch_buffer:desired_buffer_size was not properly initialized in vc120 compilers during debugging. Default constructors proved insufficient, and std:map::operator[] seems to ignore them anyway. This fix gets around that by explicitly clearing desired_buffer)size from within batching_init_buffer()
When this functionality was added in commit 0662cb6959 it made an explicit check to see if the node was -1, and if so (meaning the node is not present), defaulted the value to true; a month later commit 57c4855e25 "simplified" this to a single is_sexp_true() call, which returns false if the node isn't present... but the documentation still claimed that the default value was true.
Ten years later, and Axem wanted to know why his submodel wasn't being fixed by the repair-subsystem SEXP. I don't know if this is the first time in ten years anybody's wanted to use repair-subsystem on a destroyable submodel, or if everyone was just assuming it worked as intended and never noticing it didn't; regardless, while the "simple" solution would seem to be to fix the documentation (since the current behavior has been the actual behavior for almost as long as the feature has existed), it seems unlikely that there would be many unintended consequences of just fixing submodels by default, and if anyone has used these SEXPs in the intervening ten years, it was probably under the assumption that they worked as the documentation claimed.
Since Windows line endings include this character it needs to be ignored
since the text rendering would display it as an unknown character
otherwise.
This was reported by @AxemP.
Fix unlimited transfer of energy to shields (energy lost)
Fix thresholds in ai balance shields, rearm timer & call4help
Fix scaling in shield pain flash
Fix variable number of shield segments in shield pain flash
Lastly includes formatting tidy-up in shield pain flash
Make sure we've got initialized values in the secondary pattern indexes
for a ship_weapon and also allow linked/dual fire to be in sequence
instead of swapping in the base weapon at the beginning of each pattern
loop.
This fixes an issue where the event music cuts off after ~ 3 seconds
because the fields tracking how much data has been read so far were not
reset. I also fixed the calculation of how much data may be read since
that was slightly broken by the new audio stream reading code.
I'm not entirely sure if this is the correct way to do the computation
but I see no other way of fixing it but since the zero vector is a valid
value for the relative velocity this seems to be the most sensible
solution.
Also, related to this I found out that FSO causes a lot of NaN errors at
runtime which may need to be investigated at some point to make sure
they don't cause issues like this bug.
Reasons being; it's incompatible with FXAA, it's slow, and it's causing
OGL init to fail on certain systems. Oh, and it probably doesn't work
anyway :)
This will make sure that an exception doesn't just silently crash the
game (if the dialog can be shown at that point). This caused some issues
in the past so I thought it would be a good idea. I also added a check
for a preprocessor define to disable exception catching completely which
should make it possible to use a debugger to debug uncaught exceptions.
The routine vm_vec_normalize_quick_mag() did not normalize a vector.
Instead of dividing the vector by the 'quick magnitude', it multiplied
it. This routine was only called by one other routine (which was
fortunately unused)--vm_vec_normalized_dir_quick_mag().
Given both the incorrect behavior as well as their lack of use, those
routines have been removed.
Signed-off-by: Peter Mitsis <[email protected]>
Uses fl_abs() (which evaluates to fabsf()) instead of an if-else
statement to get the absolute value of a float. A compiler for the
x86 platform is able use SSE instructions to optimize calls to fabsf().
Signed-off-by: Peter Mitsis <[email protected]>
@niffiwan discovered that some retail sounds trigger the newly
introduced so the warning needs to be suppressed for those few files.
See #1005 for the full discussion.
Designed to work around issues with gunpoints on animated subsystems,
and those gunpoints being in the "triggered" position, and thus there's
lines pointing to empty space in the weapon loadout screen.
Use this to specify an alternate model that has the gunpoints in the
"correct" position.
ADPCM playback was broken by #991 when an older FFmpeg version (< 3.1)
was used. The newer version has a better API for handling decoder that
return multiple frames of data per packet which I already used. However,
I didn't bother implementing that for the older API since I haven't seen
a decoder that actually returned multiple frames per packet but ADPCM is
such a decoder. This fixes that by implementing the correct behavior
with the old API.
1) I accidentally used subshells for matching the tag patterns which
broke the regex match.
2) The destination directory for the library files wasn't created by
default so it broke the build.
- Add libs prebuilt with mxe
- Update cmake scripts to use them
- Make MINGW builds use the generic def_files inclusion method
- Some minor fixes to compilation
previous_primary_bank was only getting set if the ship had a ballistic weapon or if secondary banks were changed, so previous_secondary_bank wasn't getting set at all. I fixed the second problem my simply using the correct variables, and the first problem by consolidating the ballistic and non-ballistic code so that there was less code redundancy (without that redundancy, it's unlikely the mistake would've been made in the first place); I figured this was a better solution than just copying the code to set previous_primary_bank into the non-ballistic codepath.
Also simplified the code for setting the previous weapon bank according to asarium's suggestion.
This is the first step towards moving all audio decoding to FFmpeg which
will reduce the amount of external code we will need to include. This
only replaces the AudioStream code with an FFmpeg based solution which
should make the code easier to review.
It turns out that FFmpeg is actually able to decode the Interplay MVE
movies so we can drop the old MVE code and just use FFMpeg and the new
video player interface for that.
This was requested by @AxemP.
The implementation is a bit more complicated than simply retrieving the
value since that is only updated when the weapon is fired. Instead, the
function calculates what the current value should be based on the code
from the function that updates the value when the weapon is fired.
Setting the value is disabled since the extra processing code could
alter the calculation a script does so that after setting the value,
reading it again would return a different value.
The ogg/vorbis DLLs were linked with a dynamic runtime which caused the
error that was reported in the nightly thread. These new DLLs statically
link the runtime which should eliminate the dependency on the runtime
DLL.
Apaprently the alpha blend behavior has been broken for a long time and
alpha blending was always enabled. I changed the default lua opacity
type to match this behavior so that older scripts don't get broken by
this.
Also added the "Center Text On Gauge X-Position:" option for the Fixed Messages gauge, which by default is enabled only if the gauge's position is not overridden.
cmission.main_hall defaults to an empty string, so calling main_hall_init() with an empty string is neither unsurprising nor uncommon. Since it's not actually caused by bad data, the warning can be considered actively harmful by training users that sometimes FSO just gives you a pointless warning.
The codebase had quite a few instances of .size() being called and then checked to see if it was 0 or not (or less than 1, or greater-than-or-equal-to 1, which are basically equivalent), when .empty() could be called instead (negated or not, depending on what the original condition was).
Changes "A-Objects" to "OBJ_INDEX(A)" (not sure why that one didn't generate warnings, but whatever), removes a redundant should_be_ignored() call (it will have already been called for that ship for the code to be in that block in the first place), and adds an assertion to make sure that the jnp iterator is valid before trying to dereference it.
Most AI profile-related five-value lists are related to the number of difficulty levels. "$Detail Distance Multiplier:", however, is related to the number of detail levels (MAX_DETAIL_LEVEL + 1, because detail levels go from 0-MAX_DETAIL_LEVEL; MAX_DETAIL_LEVEL + 1 is also the size the detail_distance_mult array is defined with). Those two numbers happen to be the same (5); however, this may not always be the case in the future, and this way it's explicit that this field isn't related to difficulty at all.
Ignore_List (the list of flags used to determine if a ship is an invalid target) was originally a statically-initialized bitfield stored in an int; the new bitset flags code added a set_default_ignore_list() function to provide the default values, but then forgot to call it anywhere. As a result, "hidden-from-sensors" (and the other, less-likely-to-be-noticed flags) was having no effect on the player's ability to target anything. This adds a call to set_default_ignore_list() to ship_init() so that the original functionality is restored.
This uses the program binary support included in OpenGL 4.1 to build a
cache of compiled shaders. It does this by computing the MD5 of the
source code of the shaders and using that hash to save the files. That
should make sure that a change to a shader is automatically reflected in
the shader cache.
As far as I can tell this issue has been present for a very long time,
maybe even since retail. It was only uncovered since the recent changes
initialized the mission text by default which corrupted the table text
that was currently being parsed.
This also adds a unit test that validated that pausing works correctly.
A few things I noticed while working on ai-chase-ship-class, split out into a separate PR. Some code is reordered, some is cleaned up; nothing too extensive. The most notable changes are a) the modification of the Ai_goal_text function to work on the AI_GOAL_X #define directly rather than unnecessarily calculate the bit; b) changing the HUD text of "fly to ship" to "rendezvous with" plus the ship name; c) adding a Warning in ai_update_goal_references; and d) changing ship_name to target_name in ship_return_orders for clarity
texture2D has been deprecated for some time and Mac also doesn't support
it anymore. The 1.50 GLSL specification says that texture is the correct
function for texel lookup so I used that.
This adds unit tests (or maybe these count more as functional tests) for
parsing the intelligence data displayed in the tech room. It is parsed
from species.tbl by code/menuui/techroom.cpp and stored in the global
array Intel_info. The number of entries is saved in the global int
Integer_info_size.
Every test has its own mod dir with a species.tbl that it parses by
calling techroom_intel_init(). The test fixture resets the intel state
with techroom_intel_reset() between tests.
These tests assume that the file is preprocessed correctly, so it does
not try to test if e.g. comments are removed correctly, ... Only the
parsing that is unique to species.tbl is tested.
While it isn't strictly necessary since the Windows drivers typically
support the features we need it's still the better solution.
It also allows WINE to run FRED2 on Linux since there the code profile
is actually needed.
This is not technically correct since the FRED code is not able to
create an OpenGL Core context but since FRED is Windows only it's not a
problem because those drivers usually support the Core profile features
in the Compatibility profile.
tech_render_anim did not check whether there were any intel/weapon
entries before trying to read from Current_list, which means that it
read at Current_list[-1], which is a Bad Thing (TM).
Do not try to render an anim if there is no entry.
Add missing new line to BSP Parse timing and make it nprintf("Model").
Log value of HUD_config.rp_dist when it is not valid.
Fail reading a .plr file if it has a zero-length section.
startSectionWrite would push unnamed sections on _sectionOffsets, but
endSectionWrite was not removing them, leading to _sectionOffsets
containing tens of unnamed sections when parsing the HUD config.
Pop the unnamed sections in endSectionWrite.
Opening the log file failed when the data path did not exists, e.g.
during the user's first run. Create it before trying to open the log
file.
Also, include <direct.h> in windows_stubs/config.h since the equivalent
stubs for Unix are also declared there.
This fixes a few of the bad design descisions of previous shader
iterations. This uses a dedicated class for managing the resources and
uniform locations of a shader program.
Uniforms are also stored in this object which makes a lot more sense
than storing them in the OpenGL state where they had to be reset every
time a new shader was used.
There are still a lot of possible enhancments to make, e.g. by using
uniform blocks and buffers instead of standard uniforms which would make
uniform location handling easier.
Another optimization that I will investigate is reducing the amount or
different compiled shaders by turning some of the current compile-time
defines into bool uniforms.
This uses GL_KHR_debug for exposing debug group information. This is
very useful for tools like apitrace where it's used for assiciating
OpenGL commands with a specific application function.
The groups are created using a utility macro which is removed in release
builds so it should have no impact on the release performance.
The previous code generated a lot of OpenGL function calls because every
star was rendered using a separate NanoVG frame. This fixes that by
using the path renderer directly which removes most of the
inefficiencies.
This is related to #898.
The code was using the 32-bit types while being compiled under 64-bit
because a header was missing. I fixed this issue by using fixed width
integer types.
It was setting the Pierce_shields flag based on whether or not the Beam flag was set, rather than based on whether or not the beam flag was explicitly provided; as such, a TBM entry for a non-piercing beam that contained a "$Flags:" entry but didn't re-set "no pierce shields" could spontaneously regain its piercing status (explicitly setting "beam" again will re-add piercing, but this should match previous behavior).
This fixes an Int3 in the ai code where it couldn't find a ship that was
destroyed before a mission. This was found through a mission bug in
FreeSpace Blue "Slaying Ravana" where the "Somtus" is marked as
destroyed before mission but then the AI is given orders which target
that ship.
Also adds code for detecting if the FreeTrack client is actually
reporting valid values. I only tested it with FaceTrackNoIR so it may
not work for other head trackers.
For some reason, FRED has some code that checks a checksum and if it
doesn't match it exits after a certain time with an obscure error
message. It doesn't affect us since the checksum is always right but it
was probably some kind of DRM at some point.
Avoid potential uint overflow if joystick returns a range greater than
the maximum expected range. I guess this could also be fixed by
limiting raw to rng-1 (?)
* Moves a camera lock statement into do_view_chase() to coincide with do_view_slew()'s style;
* Resets camera angles when transitioning into chase and external views from target padlock view;
See also my comments on #762. The flag is almost entirely redundant, so this PR removes it in all instances where it's used in the ballistic primaries code. There are one or two places where removing it was not a no-op, so I adjusted the rest of the code accordingly (most notably in the parsing validation when it checks that primary weapon cargo has been assigned). I also added a few divide-by-zero checks and slightly tweaked the support ship rearm code. The use of the SIF_BALLISTIC_PRIMARIES flag in the ingame_join code was replaced with a dummy value to avoid bumping the multiplayer packet version number.
This disables all mouse grabbing which is useful for debugging when SDL gets interrupted without giving up
control of the mouse. That usually leads to problems since you can't
interact with the debugger window anymore.
_mkdir was horribly broken. It was creating all directories in the given
path but failed to create the actually wanted last portion.
On Windows, _mkdir only creates the last portion.
Fix this by simply calling mkdir, which does the Right Thing (TM).
This is a new implementation of the JSON dumping which was already
proposed in #22 but this version tries to allow implementing both
reading and writing JSON files without having to change the existing
code too much. This is done by using an abstract class to hide the
differences between writing the JSON and binary files.
This is currently only capable of writing the files but not reading them
so if the option is enabled all changes to the pilot file are lost. I
will implement reading after this PR has been merged since I would like
to reduce the amount of changes that need to be reviewed.
Starting with git 127976c (#851), FSO fails to start, displaying an
error. This is my attempt to fix it. FSO starts, but I do not know how
to check that the flags are parsed correctly.
* Adds VM_CENTERING to replace view_centering
* view_modify() now takes care of centering the view
* Reorganized view-related controls and logic to be cleaner
If "value" is empty, then attempting to access "value[value.length() - 1]" is equivalent to trying to access "value[-1]", which is an out-of-bounds access (causing debug builds to complain and undefined behavior).
When PR #831 got rid of a warning in sexp_event_delay_status(), it did so by getting rid of the 64-bit temporary variable (in order to get rid of a warning in the non-use_msecs branch). However, that 64-bit variable was protecting against overflow when using numbers of milliseconds >= 65535, which are used by e.g. the Icarus cutscene mission from Blue Planet, leading to interesting (but wrong) behavior.
This restores usage of the uint64_t temporary variable by reverting that specific change, but then avoids the warning by moving that temporary variable to be inside the use_msecs branch; I get no warnings when compiling this version of sexp.cpp, and Icarus works again.
The new joystick API (commit f91c681ee1) didn't include calls to joy_ff_init() and joy_ff_shutdown(), disabling haptic support. Simply restoring these calls was enough to make it work on my system again.
If CurrentJoystickGUID was present but set to an empty string, the new code was comparing all joystick GUIDs against the empty string, and therefore concluding that no joystick was currently selected. This just treats an empty string as though CurrentJoystickGUID weren't set at all, allowing the index-based CurrentJoystick to take over.
While working on #824, I found out that cleaning up that particular piece of code would not be doable cleanly without a refactor of the multi_sexp infrastructure. This is that refactor; it encapsulates the code of multi_sexp inside a class, an instance of which is then used to manage all the network stuff that sexps need to do.
Kobrar reported that joystick events were not properly assigned to the
right Joystick instances because the GUIDs of the joysticks was the same
(that's another problem since the code assumes that they actually are
Globally Unique like the name says).
The fix was to simply use the instance ID for checking if two sticks are
the same which seems to work more reliably.
* There's now registers for both 4 position and 8 position hats for both timestamps and downcounts
* There's conversion code to allow an 8-position hat to act like a 4-position hat, which is needed by the FSO codebase which only uses 4-pos hats
* There's also conversion code to allow a 4-pos hat to act like an 8-position hat to some degree.
Target priorities could previous only select based on very few flags, for the simple reason that very few were defined in the ai_tgt_*_flags[] arrays. This simply adds additional flags (even some that seem a little silly; I can't actually think of a reason to especially target "objects that are being rendered", but hey, maybe somebody will find a use for it in the future).
This introduces a new mechanism for handling bit flags. Instead of using an int (or two, or three) to write bits into, this uses the std::bitset in a wrapper class that accepts an enum class as input. This means that certain classes of errors we've had a few of in the engine, where a coder used the wrong set of flags or checked them against the wrong variable (SF_STEALTH vs SIF_STEALTH, for example) can now be detected at a compiler level rather than not at all.
getHatPosition() returns a value from the HatPosition enum, so the conversion to a 0-based index is incorrect (and causes the hat switch to basically not work with continuous controls).
When the hat switch code was fixed to restrict joysticks to 32 buttons again, it forgot to invalidate buttons between numButtons() and 32. This could lead to some assertions being failed when the joystick got asked for the status of a nonexistent button.
* Fix (undocumented) issue with hat presses not registering.
* Use array instead of a vector for _hat::DownCount
* No, no die-nam-ick numbor of boot-ons to-day. Und no, ve only haff vone hat. Sad Heavy is Sad.
* Fixes an out-of-bounds error caused by incorrect indexing in Joystick::handleHatEvent.
Also fixes a bug where the hatGetDownTime would return a nonzero value if the hat was active but in a different position than the input parameter.
If the -noninteractive command line option is set then dialogs won't be
shown and the default action is taken. This should be useful for
the standalone server.
Apparently MSVC 2013 allocates memory when locking a mutex which calls
our allocation hook when the tries to call our memory tracking function
which leads to a deadlock. Since there is no way of providing a memory
allocation function for std::mutex the best solution is to simply
disable the lock_guard for everything before MSVC 2015. That will
probably corrupt the memory tracking values at some point but it's
better than not being able to run FSO at all.
Coverity defects 1320483, 1320484, 1320485, and 1320486 noted that several values were being set and then immediately overwritten before they could do anything. These appear to be related to behavior that Volition disabled before release that would allow the AI to slow down while attacking capital ships. It seemed a shame to waste this code, so I've added a flag to enable the behavior.
This allows to use a different method of creating and managing the
OpenGL context. This is needed of wxFRED where the OpenGL context is
created by wxWidgets. This will probably also fix#753 since it uses the
old wgl based method of creating an OpenGL context in FRED.
If a required argument is invalid, ade_get_args() returns 0, but it wasn't making sure va_end(vl) got called first, leading to potential memory corruption (probably not a huge issue in actual usage because most people try not to release scripts that throw errors).
Previously the code simply skipped the invalid tokens and silently
ignored them. This is frustrating for modders and also let #758 slip
into the code base which would not have happened otherwise.
This removes the built-in OpenGL function pointer because we don't need
it since we are using the SDL function for that. Also explicitly uses a
compatibility loader although that has no effect on the generated code.
The documentation says that the SDL OpenGL attributes need to be
initialized before a window is created. These changes implement that by
moving the actual SD_Window creation inside the OpenGL setup. FRED only
sets the native window handle to the correct HWND and gropengl uses
that.
"Unchecked return value from library". The function can't return an
error value so I added a ml_printf (which is used at another place for
error logging as well) to log the error.
It looks like this was added to trunk (a0f31e6), synced with antipodes (4952b70), and then one of the antipodes merges (7e77b5a) wound up combining both additions.
The Assertion which was triggered was carried over from the OpenGL code
but the stub code was using pretty much the same code so removing the
Assertion seems like the correct way to solve this.
This instructs SDL to create an OpenGL debug context when a debug build
is used. Additionally it uses GL_ARB_debug_output if it's available to
provide OpenGL debug output.
This allows to use standard TrueType Fonts for text rendering in FSO. It uses the NanoVG library which provides the ability of drawing 2D shapes. This library is used for most 2D operations now and can also be used directly by using the PathRenderer class.
The CMake merge changed the default files system to include individual files instead of use a bunch of hardcoded strings, but the old file got left behind for some reason. Also, the same merge added some spurious extra imports of def_files.h which I removed at the same time (although if somebody wanted to go through and clean up all of our imports again, it'd probably be a good time for it).
The launcher passes the mod folders as relative paths using / as the
directory separator. That path is copied into the cf_root path and when
cf_create_directory tries to create the directory, mkdir_recursive can't
handle the / in the path and tries to create two path elements at once
which is not supported by mkdir.
These changes fix that by converting mod paths to the native format
(from the / format, so it's a No-op on Unix) before using it in
cf_create_root().
This expands the existing system which only worked on Windows to all
supported platforms.
If the MSVC debug runtime is not present then its behavior is emulated
by adding a header to each allocated memory block.
Originally, "share fire dir" forced the "salvo mode" flag. This
interfered with the "use multiple guns" flag. In order to avoid this, I
instead made "share fire dir" if either "salvo mode" or "use multiple
guns" is not found, as those are the only two flags that, coupled with
"share fire dir" give the desired results.
Bombs can give points for being shot down. This was being handled by a full-blown pair of damage_ship/damage_ship_id arrays, just like ships have for scoring purposes. This is ridiculous overkill when most bombs are shot down with a single pull of the trigger and means we were storing a couple hundred bytes of data that would be completely unused for the vast majority of projectiles. Now, whoever shoots down a bomb gets the points for it; period. Simple, and we can remove all scoring data from the weapon struct.
Lots of references to Weapons[A->instance] and Weapons[B->instance], despite having created pointers for them earlier in the function. Also, I have no idea what was up with the override conditional.
This seems preferable to storing an entire mc_info object on every weapon, when the vast majority of projectiles (by the very nature of the fact that they still exist) won't have collided with anything.
On the other hand, I'm not wild about allocating and freeing memory every time a weapon collides with a ship or debris. If anyone has a better solution, I'm all ears.
"If a or b else a" should never ever execute the "else a" branch; this appears to be an artifact left over from Wanderer's reorganization of the autoaim/convergence code in 7bb10d8, before which standard convergence and automatic convergence were handled in separate conditionals.
SET(IMPORT_EXE_DIR"IMPORT_EXE_DIR-NOTFOUND"CACHEFILEPATH"Required for a cross compiling build, point to binary directory of a cmake build for the real OS")
option(FSO_BUILD_APPIMAGE"Build an AppImage package"OFF)
set(APPIMAGE_ASSISTANT""CACHESTRING"The root directory of an AppImage clone.")
ENDIF(WIN32)
OPTION(FSO_BUILD_TOOLS"Build tools related to FSO"OFF)
OPTION(FSO_BUILD_TESTS"Build unit tests"OFF)
OPTION(FSO_DEVELOPMENT_MODE"Generate binaries in development mode, only use if you know what you're doing!"OFF)
OPTION(FSO_BUILD_QTFRED"Build qtFRED2 binary"OFF)
IF(WIN32ORAPPLE)
# On windows and mac the default should be to always build the included libraries
SET(FSO_BUILD_INCLUDED_LIBS_DEFAULTON)
ELSE()
SET(FSO_BUILD_INCLUDED_LIBS_DEFAULTOFF)
ENDIF()
OPTION(FSO_BUILD_INCLUDED_LIBS"Build and use the included libraries istead of using the system headers and libraries"${FSO_BUILD_INCLUDED_LIBS_DEFAULT})
OPTION(FSO_USE_LUAJIT"Use LuaJIT for Lua scripting, needs a working internet connection!"OFF)
OPTION(FSO_USE_OPENALSOFT"Download and build OpenAL Soft instead of using the system libraries"OFF)
OPTION(FSO_FATAL_WARNINGS"Determines if warnings in the build are considered fatal errors, primarily used for CI"OFF)
SET(FSO_FREESPACE_PATH"${CMAKE_INSTALL_PREFIX}"CACHEFILEPATH"The path of the FreeSpace directory you want to use. Please note that you will have to change CMAKE_INSTALL_PREFIX if you change this at some point.")
SET(FSO_RUN_ARGUMENTS""CACHESTRING"Additional arguments passed to a generated executable when run with the generated build files.")
option(FSO_INSTALL_DEBUG_FILES"Install some debug files (currently only PDB files on windows)"OFF)
MARK_AS_ADVANCED(FORCEFSO_CMAKE_DEBUG)
MARK_AS_ADVANCED(FORCEFSO_BUILD_INCLUDED_LIBS)
MARK_AS_ADVANCED(FORCEFSO_USE_OPENALSOFT)
MARK_AS_ADVANCED(FORCEFSO_USE_LUAJIT)
MARK_AS_ADVANCED(FORCEFSO_DEVELOPMENT_MODE)
MARK_AS_ADVANCED(FORCEFSO_FATAL_WARNINGS)
mark_as_advanced(FORCEFSO_INSTALL_DEBUG_FILES)
# Include cotire file from https://github.com/sakra/cotire/
In 2002 Volition released the source code for Freespace2. In the years since dedicated individuals have added countless new features to create a flexible and powerful space combat simulation engine. More info can be found on our [wiki](http://www.hard-light.net/wiki/index.php/Source_Code_Project)
People interested in contributing are encouraged to read [this thread](http://www.hard-light.net/forums/index.php?topic=82688.0)
The "projects" directory contains ready projects for:
* Microsoft Visual C++ 6, 2005, 2008, 2010, 2011, 2013, 2015
* Apple Xcode
* Code::Blocks
* Eclipse
Review the commit logs to see what's new.
See the INSTALL file for instructions on how to build fs2_open, or open the relevant MSVC project
Before you do anything, make sure you have updated your git submodules, either by running `git submodule update --init --recursive` or by cloning the repository with the `--recursive` flag.<br/>
<br/>
For building you will need [CMake](http://www.cmake.org/cmake/resources/software.html). Version 3.4 is required. Once you have installed CMake you should create a build directory where the project/make files should be created, **do not create them inside the source tree!**<br>
<br>
On Windows you can use the `cmake-gui` executable to get a nice GUI, on Unix just use `cmake`. Use the newly created directory as build directory (change to this directory on Unix) and run cmake. On Windows this can be done by clicking the `Configure` button. Choose your compiler version and hit `Generate` when configuring is done. <br>
Depending on the makefile generator used build the `all` or `ALL_BUILD` target to compile the project.<br>
### Available variables to control the build
*`FSO_BUILD_WXFRED2`: Build the wxfred2 project, requires wxWidgets
*`FSO_FREESPACE_PATH`: Sets the path of your FreeSpace install, can be used to automatically run the generated executables with the correct working directory, this is an optional variable. By default this will use the value of the `FS2PATH` environment variable.
*`FSO_BUILD_TOOLS`: Build some tools related to FSO
*`CMAKE_BUILD_TYPE`: Sets the binary build type between `Debug` and `Release` (default)
#### Windows only variables
*`FSO_BUILD_FRED2`: Build FRED2, requires a Visual Studio version that ships with MFC
*`FSO_USE_SPEECH`: Build a binary with text-to-speech support
*`FSO_USE_VOICEREC`: Build a binary with voice recognition support
#### Advanced variables
You should only use these variables if you know what you're doing
*`FSO_BUILD_INCLUDED_LIBS`: Build libraries from the included source
*`FSO_USE_OPENALSOFT`: Use [OpenALSoft](http://kcat.strangesoft.net/openal.html) for OpenAL support
*`FSO_USE_LUAJIT`: Use [luajit](http://luajit.org/) as a replacement for lua
*`FSO_DEVELOPMENT_MODE`: Toggles some development behavior, only use if you really need it.
*`FSO_RUN_ARGUMENTS`: If you run an executable from within the project, these arguments will also be passed to the executable
*`FSO_BUILD_POSTFIX`: Sets a postfix to be added to the executable name, may be useful for release candidates.
#### Visual Studio specific variables
*`MSVC_USE_RUNTIME_DLL`: Use the DLL version of the runtime, experimental and not well tested.
*`MSVC_SIMD_INSTRUCTIONS`: The instruction set the executables will be optimized for.
### Generating an installation package
CMake can automatically generate installation packages of the project. To do this you will just need to run the `package` target of the build system and the package will be placed inside your build directory. On Windows you will have to install [NSIS](http://nsis.sourceforge.net/Main_Page) to use this.
# Since the Travis CI people are not capable of enabling SSH/SCP support for their libcurl we need to build that manually...
# These commands are based on the tutorial from here: http://zeroset.mnim.org/2013/03/14/sftp-support-for-curl-in-ubuntu-12-10-quantal-quetzal-and-later/
option(MSVC_USE_RUNTIME_DLL"Use the dynamically linked version of the runtime"OFF)
option(MSVC_RELEASE_DEBUGGING"Set options that allow to debug release builds"OFF)
MARK_AS_ADVANCED(FORCEMSVC_USE_RUNTIME_DLL)
MARK_AS_ADVANCED(FORCEMSVC_RELEASE_DEBUGGING)
# These are the warnings we disable
set(WARNING_FLAGS
/wd4100# unreferenced formal parameters
/wd4127# constant conditional (assert)
/wd4201# nonstandard extension used: nameless struct/union (happens a lot in Windows include headers)
/wd4290# C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
/wd4390# empty control statement (triggered by nprintf and mprintf's inside of one-line if's, etc)
/wd4410# illegal size for operand... ie... fxch st(1)
/wd4511# copy constructor could not be generated (happens a lot in Windows include headers)
/wd4512# assignment operator could not be generated (happens a lot in Windows include headers)
/wd4514# unreferenced inline function removed
/wd4611# _setjmp warning. Since we use setjmp alot, and we don't really use constructors or destructors, this warning doesn't really apply to us.
/wd4663# C++ language change (template specification)
/wd4710# is inline function not expanded (who cares?)
/wd4711# tells us an inline function was expanded (who cares?)
/wd4786# is identifier truncated to 255 characters (happens all the time in Microsoft #includes) -- Goober5000"
/wd4996# deprecated strcpy, strcat, sprintf, etc. (from MSVC 2005) - taylor
/wd4311# Disables warnings about casting pointer types to ints. The funny thing is these warnings can't be resolved, just disabled... - m!m
/wd4302# Same as above - m!m
/wd4366# The result of the unary '&' operator may be unaligned - m!m
/wd4592# "symbol will be dynamically initialized" is being generated by a compiler bug, see https://stackoverflow.com/a/34027257 for an explanation - m!m
$<$<CONFIG:Release>:/wd4101># In release mode there are unreferenced variables because debug needs them
/wd4995# "'vsprintf': name was marked as #pragma deprecated" is being caused by our custom definition of vsprintf. I have no idea what causes this or how to fix it - m!m
SET(MSVC_SIMD_INSTRUCTIONS"${MSVC_DETECTED_SIMD_INSTRUCTIONS}"CACHEFILEPATH"The SIMD instructions which will be used, possible values are ${POSSIBLE_INSTUCTION_SETS}")
#define AIG_TYPE_PLAYER_WING 4 // from player direct to wing
#define AIG_TYPE_DYNAMIC 5 // created on the fly
// flags for AI_GOALS
#define AIGF_DOCKER_INDEX_VALID (1<<0) // when set, index field for docker is valid
#define AIGF_DOCKEE_INDEX_VALID (1<<1) // when set, index field for dockee is valid
#define AIGF_GOAL_ON_HOLD (1<<2) // when set, this goal cannot currently be satisfied, although it could be in the future
#define AIGF_SUBSYS_NEEDS_FIXUP (1<<3) // when set, the subsystem index (for a destroy subsystem goal) is invalid and must be gotten from the subsys name stored in docker.name field!!
#define AIGF_GOAL_OVERRIDE (1<<4) // paired with AIG_TYPE_DYNAMIC to mean this goal overrides any other goal
#define AIGF_PURGE (1<<5) // purge this goal next time we process
#define AIGF_GOALS_PURGED (1<<6) // this goal has already caused other goals to get purged
Formation_wing,// Fly in formation as part of wing.
Awaiting_repair,// Awaiting a repair ship.
Being_repaired,// Currently docked with repair ship.
Repairing,// Repairing a ship (or going to repair a ship)
Seek_lock,// set if should focus on gaining aspect lock, not hitting with lasers
Formation_object,// Fly in formation off a specific object.
Temporary_ignore,// Means current ignore_objnum is only temporary, not an order from the player.
Use_exit_path,// Used by path code, to flag path as an exit path
Use_static_path,// Used by path code, use fixed path, don't try to recreate
Target_collision,// Collided with aip->target_objnum last frame. Avoid that ship for half a second or so.
Unload_secondaries,// Fire secondaries as fast as possible!
On_subsys_path,// Current path leads to a subsystem
Avoid_shockwave_ship,// Avoid an existing shockwave from a ship.
Avoid_shockwave_weapon,// Avoid an expected shockwave from a weapon. shockwave_object field contains object index.
Avoid_shockwave_started,// Already started avoiding shockwave, don't keep deciding whether to avoid.
Attack_slowly,// Move slowly while attacking.
Repair_obstructed,// Ship wants to be repaired, but path is obstructed.
Kamikaze,// Crash into target
No_dynamic,// Not allowed to get dynamic goals
Avoiding_small_ship,// Avoiding a player ship.
Avoiding_big_ship,// Avoiding a large ship.
Big_ship_collide_recover_1,// Collided into a big ship. Recovering by flying away.
Big_ship_collide_recover_2,// Collided into a big ship. Fly towards big ship sphere perimeter.
Stealth_pursuit,// AI is trying to fight stealth ship
Unload_primaries,// Fire primaries as fast as possible!
Trying_unsuccessfully_to_warp,// Trying to warp, but can't warp at the moment
Free_afterburner_use,// Use afterburners while following waypoints or flying towards objects
NUM_VALUES
};
FLAG_LIST(Goal_Flags){
Docker_index_valid,// when set, index field for docker is valid
Dockee_index_valid,// when set, index field for dockee is valid
Goal_on_hold,// when set, this goal cannot currently be satisfied, although it could be in the future
Subsys_needs_fixup,// when set, the subsystem index (for a destroy subsystem goal) is invalid and must be gotten from the subsys name stored in docker.name field!!
Goal_override,// paired with AIG_TYPE_DYNAMIC to mean this goal overrides any other goal
Purge,// purge this goal next time we process
Goals_purged,// this goal has already caused other goals to get purged
Depart_sound_played,// Goober5000 - replacement for AL's hack ;)
Target_own_team,
NUM_VALUES
};
FLAG_LIST(Maneuver_Override_Flags){
Full,// Full sexp control
Roll,// Sexp forced roll maneuver
Pitch,// Sexp forced pitch change
Heading,// Sexp forced heading change
Full_lat,// full control over up/side/forward movement
if(!(En_objp->flags&OF_PROTECTED)||((aip->goals[0].ai_mode&(AI_GOAL_DISABLE_SHIP|AI_GOAL_DISARM_SHIP))&&swip->wi_flags&WIF_PUNCTURE)){//override lockdown on protected ships when using anti subsystem weapons - Valathil
if(!(En_objp->flags[Object::Object_Flags::Protected])||((aip->goals[0].ai_mode&(AI_GOAL_DISABLE_SHIP|AI_GOAL_DISARM_SHIP))&&swip->wi_flags[Weapon::Info_Flags::Puncture])){//override lockdown on protected ships when using anti subsystem weapons - Valathil
// If ship is protected and very low on hits, don't fire missiles.
@@ -1573,7 +1608,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
wing*wingp=&Wings[sindex];
if(wingp->flags&WF_WING_GONE)
if(wingp->flags[Ship::Wing_Flags::Gone])
returnAI_GOAL_NOT_ACHIEVABLE;
elseif(wingp->total_arrived_count==0)
returnAI_GOAL_NOT_KNOWN;
@@ -1605,7 +1640,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
}
else
{
Int3();// get ALLENDER
mprintf(("Potentially incorrect behaviour in AI goal for ship %s: Ship %s could not be found among currently active, departed, or yet-to-arrive ships.\nPlease check the mission file.\n",Ships[objp->instance].ship_name,aigp->target_name));
status=SHIP_STATUS_UNKNOWN;
}
}
@@ -1620,15 +1655,15 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
// if the goal is an ignore/disable/disarm goal, then
// Goober5000 - see note at PURGE_GOALS_ALL_SHIPS... this is bizarre
Assertion(bm_inited,"bmpman must be initialized before this function can be called!");
intbitmapnum=handle%MAX_BITMAPS;
Assertion(bm_bitmaps[bitmapnum].handle==handle,"Invalid bitmap handle %d passed to bm_get_signature().\nThis might be due to an invalid animation somewhere else.\n",handle);// INVALID BITMAP HANDLE!
@@ -966,7 +974,7 @@ int bm_get_tcache_type(int num) {
}
BM_TYPEbm_get_type(inthandle){
if(!bm_inited)bm_init();
Assertion(bm_inited,"bmpman must be initialized before this function can be called!");
intbitmapnum=handle%MAX_BITMAPS;
Assertion(bm_bitmaps[bitmapnum].handle==handle,"Invalid bitmap handle %d passed to bm_get_type().\nThis might be due to an invalid animation somewhere else.\n",handle);// INVALID BITMAP HANDLE!
Assertion(goal_position>=cb->lib_offset,"Invalid offset values detected while seeking! Goal was "SIZE_T_ARG", lib_offset is "SIZE_T_ARG".",goal_position,cb->lib_offset);
}
// If we only have a data pointer this will do all the work
cb->raw_position=goal_position-cb->lib_offset;
Assertion(cb->raw_position<=cb->size,"Invalid raw_position value detected!");
#if defined(CHECK_POSITION) && !defined(NDEBUG)
inttmp_offset;
tmp_offset=(int)ftell(cb->fp)-cb->lib_offset;
Assert(tmp_offset==cb->raw_position);
if(cb->fp){
autotmp_offset=ftell(cb->fp)-cb->lib_offset;
Assert(tmp_offset==cb->raw_position);
}
#endif
returnresult;
@@ -185,21 +189,15 @@ int cfread(void *buf, int elsize, int nelem, CFILE *cfile)
if(!cf_is_valid(cfile))
return0;
intsize=elsize*nelem;
size_tsize=elsize*nelem;
if(buf==NULL||size<=0)
return0;
Cfile_block*cb=&Cfile_block_list[cfile->id];
// cfread() not supported for memory-mapped files
if(cb->data!=NULL)
{
Warning(LOCATION,"Writing is not supported for mem-mapped files");
return0;
}
if((cb->raw_position+size)>cb->size){
Assertion(cb->raw_position<=cb->size,"Invalid raw_position value detected!");
size=cb->size-cb->raw_position;
if(size<1){
return0;
@@ -208,7 +206,7 @@ int cfread(void *buf, int elsize, int nelem, CFILE *cfile)
Loaded 100 of 1945 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.