Compare commits

...
Author SHA1 Message Date
SirKnightly efff196800 Automated build commit 2023-01-04 19:11:24 +00:00
Goober5000 a7b46dba58 Merge pull request #5060 from MjnMixael/fix_mainhall_anims
SCPUI needs to be able run game_close_level
2023-01-03 21:23:38 -05:00
mjn-mixael 1f7cdca5a9 optional 2023-01-03 19:56:56 -06:00
Goober5000 d2eff1f141 Merge pull request #5073 from Goober5000/fixed_chain_repeat
restore retail behavior of chaining to repeating events
2023-01-03 19:03:33 -05:00
Goober5000 9ce7748c20 Merge pull request #5039 from Goober5000/object_iteration_fixes
more robust object iteration
2023-01-03 19:03:22 -05:00
mjn-mixael c74d523e18 third attempt at getting past that one guy 2023-01-03 14:52:55 -06:00
mjn-mixael 0bc26cab24 Revert "make sure game time is running in the mainhall"
This reverts commit 155e043bb0.
2023-01-03 08:37:06 -06:00
Goober5000 0d56bb9999 restore retail behavior of chaining to repeating events
To avoid changing behavior of existing mods, simulate the retail behavior unless the bugfix is explicitly activated.  The buggy retail behavior is to evaluate a chained event, not skip it, if the event is repeating, regardless of whether the repeat timestamp has elapsed.
2023-01-03 01:37:18 -05:00
Goober5000 f2fa235522 Merge pull request #5058 from Goober5000/missile_obj_list_iteration
add should-be-dead checks for missile and asteroid iterations
2023-01-02 14:19:03 -05:00
Goober5000 7829989478 Merge pull request #5070 from MjnMixael/fix_ingame_joystick
Make sure all 4 in-game joystick options get evaluated
2023-01-02 01:12:43 -05:00
mjn-mixael a8e411d310 Make sure all 4 ingame joystick options get evaluated 2023-01-01 23:30:50 -06:00
Goober5000 07924f078a use Missile_obj_list or Asteroid_obj_list instead of obj_used_list where appropriate 2023-01-01 18:13:29 -05:00
Goober5000 782980844b add checks to Missile_obj_list and Asteroid_obj_list 2023-01-01 18:13:29 -05:00
Goober5000 c95865442e Merge pull request #5065 from notimaginative/fix_joystick_loops
swap loop order to fix joystick detection issue
2023-01-01 18:00:35 -05:00
Goober5000 f484ddef06 Merge pull request #5066 from notimaginative/fix_joyid_problem
use correct joystick id type (instance -> device)
2023-01-01 18:00:26 -05:00
JohnAFernandez 0c687f37c1 Merge pull request #5062 from Baezon/team-color-split-ships
Ensure 'split ships' are team colored
2022-12-31 23:24:56 -05:00
Goober5000 6de5c96127 add should-be-dead checks for object iterations (#5050)
Follow-up to #5040.  This extends the checks to most iterations over `obj_used_list` in FSO.  There are a few exceptions such as `waypoint_add` and `waypoint_remove`, plus a few others.  And none of the object iterations in FRED have the guard because FRED does not use the same object life cycle as FSO.
2022-12-31 23:23:39 -05:00
Taylor Richards 083984efec add support for .vpc extension on VP archives (#5067)
.vpc is identical to existing .vp except that it is allowed to
contain compressed files. This allows builds and tooling to know
that although the archive itself is retail compatible, it's content
may require special handling.

Simply rename your existing .vp to .vpc to indicate that it may
use compressed files. Existing tools can be updated to be able to
handle the compressed content within.

Although not recommended, the same archive can exist as both .vp
and .vpc for maximum compatibility. Both archives will be indexed
but the content of the .vpc will have priority.
2022-12-31 18:58:28 -05:00
Taylor Richards 9346f67d5c use correct joystick id type (instance -> device)
fixes #4793
2022-12-30 21:57:10 -05:00
Taylor Richards d2322cb2c2 swap loop order to fix joystick detection issue
fixes #4792
2022-12-30 21:48:34 -05:00
Asteroth 96f2a3b045 ensure split ships are team colored 2022-12-30 00:45:03 -05:00
Goober5000 e2e14bb6df Merge pull request #5059 from Baezon/team-color-change-pobjp
Check for parse object before team color change
2022-12-29 14:37:04 -05:00
mjn-mixael 155e043bb0 make sure game time is running in the mainhall 2022-12-29 11:01:43 -06:00
Asteroth ef721b3192 check for parse object 2022-12-29 03:27:38 -05:00
Goober5000 06ded501c8 Merge pull request #5056 from Goober5000/comment_tweak
comment tweak
2022-12-29 01:08:51 -05:00
Goober5000 9540caff5a Merge pull request #5057 from MageKing17/bugfix/use-universal-textifying
Use `textify_scancode_universal()` in more places.
2022-12-29 00:07:48 -05:00
MageKing17 3eacbc0e0b Use textify_scancode_universal() in more places.
Controls6 (PR #4133) changed `textify_scancode()` to be more l10n-aware, and added `textify_scancode_universal()` to continue serving the function of providing the values expected by scripts. Except there was one `textify_scancode()` call in the scripting system that wasn't changed, and it also wasn't used in FRED (for providing values for the `OPF_KEYPRESS` argument type, as used with `key-pressed`). This commit fixes both of these oversights, which *should* mean that all instances where a script or mission file needs to reference a keypress now use the same strings as before controls6.
2022-12-28 18:03:07 -08:00
Goober5000 a2d4576c4f comment tweak
Add a useful summary to the comment about event timestamps.
2022-12-28 17:34:15 -05:00
Fabian WoltermannandFabian Woltermann c727e40b8a apply the HDR colorspace stuff _after_ mixing in the team color glows (#5052)
Co-authored-by: Fabian Woltermann <[email protected]>
2022-12-28 18:48:20 +01:00
Goober5000 78b385e41b Merge pull request #5051 from Goober5000/wing_fix_and_error_checks
fix wing cues and add some more error checks
2022-12-27 15:30:34 -05:00
Goober5000 5485efe904 fix wing cues and add some more error checks
Fixes #5045 by correctly initializing wing arrival and departure cues.  Follow-up to #4856.  Also adds a bit more SEXP error checking.
2022-12-27 01:33:53 -05:00
Goober5000 85bb14898f Merge pull request #5040 from Goober5000/ship_obj_list_iteration
add should-be-dead checks for all ship iterations
2022-12-26 22:28:00 -05:00
MjnMixael a3bbf13da6 prevent access to goals outside the vector (#5044)
prevent access to goals outside the vector
2022-12-24 21:12:56 -05:00
JohnAFernandez 10d3bdda06 Merge pull request #5041 from MjnMixael/consolidate_tech_rendering
consolidation of tech rendering methods
2022-12-24 11:59:12 -05:00
Goober5000 dd93284777 Merge pull request #5043 from Baezon/no-pobjp-crash-fix
Fix a crash in `change_ship_type`
2022-12-23 13:14:06 -05:00
Goober5000 d6bb97d8f2 address feedback 2022-12-23 02:11:54 -05:00
Goober5000 46293ad0fe add should-be-dead checks for all ship iterations
When iterating through `Ship_obj_list`, check the `Should_be_dead` flag before using the object.  This fixes #4990 and adds defense-in-depth checks to guard against similar errors elsewhere.

I considered moving the `Ship_obj_list` removal from `obj_delete` to `ship_cleanup`, but decided it would be prudent to avoid fundamental changes to lifecycle management.
2022-12-23 00:51:31 -05:00
mjn-mixael 8aa4a86e1c set shadow override 2022-12-22 07:02:10 -06:00
Asteroth ca7618c993 check for if a ship has a parse object first 2022-12-22 04:02:43 -05:00
mjn-mixael a662f8168c consolidation of tech rendering methods 2022-12-21 20:45:40 -06:00
Goober5000 c2b93549a2 more robust object iteration
When iterating through various object collections, check for the should-be-dead flag to avoid returning objects that are on the verge of being deleted.

Separately, this adds the `isExpiring` function to check for should-be-dead objects.

This PR also makes object iteration consistent across all object types, both to reduce code duplication and to ensure that the length and iteration are done using the same algorithm.  Furthermore, if the number of should-be-dead objects is nonzero, the Lua array count for that frame will be different from the internal array count for that frame.

Fixes #5034.
2022-12-21 19:51:02 -05:00
Goober5000 32852c967e Merge pull request #5037 from Goober5000/hud_lock_iteration_fix
patch hud-lock iteration for objects that aren't ships
2022-12-21 12:44:46 -05:00
Goober5000 342373e2a1 Merge pull request #5038 from Goober5000/patch_hud_target_live_turret
patch some crash vulnerabilities in hud_target_live_turret
2022-12-21 12:43:59 -05:00
Goober5000 1070d1dbea patch hud-lock iteration for objects that aren't ships
Add a few more safety checks; don't assume every item is a ship.
2022-12-21 00:40:09 -05:00
Goober5000 6cf6b3266f patch some crash vulnerabilities in hud_target_live_turret
These checks risked causing a crash or memory access violation if they were ever encountered with an invalid target when `auto_advance` is true.
2022-12-20 20:40:43 -05:00
Asteroth f464b30089 update regen rates and autoaim fov on ship class change (#5029) 2022-12-21 00:17:23 +09:00
Asteroth 0fb6b2ae0d Update 22.4 version references to 23.0 (#5025)
* update references to 22.4 to 23.0

* fix a few more version references
2022-12-21 00:16:51 +09:00
Fabian Woltermann 18c182acc8 script hooks must be declared within global_hooks so that both FRED and FSO can see them (#5031) 2022-12-20 11:55:36 +01:00
Taylor Richards c9291e3f1c address issues related to cf.openFile() error handling (#5030)
- fix crash bug when path only contains dir separators
 - fix error handling when no path is specified in write mode
 - clarify function documentation

Fixes #5028
2022-12-20 01:27:51 -05:00
Goober5000 00f0cc4847 Merge pull request #5027 from Goober5000/comm_menu_open
add hu.isCommMenuOpen
2022-12-19 20:33:04 -05:00
Tyler Blount 2f8e10b8d8 Merge pull request #5024 from scp-fs2open/fix/CI-POST-result-status
Change check of POST response result
2022-12-18 20:35:01 -07:00
Tyler Blount 0acb22456c Respecify the env for Post Builds auto-trigger 2022-12-18 14:15:04 -07:00
Tyler Blount 22c8ae024e Change check of POST response result
This modified the check as `text` has been changed in the Requests API. In order to make the code compatible with the JSON result, we check `resp.status_code` instead.
2022-12-18 13:53:32 -07:00
Tyler Blount 5857b569a1 Merge pull request #5023 from scp-fs2open/fix/build-post-23.0-RC1
Fix failure to post Mac builds to forums
2022-12-18 11:31:26 -07:00
Tyler Blount 9136c04a34 Fix failure to post Mac builds to forums
Also includes replacement of string literals with constants to reduce maintenance overhead in the event the name of a group changes.
2022-12-18 10:22:31 -07:00
Fabian WoltermannandFabian Woltermann 87926995df Feature/dear imgui (#4987)
* Add imgui

* migrate render options

* remove wmcgui

* Add subsystem selection and highlighting

* Add a syntactic sugar extension for imgui

* don't rebuild the mission list every frame

* Add imgui_sugar extension

* Move helper functions out of lab_ui, add function to display consolidated table text for object

* add button to export cubemap

* fix entering and exiting the lab

* refactor some of this for greater cleanness

* use techroom lighting when no mission background is set

* minor things

* add imguizmo

* add imguizmo

* Add imgui

* migrate render options

* remove wmcgui

* Add subsystem selection and highlighting

* Add a syntactic sugar extension for imgui

* don't rebuild the mission list every frame

* Move helper functions out of lab_ui, add function to display consolidated table text for object

* add button to export cubemap

* fix entering and exiting the lab

* refactor some of this for greater cleanness

* minor things

* add imguizmo

* add imguizmo

* Add button to reset changes made in the render dialog

* refactoring

* unfuck rebase

* fix issue with loose mission files

* use with_CollapsingHeader for greater uniformity

* add weapon selection functionality

* make primaries and secondaries fire again

* implement animation triggers

* avoid crash when switching back and forth between ships with and without team colors

* add control to set team color setting to renderer texture dialog

* make sure the table text updates when the ship class changes

* let rotating subsystems rotate

* do not add imgui.h to pstypes

* code cleanup

* add subsys highlighter from fred

* Highlight non-modelled subsystems as well

* add cmdline flag to show the imgui demo dialogue

* fix compiler warnings reported by CI

* fix error when building the subsystem list

* refactor variable/method naming

* code cleanup

* remove vestigial code

* update to imgui 1.89.1

* add credits entry for imgui

* use the imgui namespace

* Separate the background dialog out into its own window

* make sure the subsystem highlights are placed correctly

Co-authored-by: Fabian Woltermann <[email protected]>
2022-12-18 16:29:20 +01:00
BMagnu 66becc983e Fix OnBeamCollision oversight (#5021) 2022-12-18 01:04:59 +00:00
Goober5000 47564d1505 Merge pull request #5008 from MjnMixael/asteroid_sexp_error_checks
Add missing asteroid debris argument type error checking
2022-12-16 23:04:13 -05:00
Goober5000 4572aa1bc1 Merge pull request #5004 from JohnAFernandez/fix-use-of-incorrect-variables
Use the correct variables in this function
2022-12-16 22:58:59 -05:00
Goober5000 d36db98974 Merge pull request #5014 from MjnMixael/fix_render_tech_model
Do not include -destroyed subobjects in renderTechModel
2022-12-16 22:58:48 -05:00
Goober5000 a822d2ad60 Merge pull request #5016 from Goober5000/navpoint_fixes
initialize NavPoint properly
2022-12-16 22:58:41 -05:00
Goober5000 e3fc5f8bc1 add hu.isCommMenuOpen
A script function to tell if the comms menu is open
2022-12-16 22:20:52 -05:00
Fabian Woltermann 386e068890 Merge pull request #5015 from The-E/fix/old_ai_weapon_link_copypasta
fix vintage copypasta bug
2022-12-16 21:09:50 +01:00
Goober5000 5a674a7db1 initialize NavPoint properly
Initialize NavPoint values any time a NavPoint object is created, not just when the `clear()` function is run.
2022-12-16 12:59:53 -05:00
Fabian Woltermann 5984be99b6 fix vintage copypasta bug 2022-12-16 18:35:52 +01:00
mjn-mixael 84962ff33c Remove model instances after rendering 2022-12-16 09:39:11 -06:00
mjn-mixael 3136e0debf Use a model instance to prevent rendering destroyed subobjects 2022-12-16 09:31:19 -06:00
Goober5000 7318221e6a Merge pull request #5002 from Goober5000/beam_team
beam teams
2022-12-15 17:46:26 -05:00
Goober5000 c3477e88a7 beam teams
Add a Team virtvar to beam objects in Lua.
2022-12-15 15:44:54 -05:00
MjnMixael f1f27b21b7 Use define 2022-12-15 10:52:58 -06:00
Goober5000 52455bbc62 Merge pull request #5009 from MjnMixael/dynamic_sexp_enum
Dynamic sexp enum
2022-12-15 11:31:49 -05:00
mjn-mixael 25a4f66451 missed items 2022-12-15 01:01:10 -06:00
mjn-mixael e0eb7ef3d6 this should have a more unique name 2022-12-14 22:49:41 -06:00
mjn-mixael 2909e8fa2b address feedback 2022-12-14 22:32:51 -06:00
mjn-mixael a47658b336 address feedback 2022-12-14 15:41:36 -06:00
mjn-mixael 42a88a9e3f Comment 2022-12-14 13:54:17 -06:00
mjn-mixael 174976d2bb Better global name 2022-12-14 13:52:50 -06:00
mjn-mixael 911639d1b0 Add missing asteroid debris argument type error checking 2022-12-14 13:46:40 -06:00
mjn-mixael 5366f235ca Allow custom Lua Enums 2022-12-14 13:45:14 -06:00
Fabian Woltermann 76b301b4f1 Merge pull request #5007 from The-E/fix/5006_ssm_struct_not_initialized
Fix an issue with ssms sending uninitialized messages
2022-12-14 17:04:46 +01:00
mjn-mixael 49b486a326 use enum for list types 2022-12-14 09:12:11 -06:00
Fabian Woltermann c39861a600 When parsing an ssm, make sure to only use a custom message when one is actually defined 2022-12-14 15:18:05 +01:00
John Fernandez bb42302ba3 Use the correct variables in this function 2022-12-13 21:47:10 -05:00
Goober5000 29217cc2aa Merge pull request #5000 from Baezon/playdead-player-turrets
Allow player turrets to fire despite play dead
2022-12-13 19:15:53 -05:00
BMagnu 385478824e Fix refactor bug (#5001) 2022-12-13 20:56:48 +00:00
Asteroth b0c6d81d89 ship_move_subsystems too 2022-12-13 15:38:21 -05:00
Asteroth 5d66f3108f allow player turrets to fire despite play dead 2022-12-13 15:02:08 -05:00
Goober5000 922be2ff36 Merge pull request #4999 from BMagnu/problematic_counter_lib
Remove problematic counter library
2022-12-13 13:52:52 -05:00
BMagnu af1f0eaeca Rework Script Conditions (#4960)
* add skeleton for hook condition API

* Begin Scripting Hook refactor

* Program Hook Conditions for current new-style hooks

* Replace more hooks

* Fully transition global hooks

* Convert legacy hooks pt. 1

* Convert legacy hooks pt. 2

* Convert legacy hooks pt. 3

* Post-conversion cleanup

* restore parsing

* Add Documentation and fix parsing

* Fixup engine ingame hook adding

* Fixup engine ingame hook adding again

* Fix warnings

* Fix GCC unqualified template base lookup

* unqualified lookup v2

* Virtual Destrcutors

* Fix Clang

* Fix ship objp hook condition shadow

* Remove global hook include in ship.h

* Incorporate Feedback

* Incorporate Feedback 2

* Add revision to inline version specififer
2022-12-14 03:51:27 +09:00
Birk Magnussen 6b3f99eafd comment for OP_NOT_AN_OP 2022-12-13 18:43:01 +01:00
Birk Magnussen cb008706a4 Tidy up comment 2022-12-13 18:37:08 +01:00
Birk Magnussen 9366963e42 Fix formatting 2022-12-13 18:32:27 +01:00
Birk Magnussen 7ed7b37f9a Replace enum in switch for readability purposes 2022-12-13 18:25:26 +01:00
Birk Magnussen a62a9cd5e0 Remove enum type name for safery 2022-12-13 18:21:32 +01:00
BMagnu 80b75352bf Respect First OP 2022-12-13 16:10:45 +01:00
BMagnu c58216f9c3 Remove Counter library 2022-12-13 16:04:55 +01:00
Goober5000 f40a018785 Merge pull request #4996 from MageKing17/bugfix/let-vc-2017-compile-again
Add missing locale argument to `std::isdigit()` calls.
2022-12-12 15:21:00 -05:00
JohnAFernandez cf9bfb8939 Merge pull request #4997 from Goober5000/subcategory_fixes
subcategory fixes and followup
2022-12-12 12:32:55 -05:00
Goober5000 74db049f85 subcategory fixes and followup
Several items here:
1. Patches several category and subcategory validation checks (comparisons to -1 rather than _NONE) that were missed in #4965.
2. Adds sanity checks to both built-in operators and scripted sexps to ensure categories and subcategories are consistent.
3. Deconflicts several built-in sexps that had inconsistent categories.

The inconsistent operators were:
* script-eval-string
* set-wing-formation
* get-ets-value
* turret-get-primary-ammo
* turret-get-secondary-ammo
* get-fov

Follow-up to #4965 and #4995.
2022-12-12 00:08:21 -05:00
MageKing17 7fde659b42 Add missing locale argument to std::isdigit() calls.
Much like a previous instance (fixed in #3281, although the function in question was later removed), `std::isdigit()` without a locale argument prevents MSVC 2017 from compiling FSO.
2022-12-11 20:11:42 -08:00
EatThePath 780ab89b61 Merge pull request #4995 from Goober5000/fix_4994
fix subcategory comparison
2022-12-11 22:04:52 -06:00
Goober5000 afbdd39bde fix subcategory comparison
Empty subcategories are now OP_SUBCATEGORY_NONE, not -1.  Fixes #4994.

Also fixes a cast warning in missionparse.cpp.
2022-12-11 22:27:47 -05:00
JohnAFernandez 6e159345d8 Merge pull request #4993 from MjnMixael/fix_passive_arc_iterator
fix passive arc iteration
2022-12-11 19:41:34 -05:00
MjnMixael a421d38455 Asteroid/Debris cleanup + Modular asteroids table (#4870)
* set-asteroid-field sexp

* errors

* scope

* set-debris-field sexp

* Clarify sexp documentation

* num_debris_sizes

* allow any order and activate display name feature

* unify naming scheme

* modular -ast.tbm

* styling

* decouple sexp parsing and asteroid field creation methods

* remove this

* fix merge oversights

* Remove this check

* reorder

* use scp_string instead

* spacing

* Only setup display name if it's empty

* Use define instead of magic numbers

* Ensure asteroid types get the correct spawn weight

* Warn if spawn weight is set for asteroid type

* typo

* Correctly handle asteroid split types

* iiiiiiiiiiiiiiiiiint

* address feedback
2022-12-11 19:29:23 -05:00
mjn-mixael c69bc1e395 fix passive arc iteration 2022-12-11 18:04:42 -06:00
Goober5000 e89a661210 Merge pull request #4992 from Goober5000/fix_4991
fix crash in ship_close_cockpit_displays
2022-12-10 22:20:32 -05:00
Goober5000 1e834010e0 fix crash in ship_close_cockpit_displays
This function can be called when `shipp` is null, so check for that.

Fixes #4991.
2022-12-10 21:37:28 -05:00
Goober5000 4b172c0ca9 Merge pull request #4965 from Goober5000/sexp_category_bump
SEXP operators, categories, and subcategories refactoring
2022-12-10 15:18:53 -05:00
Asteroth eb3b7544b5 ensure animations load first if available (#4986) 2022-12-10 08:45:21 -05:00
Goober5000 207540303f multi version bump for new SEXP operator IDs 2022-12-09 14:44:30 -05:00
Goober5000 89ed5be8c7 Merge pull request #4875 from Goober5000/dynamic_events
dynamic events and goals
2022-12-09 13:53:54 -05:00
Goober5000 57395a772a address feedback 2022-12-09 13:47:23 -05:00
Goober5000 e179caa339 add defaults to switch blocks 2022-12-09 13:47:23 -05:00
Goober5000 621593c39f convert categories, subcategories, and operator IDs 2022-12-09 13:47:23 -05:00
Goober5000 da66b8c08c use enum for sexp error check 2022-12-09 13:47:23 -05:00
Goober5000 ffed86e8a0 typesafe oswpt_type 2022-12-09 13:47:23 -05:00
Goober5000 719148beaa typesafe sexp_oper_type 2022-12-09 13:47:23 -05:00
Goober5000 1a487473d7 MAX_OPERATORS is no longer used 2022-12-09 13:47:23 -05:00
Goober5000 eddca6bdf0 Merge pull request #4961 from Goober5000/support_ship_cleanup
clean up support ship mode in all cases
2022-12-09 13:14:45 -05:00
Goober5000 226e956fcc dynamic events and goals
Make events and goals dynamic in missions and campaigns.  When parsing, initialize all fields to their defaults.
2022-12-09 13:10:39 -05:00
Goober5000 a88ccb69e7 Merge pull request #4963 from Goober5000/messageq_enhancement
make message queue dynamic
2022-12-09 11:03:54 -05:00
Goober5000 10bdf5c03b Address feedback 2022-12-08 21:53:10 -05:00
Goober5000 12cbf9ab61 make message queue dynamic
Use a vector for storing the message queue so it can be whatever size the mission needs.

As part of this, add `free` and `vm_free` deleters to be usable with `unique_ptr` and enhance `insertion_sort` to be usable with vectors.

Fixes #4959.
2022-12-08 21:53:10 -05:00
Goober5000 6496b97d21 Merge pull request #4985 from Goober5000/disable_qt_again
try disabling Qt builds
2022-12-08 21:50:33 -05:00
Goober5000 721680cb60 try disabling Qt builds
Per the example in #3160, disable Qt builds for the time being.
2022-12-08 19:54:46 -05:00
Goober5000 c4cf9edd41 Merge pull request #4983 from Goober5000/wing_formation_script_2
exposes wing formation via scripting
2022-12-08 13:32:15 -05:00
Goober5000 7f22137bc3 exposes wing formation via scripting
A rework of #4980, adding a wing formation type and a way to access them via `tb.WingFormations`.
2022-12-08 12:02:33 -05:00
Goober5000 fd77eba855 Merge pull request #4975 from Goober5000/sendMessage_enhancement
enhance sendMessage to allow messages sent from ships
2022-12-07 20:46:06 -05:00
MjnMixael e72e90b9cc Only set the colors for passive lightning (#4982) 2022-12-07 22:39:46 +00:00
MjnMixael 6d070c88b7 clean traitor.tbl parsing (#4949) 2022-12-07 17:29:05 -05:00
BMagnu 57f529e902 Fix edge case bugs with moveables in combination with special polymodels being animated (#4981) 2022-12-07 20:43:36 +00:00
MjnMixael a51b2750aa pre parse icons to get an accurate count (#4925)
* pre parse icons to get an accurate count

* static

* Some code clarity
2022-12-07 11:00:03 -05:00
MjnMixael fce04d5907 do correct math at parse (#4979) 2022-12-07 15:40:19 +00:00
wookieejedi 07a21a607a Mod Table Settings for Arc Widths (#4967)
* Mod Table Settings for Arc Widths

There is currently a way to set the color of EMP and Damage Arcs in game_settings.tbl, but no way to change the width.

This PR adds options useful to modders to set the width and how it is calculated. Looking over the code and asking around, I developed these exposed options.

The options also allow modders to control the arc widths in multiple ways. For example, if you want to set a constant width for all ships you would set the `+Do Not Use Width Multiplier Over Radius:` to something huge, and if you wanted no arcs ever you would set the `+Width Default:` to 0.

They are tested and work as expected.

* clang

* fix copy paste error from #2053

* tab cleanup

* whitespace cleanup 2

* same for type ship and damage
2022-12-07 07:24:05 -05:00
wookieejedi 3f21ba4d17 Expose decal options useful for modders (#4957)
* Fixes CTD with decals on dying ships

If a ship was getting shot with weapons that used decals, the decal code would hit an assertation, because the invalid decals were not being all removed.

This PR updates the decal cleanup loop, to ensure that no decals are missed and all invalid ones are removed. Tests confirm this fixes the issue.

Also cleaned up some comments and moved another assertation before setting of variables.

* Exposes modder useful options to decals

Now that decals are very stable, this PR exposes two options that are very useful for using decals, a random range for the radius along with the option to have a random rotation when the decal is created.

Tested and everything works as expected.

* add script ability to toggle decals

* properly use set arg not func

* fix two minor things in decal shader

* one more cleanup line

* fixes
2022-12-07 07:23:57 -05:00
Goober5000 0c49b09fd7 Merge pull request #4977 from Goober5000/set_formation
add changeable formation flying
2022-12-07 00:38:10 -05:00
Goober5000 e824caeea3 add changeable formation flying
Add a SEXP to change the formation and formation scale on-the-fly.
2022-12-06 23:16:54 -05:00
Goober5000 0211f44df9 Merge pull request #4973 from MjnMixael/fix_custom_data
Fix custom data when using tbms
2022-12-06 22:53:15 -05:00
Goober5000 823566244f Merge pull request #4953 from Baezon/fullneb-background-bgs
Add mission flag to show bg bitmaps despite fullneb
2022-12-06 22:52:51 -05:00
Goober5000 0e80428d48 Merge pull request #4946 from MjnMixael/per_weapon_autoaim
per weapon auto aim feature
2022-12-06 22:52:14 -05:00
Goober5000 ab3eb196b9 Merge pull request #4976 from Goober5000/fix_player_cheat_check
move player-is-cheating to the correct category
2022-12-06 22:06:08 -05:00
MjnMixael bc3da4fed7 custom colors for passive lightning (#4969)
* custom colors for passive lightning

* initialize member variables and apparently this can't be nullptr

* Small bugfix
2022-12-06 19:57:16 -05:00
Goober5000 ed06a424e2 move player-is-cheating to the correct category 2022-12-06 19:25:19 -05:00
Goober5000 bb3b3b7b13 Merge pull request #4974 from MjnMixael/remove_at_symbol
move @ removal up
2022-12-06 18:54:29 -05:00
Goober5000 affb402ee7 Merge pull request #4972 from Goober5000/mission_do_departure_cleanup
clean up mission_do_departure
2022-12-06 18:52:58 -05:00
Goober5000 7ac37d45c3 enhance sendMessage to allow messages sent from ships
Allow `mn.sendMessage` to send from a ship source, not only a string source, by allowing the ship object to be specified as the first argument.  Also add `ship:sendMessage` which is a more streamlined version of the same thing.
2022-12-06 16:40:00 -05:00
mjn-mixael b3b349a2f0 three lines for this short comment is silly 2022-12-06 12:50:35 -06:00
mjn-mixael 2988aa8fc8 move @ removal up 2022-12-06 12:43:33 -06:00
mjn-mixael 4d84e4c2a0 Make sure custom_data is properly cleared or carried over when shipclass info is reset or cloned/moved 2022-12-06 09:48:33 -06:00
Goober5000 d9dfceb279 clean up mission_do_departure
Since `mission_do_departure` can be called for multiple frames in a row, make sure that certain things run only once.
2022-12-05 22:00:51 -05:00
Goober5000 9dfb36962c Merge pull request #4971 from Goober5000/fix_cockpit_ctd
fix a crash when the Knossos explodes in A Flaming Sword
2022-12-05 21:45:26 -05:00
Goober5000 c634e64f27 fix a crash when the Knossos explodes in A Flaming Sword
The ship being accessed here is the viewer object, not the loop iterator.

Follow-up to #4936.
2022-12-05 19:56:48 -05:00
mjn-mixael 662d5f743a address feedback 2022-12-05 09:59:06 -06:00
BMagnu fb223c1dbe Properly init cockpit_model_instance to -1 (#4966) 2022-12-05 15:32:09 +00:00
BMagnu 5bb869953e Animate More Things (#4936)
* Add Cockpit AnimSet

* Add Skybox Animset

* Add cockpit model instanc

* Render ship cockpit with instance

* Finish scripting API

* Add moveables

* Fix Typo

* Fix moveable table value get

* Fix copy paste error

* Add Cockpit AnimSet

* Add Skybox Animset

* Add cockpit model instanc

* Render ship cockpit with instance

* Finish scripting API

* Add moveables

* Fix Typo

* Fix moveable table value get

* Fix copy paste error

* Add Animation Scripting Handle

* Add proper saving of skybox anim triggers

* Properly step non-obj animations

* Incorporate feedback

* Incorporate feedback

* Fix comparison
2022-12-05 10:00:29 +09:00
Goober5000 97614517a2 Merge pull request #4962 from Goober5000/set_weapon_protecc
add some additional weapon checks
2022-12-04 15:17:49 -05:00
Goober5000 0a29a74bc8 Merge pull request #4964 from Goober5000/squadron_wing_name_fix
fix wing name matching
2022-12-04 15:07:11 -05:00
MjnMixael 7c695eebd0 Allow setting glowpoint light intensity (#4955) 2022-12-05 04:56:06 +09:00
Goober5000 8f6e6e97f5 fix wing name matching
The logic designed to match Epsilon and Epsilon#clone would be tripped up by Pi and Pisces.  Tweak the string matching to handle this.

Fixes a bug reported on the forums: https://www.hard-light.net/forums/index.php?topic=98576.0
2022-12-04 14:06:56 -05:00
Goober5000 9c9ca3bcd6 remove unneeded function prototypes 2022-12-04 00:25:14 -05:00
MjnMixael bdea3d53c0 set-asteroid-field and set-debris-field sexps (#4860)
* set-asteroid-field sexp

* errors

* scope

* set-debris-field sexp

* Clarify sexp documentation

* num_debris_sizes

* styling

* decouple sexp parsing and asteroid field creation methods
2022-12-03 22:10:50 -05:00
Goober5000 360dcd4e1e add some additional weapon checks
Enhance set-primary-weapon and set-secondary-weapon to check the validity of the weapon bank and weapon type.
2022-12-03 20:34:15 -05:00
Goober5000 5a9136a5c2 clean up support ship mode in all cases
Whether a ship is a support ship or its target, and whether it is destroyed or vanished, its repair/rearm mode should be cleaned up in a consistent way.  This fixes a bug in Series Resurrecta where calling `ship-vanish` on a support ship put things into a broken state.
2022-12-03 20:06:32 -05:00
Goober5000 9fbcd71442 Merge pull request #4948 from Goober5000/isMouseButtonDownCount
add mouseButtonDownCount and flushMouse
2022-12-02 11:03:57 -05:00
Goober5000 7e337944f0 Merge pull request #4943 from EatThePath/better-dynsexp-error
Improved error message for missing sexp action
2022-12-01 21:25:24 -05:00
wookieejedi 31e55f4d12 Fixes CTD with decals on dying ships (#4956)
If a ship was getting shot with weapons that used decals, the decal code would hit an assertation, because the invalid decals were not being all removed.

This PR updates the decal cleanup loop, to ensure that no decals are missed and all invalid ones are removed. Tests confirm this fixes the issue.

Also cleaned up some comments and moved another assertation before setting of variables.
2022-12-01 14:18:46 -05:00
Goober5000 398cf2f8c3 add flushMouse 2022-11-30 23:36:14 -05:00
Goober5000 028ee9ec23 deprecate isMouseButtonDown and add mouseButtonDownCount
Implements #4429.
2022-11-30 22:04:48 -05:00
Goober5000 5b1f668e6f Merge pull request #4954 from Goober5000/patch_event_timestamps
fix event status evaluation for repeating events
2022-11-30 19:41:19 -05:00
Goober5000 08626aeecf fred2 support 2022-11-30 00:46:40 -05:00
Goober5000 42fba1c7f2 fix event status evaluation for repeating events
Two situations in the event timestamp life cycle, chain delays and event status delays, require accommodation for the timestamp-plus-interval case described in `mission_process_event()`.  Commit 06fc8c73 applied the fix for chain delays; this applies the same fix to event status delays.

Follow-up to #4633.  Fixes #4951.
2022-11-29 23:42:55 -05:00
Asteroth 3ed90e2b89 Add Fullneb_background_bitmaps mission flag 2022-11-29 23:00:39 -05:00
mjn-mixael 9e2aa0377f per weapon auto aim feature 2022-11-28 14:19:00 -06:00
Kiloku 4106176aab Cheat framework allowing for custom cheats, sexp for cheat used and On Cheat lua hook (#4387)
* Add SpawnShipCheat and convert Bravos spawning to it

* Clean-up and add canUseCheat() check

* Move some stuff to parent CustomCheat class

* Add cheat-used SEXP and On Cheat scripting hook

* Add cheat tbls and tbms, fix custom cheat detection, move cheat hooks to global hooks

* Add a default virtual destructor to CustomCheats for its derived classes to use

* Initialize buffers with memset so clang will calm down, also move cheat check a bit to keep old cheats

* Attempt to appease MSVC

* Clean-up and formatting

* Ensure custom cheats fit in the cheat code buffer

* Fix a merge mistake

* Move pre-set cheat to embedded cheats table

* Use appropriate types for stuff_string

* Remove unnecessary copying of the cheat buffer

* Explicit nullchecking

* Avoid copying values for initializing CustomCheat

* move cheat checking function to cheats_table.h, fix a typo

* Clarify OP_USED_CHEAT sexp description

* Remove unnecessary casting

* Use list initalization for Ship Cheats

* Move a few method definitions from the .h to .cpp

* Change buffer to const char*
2022-11-29 01:30:54 +09:00
Goober5000 ea93f29654 Merge pull request #4916 from Goober5000/fix_3849
guard against unknown variables
2022-11-27 22:50:34 -05:00
Goober5000 dbd1c027e8 Merge pull request #4944 from Goober5000/fix_fotg_ctd
fix crash on mission load
2022-11-27 17:10:49 -05:00
Goober5000 77fc5150c7 fix crash on mission load
Some subsystems will not have submodel instances, so make sure their velocities are not reset.  Fixes a crash in FotG.
2022-11-27 15:23:04 -05:00
Goober5000 027f109f9f Merge pull request #4929 from Goober5000/supplemental_autoscaling_fix
fix the rest of the autoscaled attributes
2022-11-27 14:37:22 -05:00
Goober5000 1b744a6ae1 Merge pull request #4932 from Goober5000/fix_event_dragging
make sexp_tree dragging more user-friendly
2022-11-27 14:37:07 -05:00
David Gibson 125e1e26bf Improved error message for missing sexp action 2022-11-27 13:28:50 -06:00
Taylor Richards 20dcdb2904 use case-insensitive comparison of cfile pathtypes (#4942)
fixes #4941
2022-11-27 13:37:32 -05:00
Taylor Richards 0be895d8bd add proper support of subfolders to lua listFiles (#4940)
Also updates function description to be more accurate and
document filter format for subfolder searches.

fixes #4939
2022-11-27 11:53:10 -05:00
BMagnu f76048b269 Enhance OnDialogX Hooks to encompass Death Popups (#4938)
* Add Scripting hooks to death popups

* Fix type

* cleanup
2022-11-27 19:01:50 +09:00
Goober5000 18150673c3 Merge pull request #4934 from Goober5000/ai_play_dead_fix
don't process turrets or subsystems when playing dead
2022-11-26 12:41:53 -05:00
BMagnu 5034855d4d Check if Texture is valid first (#4937) 2022-11-27 02:28:46 +09:00
Goober5000 1d5c802a9c handle speeds when removing play-dead 2022-11-25 12:20:45 -05:00
Goober5000 35380e8e24 don't process turrets or subsystems when playing dead
In the submodel reorganization in commit 575c050da4, subobject movement was moved out of the AI pipeline, which inadvertently removed the play-dead check that prevents subsystem movement.  This broke a few missions such as Scroll's 'Thor's Hammer'.  This PR restores the check.

Fixes #4933.
2022-11-25 11:35:13 -05:00
MjnMixael 649b513481 Modular bolts (#4880)
* better types and initialize objects with reasonable values

* modular -ltng.tbm

* fixes

* remove warning on no glow being defined

* do not error in FRED since the above code won't load the texture in FRED
2022-11-25 03:35:57 -05:00
Goober5000 cb7c760255 make sexp_tree dragging more user-friendly
FREDders expect events (and goals and campaign links) to land where you drag them.  So when dragging items earlier in the list, insert them before the item they are dropped on.
2022-11-24 20:55:18 -05:00
Goober5000 412cd8a993 Merge pull request #4931 from Goober5000/fix_warnings
fix two warnings
2022-11-24 16:43:33 -05:00
wookieejedi 1c45a18d9b Add Option to allow weapons that hit player to place per-weapon sound (#4921)
* Add Option to allow weapons that hit player to place per-weapon sound

Weapons that lasers or missiles that hit the player also play a hard coded sound, which is not ideal when trying to give valuable audio feedback to player.

This PR allows modders to stop the behavior and have the weapon class impact sound specified in the weapons table play instead of the hard coded sounds.

Tested and works as expected.

* add per class shockwave and weapon sounds

* naming update
2022-11-24 17:03:05 +00:00
MjnMixael 0af43628ad add set-order-allowed-for-target sexp (#4884) 2022-11-23 22:28:52 -05:00
Goober5000 8d8cdd9206 fix two warnings
`warning C4305: 'argument': truncation from 'double' to 'float'`
2022-11-23 22:25:51 -05:00
Goober5000 23a48ed9a8 Merge pull request #4927 from Goober5000/no_fred_weapons
add no_fred flag for weapons, and patch no_fred for ships
2022-11-23 21:43:28 -05:00
Goober5000 261e37d047 Merge pull request #4928 from Goober5000/options_tweaks
style tweaks for recently added options
2022-11-23 21:43:06 -05:00
BMagnu 67d0fb3dce Add 'Dont stop running sounds' (#4924) 2022-11-23 16:43:52 +09:00
Goober5000 c40764b65c add no_fred flag for weapons, and patch no_fred for ships
The new `no_fred` flag prevents weapons from being listed in the dropdown lists in the weapon dialog.  Also this fixes `no_fred` ships to not appear either: previously they were hidden in the main window dropdown but still appeared in the ship editor.

In order to vastly simplify the dropdown list code, the weapon dialog was refactored to use arrays of variables rather than one hardcoded variable per bank.

Implements #3643.
2022-11-22 21:30:25 -05:00
Goober5000 77be140a45 fix the rest of the autoscaled attributes
PR #4516 did not cover all of the autoscaled AI class attributes, since a few of them were labeled differently.  This adds checks to grab the correct autoscale index for the remaining cases:

```
$Afterburner Use Factor:
$Shockwave Evade Chances Per Second:
$Get Away Chance:
$Secondary Range Multiplier:
```

Fortunately, Sushi's investigation was pretty thorough.  Between these remaining cases and @EatThePath's autoscaling review, this PR should cover the complete set of autoscaling situations.

Fixes #4922.
2022-11-22 21:18:34 -05:00
Goober5000 89fb43b83d style tweaks for recently added options
1. Since Discord is both a common noun and a proper noun, capitalize it here to clarify what it refers to.
2. Capitalize the first letter of the Hotkey internal variable to follow the global variable convention.  And might as well clarify, while we're at it, that it hides hidden ships, not all ships.
2022-11-22 19:53:13 -05:00
Asteroth 13a08371cf fix an oversight from gravity changes (#4926) 2022-11-22 16:05:39 -05:00
Asteroth 732f1bdcbe Fix strange warp glow sizing (#4244)
* fix warp glow sizing

* whoops
2022-11-22 11:07:24 -05:00
EatThePath 8e560a0ba4 More old dead shader override code that isn't hooked to anything anymore. (#4861) 2022-11-22 11:06:51 -05:00
EatThePath 406c28d871 Add yaml file defining build options for vscode cmake tools users. (#4858) 2022-11-22 11:06:34 -05:00
Taylor Richards c9374ec6fb add text-to-speech support for macOS (#4914)
* add text-to-speech support for macOS

* only add Obj-C langs on mac

* move obj-c file to apple-specific block
2022-11-22 11:05:13 -05:00
Taylor Richards 072e1123d9 avoid playing voice messages with aux effects (EFX) (#4923) 2022-11-22 11:04:13 -05:00
Goober5000 e402af803b fix full ship list selection in FRED (#4919) 2022-11-21 20:15:44 -05:00
Asteroth 219bcca23a Implement gravity (#4803)
Adds gravity! Applies on a per-mission basis, and weapons, ships, debris, and asteroids now have a configurable "gravity const" which multiplies the effect of gravity on them, by default everything except debris is 0 (meaning no effect even when the mission has gravity). AI and the lead indicator will also lead for ballistic trajectories as well, given a gravity-affected weapon. No FRED support or gravity direction control yet, to come in later PRs.
2022-11-21 20:13:35 -05:00
Strygon 91eb48c5b8 Setting up Vampirism again... again (#4911)
* Setting up Vampirism again
2022-11-20 17:07:27 -05:00
MjnMixael d0fea8e14c option to always hide hidden hotkey ships (#4877) 2022-11-20 17:04:22 -05:00
John Fernandez d29ead20f6 optional feedback 2022-11-20 17:03:20 -05:00
John Fernandez 760a91376c Fix a warning
We shouldn't be checking that the `cci_h` is valid by seeing if it is greater than -1 because by that point it never will be.  Instead, we should be checking that the incoming id is valid and setting to the invalid state if it is not.
2022-11-20 17:03:20 -05:00
Goober5000 cf7919aef6 fix crash when changing ship classes in FRED (#4917)
PR #4908 had a small bug that caused a crash in FRED.  The code in question is only needed and only relevant when changing ship classes in-mission.
2022-11-20 21:56:43 +00:00
JohnAFernandez 2b6058d6f4 Adjust ssssssssssi in one more place (#4913)
* Fix crashes with sssi

We need to init in both places to avoid purging goals before ssi is set.

* Make sure we adjust for the wingp->special_ship--

Make sure we adjust sssi on ship death
2022-11-20 09:11:40 -05:00
Goober5000 7693138f56 also qtfred 2022-11-19 20:48:48 -05:00
Goober5000 d06e5ee627 guard against unknown variables
If a variable can't be found, fail gracefully instead of Asserting.  These changes will allow the mission to be saved and/or loaded, and will also allow the user to open the Event Editor and replace the nonexistent variable.  This fixes the crash/assertion failure in #3849, as well as the case where the variable is edited in the mission file.
2022-11-19 20:43:02 -05:00
Goober5000 5eddd06f44 Merge pull request #4915 from Goober5000/4878_followup
fix a copy+paste error
2022-11-19 20:23:59 -05:00
Goober5000 e62c148c53 fix a copy+paste error
This was accidentally introduced in #4878.
2022-11-19 18:54:39 -05:00
Goober5000 bfa498b378 Merge pull request #4898 from MjnMixael/force_sensor_static_sexp
hud-force-sensor-static sexp
2022-11-18 21:52:25 -05:00
Goober5000 ecb78479ce Merge pull request #4910 from MjnMixael/generate_script_name
allow getting message names in script generation
2022-11-18 21:51:55 -05:00
Goober5000 70b8a8e81e Merge pull request #4885 from Goober5000/fred_campaign_path
fix campaign loading in FRED
2022-11-18 21:49:57 -05:00
mjn-mixael 4e6ff9c355 allow getting message names in script generation 2022-11-18 11:06:34 -06:00
MjnMixael 2811e56d39 setup callsign and altname fields to use the full 31 characters allowed (#4905)
* setup callsign and altname fields to use the full 31 characters allowed

* no magic numbers
2022-11-18 10:06:09 -05:00
John Fernandez cd67d8ac6a Move the assertion.
This is just a much simpler and cleaner version of the same check.
2022-11-17 19:45:29 -05:00
MjnMixael 735b41631d ship flag to exempt it from targeting restrictions (#4878)
* ship flag to exempt it from nebula targeting restrictions

* Make this flag more generic

* address feedback
2022-11-17 07:38:37 -05:00
JohnAFernandezandGoober5000 203c5a04f6 Add special ship info index (#4908)
* Add special_ship_ship_info_index

* Change the wing's sssii if it's the wing leader

* Ignominious Lack of P

* Update code/ai/aigoals.cpp

Co-authored-by: Goober5000 <[email protected]>

* Update code/ai/aigoals.cpp

fix indentation

Co-authored-by: Goober5000 <[email protected]>
2022-11-17 05:46:13 +00:00
Goober5000 6918993994 Merge pull request #4907 from Goober5000/reanimate_textures
by default, start texture animation at the beginning of a mission
2022-11-16 23:46:53 -05:00
Goober5000 22782333c9 by default, start texture animation at the beginning of a mission
For all POFs that use animated textures, if no starting timestamp is specified, assume animation started at the beginning of the mission.  This fixes a bug reported in Starfox: Event Horizon where weapon POF animated textures stopped animating after the texture timestamp upgrade.
2022-11-16 22:50:04 -05:00
MjnMixael 727b3dc5c2 check nebula and poof bitmaps at parse time (#4895) 2022-11-16 10:47:00 -05:00
MjnMixael 76392de698 Fix overhead style (#4893)
* move initialization of overhead style

* Still need to init these colors for scpui
2022-11-16 07:37:58 -05:00
EatThePath d848adc1cf hook up cone light profile values (#4900) 2022-11-16 07:37:15 -05:00
wookieejedi 493158174a Fix Flashlights (#4902)
Area_normalisation term in deferred shader was not getting set properly for cone lights, which caused things like ship headlights to not work properly.

Tested and fixes issue as expected. Thanks to Qaz and EatThePath for pointing out how to fix it!
2022-11-16 07:36:48 -05:00
mjn-mixael 786b4b74f1 missed one 2022-11-15 21:29:04 -06:00
mjn-mixael 1f311adf13 hud init and better variable name 2022-11-15 20:20:20 -06:00
Goober5000 bd062d155e Merge pull request #4892 from MjnMixael/resize_fred_briefing
Increase default Briefing window size and allow custom setting
2022-11-15 20:53:15 -05:00
Goober5000 98a3c64cc8 fix campaign loading in FRED
Load campaigns using the full path provided by the user, not just from the configured mod paths.

Also tweaks initialization based on the campaign having already been cleared in `mission_campaign_clear()`.
2022-11-15 20:40:33 -05:00
JohnAFernandez 6255b9b154 Make sure that we check the correct instance (#4897) 2022-11-15 12:02:55 -05:00
mjn-mixael 2e42f9f215 hud-force-sensor-static sexp 2022-11-15 10:44:30 -06:00
Taylor Richards 3e57da1681 add support for subfolders to cfile (#4771)
* add subfolder support to cfile

* sort files in VP archives before indexing them

* fix indexing of sub-subfolders

* remove unused 8B22K & 16B11K sound path types

* add more items to skip subfolder scanning

* fix windows build issues

* fix unit tests by allowing 0-byte files to be indexed

* fix file indexing on windows

* add test for cfile subfolders

* remove specific 'markup' and 'css' interface subfolders

They aren't directly referenced anywhere by pathtype and the new
subfolder code will continue to index and load files from them

* add player binds to list of always-root locations

* remove file-based localization support

An alternative is left in place for old fonts, as that was the only place
it appeared to be used.

This method of file localization conflicts with subfolder support however
so if it's needed in the future then changes to the subfolder code will
be necessary.

* add subfolder support to cf_find_file_location_ext()

* add subfolder tests for cf_find_file_location*()

* add shlwapi to needed win32 libs

* small bit of cleanup

* add subfolder support to cf_get_file_list()

* add tests for cfile subfolder lists

* report files that might be shadowed

* fix issue with lists when a filter is used

Also fixes discrepancy in older cf_get_file_list() when a sub path
is specified (should be used in all cases, not just glob).

* address review suggestions
2022-11-15 08:00:13 -05:00
BMagnu f2f53b718d Actually assign enum value for constants (#4896) 2022-11-15 15:28:47 +09:00
Goober5000 dbf94acf02 Merge pull request #4881 from Goober5000/fred_swap_fix
fix swapping of things in FRED
2022-11-14 14:37:35 -05:00
JohnAFernandez 8712e69130 Merge pull request #4836 from JohnAFernandez/Fix-in-Game-Joining-Backup
Fix in game joining
2022-11-14 11:14:40 -05:00
JohnAFernandez 0d27a0f086 Enable client turrets to track targets (#4791)
* Enable clients to move turrets

This allows clients to user server data to move turrets according to the timing and target data on the server.  Uses a small packet to do so.
2022-11-14 15:58:41 +00:00
Goober5000 b9896ea611 Merge pull request #4890 from Goober5000/fix_wing_leader_check
fix wing leader check
2022-11-14 10:43:00 -05:00
John FernandezandTaylor Richards 11d571ed43 Fix a few other crash fixes that still existed
Co-Authored-By: Taylor Richards <[email protected]>
2022-11-14 10:30:28 -05:00
John FernandezandTaylor Richards 206ca742ab Further Fixes from Taylor
These fix up the in-game confirm packet and help sync client and server through a few timing fixes.

Co-Authored-By: Taylor Richards <[email protected]>
2022-11-14 10:30:28 -05:00
JohnAFernandezandBMagnu c89bc89cdc Use Lafiel's Fix
Fixes a check that object flags did not exceed ubyte size * 8.

Co-authored-by: BMagnu <[email protected]>
2022-11-14 10:30:28 -05:00
John Fernandez 4b26d38534 Fix mistake And Add lock clearing for multilock 2022-11-14 10:30:28 -05:00
John Fernandez bd79cc9a7a Buttress error reporting
fix
2022-11-14 10:30:28 -05:00
John FernandezandTaylor Richards 79c3571d2f Deny in-game Join for SW games
Because these are competitive games, we cannot allow in-game joining.

Co-Authored-By: Taylor Richards <[email protected]>
2022-11-14 10:30:28 -05:00
John Fernandez 2365174b55 Use tabs here 2022-11-14 10:30:28 -05:00
John Fernandezandwookieejedi 32b1e563bb Fix from Wookie for Joining more than once
Make sure that in game joiners adjust their time more than once.

Co-Authored-By: wookieejedi <[email protected]>
2022-11-14 10:30:28 -05:00
John Fernandez f8de460b75 Fix ships not moving
Revert "Fix ships not moving"

This reverts commit e989ad440009a20c1d0b1957ff0f10cc856d8fea.

Update multi_ingame.cpp
2022-11-14 10:30:28 -05:00
John Fernandez ba665bfc9d Attempt to adjust timing for in-game joiners
This allows in game joiners to avoid interpolation and physics bugs by using the first incoming timing from the server as its local missiontime.
2022-11-14 10:30:28 -05:00
JohnAFernandez 4e8203a066 Patch in-game joining crashes
Patches multiple things about in-game joining to allow it to be enabled by default.
2022-11-14 10:30:27 -05:00
BMagnu bd2c50aa1d Refactor Lua Enums (#4867)
* Refactor bitfield enums

* Add default case for lua switch

* Add default case for more lua switches

* Fix Warnings

* constexpr
2022-11-14 17:31:50 +09:00
JohnAFernandezandTaylor Richards d50a599934 Taylor's in-game fixes
Co-Authored-By: Taylor Richards <[email protected]>
2022-11-13 20:32:42 -05:00
Goober5000 9d898cb585 Merge pull request #4891 from Goober5000/cannot_perform_scan_flag
add cannot-perform-scan flag
2022-11-13 18:41:59 -05:00
Goober5000 b6d3065876 Merge pull request #4888 from Goober5000/fix_animated_textures
use correct math for animated textures
2022-11-13 16:14:01 -05:00
Goober5000 b2f5ea9065 Merge pull request #4764 from MjnMixael/3d_select_settings
3d select settings
2022-11-13 16:13:17 -05:00
mjn-mixael 495872e8fa ordering 2022-11-13 15:08:39 -06:00
MjnMixael 760cc543b7 replace keybinds in debriefing (#4876) 2022-11-13 16:05:14 -05:00
mjn-mixael abec56ee05 use a single variable array 2022-11-13 14:46:53 -06:00
mjn-mixael bab0752af2 increase default window size and allow custom setting 2022-11-13 10:31:16 -06:00
Goober5000 320ebd4762 add cannot-perform-scan flag
Prevents the player from performing a cargo or subsystem scan.  Can be toggled using alter-ship-flag.
2022-11-13 00:37:56 -05:00
Goober5000 48cd9b2989 fix wing leader check
The `special ship` field stores the index in the wing's `ship_index` array.  It does not store the shipnum itself.
2022-11-12 18:43:41 -05:00
Goober5000 e22112e0a9 use correct math for animated textures
Fixes #4887.  Follow-up to #4704.
2022-11-12 14:11:11 -05:00
Asteroth e85fabf671 bugfix arg order (#4882) 2022-11-11 23:06:42 -05:00
Goober5000 51f50132d2 Merge pull request #4886 from MageKing17/bugfix/make-sound-environment-sexp-errors-recoverable
Make sound environment SEXP errors recoverable.
2022-11-11 23:00:21 -05:00
MageKing17 6ef8028794 Make sound environment SEXP errors recoverable.
Adds `SEXP_CHECK_INVALID_SOUND_ENVIRONMENT` and `SEXP_CHECK_INVALID_SOUND_ENVIRONMENT_OPTION` to `sexp_recoverable_error()`. Neither causes a fatal problem, and the former can be spuriously triggered if EFX is disabled.
2022-11-11 16:40:01 -08:00
MjnMixael b5328a81c2 increase object limits (#4849) 2022-11-11 12:54:54 -05:00
EatThePath 63a0c9bdb9 Merge pull request #4883 from Goober5000/ai_profiles_bump
bump MAX_AI_PROFILES
2022-11-11 11:03:29 -06:00
Goober5000 2b3c533d09 bump MAX_AI_PROFILES
Previous limit lasted from 2005-11-21 until now (from commit b33caf6f45).  We'll see how long this one lasts.
2022-11-11 00:41:14 -05:00
Goober5000 351aed432f Merge pull request #4866 from Goober5000/formation_enhancements
add wing formation align button
2022-11-10 22:13:28 -05:00
MjnMixael 3367b5739f Fix poof name parsing and fix lab not knowing about the new parsing (#4879)
* Fix poof name parsing and fix lab not knowing about the new parsing

* address feedback
2022-11-10 21:40:26 -05:00
Goober5000 bd50aadf5c fix swapping of things in FRED
This properly updates event and goal signatures when events are moved around.  Fixes Mantis bugs 1005, 1961, and 2998.
2022-11-10 15:47:20 -05:00
mjn-mixael 3e87c3f54e not needed 2022-11-09 10:12:31 -06:00
mjn-mixael 35e6bc9df0 setup overhead style as a type enum 2022-11-09 09:16:57 -06:00
Goober5000 8ddbad645b Merge pull request #4874 from Goober5000/fix_path_masks
use correct path masks for parse objects
2022-11-08 23:48:00 -05:00
Goober5000 1736c9b230 use correct path masks for parse objects
Parse objects have their path masks temporarily set to -1 during parsing, since at that point the mask represents an index, not a bitfield.  In all other cases, the path mask defaults to 0.

Fixes #4873.
2022-11-08 23:14:10 -05:00
Goober5000 0b2dc58d5a add formation scale 2022-11-08 22:52:38 -05:00
Goober5000 94358c20e9 add wing formation align button
This button allows wings to be arranged in their formation so that they don't scramble around when they arrive.
2022-11-08 22:48:31 -05:00
Goober5000 2fba619a67 Merge pull request #4865 from Goober5000/clean_up_old_fields
clean up some obsolete fields
2022-11-08 22:37:53 -05:00
Goober5000 2984f21999 Merge pull request #4872 from Goober5000/init_ship_for_lab
fix lab CTD
2022-11-08 17:26:45 -05:00
Goober5000 f823a8dc62 fix lab CTD 2022-11-08 15:19:09 -05:00
MjnMixael 415924bbbd Fix num comparison for FS2 medals (#4869)
* Fix num comparison for FS2 medals

* works better if you get the proper position
2022-11-08 14:42:22 -05:00
Goober5000 e8fdfa5513 clean up some obsolete fields
Remove `behavior`, `type`, and `wing`, which are either unused or redundant.
2022-11-07 22:43:50 -05:00
Goober5000 0721792b93 Merge pull request #4856 from Goober5000/clear_mission_refactor
refactor mission initialization
2022-11-07 21:46:56 -05:00
Goober5000 5ab63a8ec9 use the clear-wing function when creating a wing in fred 2022-11-07 20:41:54 -05:00
Goober5000 21751a8a58 Merge pull request #4863 from Goober5000/lua_is_docked
add numDocked and isDocked
2022-11-07 20:29:26 -05:00
Goober5000 d43be3eba4 Merge pull request #4868 from Goober5000/decal_parse_fix
fix decal debug warnings in FRED
2022-11-07 14:23:03 -05:00
Goober5000 e64d6a062e fix decal debug warnings in FRED
Prevent warnings from being displayed due to decals not being loaded.
2022-11-07 11:19:00 -05:00
EatThePath f3601d8178 Merge pull request #4826 from MjnMixael/optional_discord_presence
Optional discord presence
2022-11-07 08:59:30 -06:00
MjnMixael 1ba0b8dcbe Modular medals (#4851)
* Modular medals table

* Remove Num_medals completely

* Handle badges out of order and allow setting of masks to handle mask indecies out of order

* const const const

* qtFRED

* address feedback
2022-11-07 22:53:28 +09:00
MjnMixael 26269e10bf toggle-asteroid-field sexp (#4857) 2022-11-07 22:52:52 +09:00
MjnMixael 6e1b194c38 Modular iff table (#4845)
* split up init, parsing, and data resolution

* modular iff table

* address feedback
2022-11-07 22:52:44 +09:00
Goober5000 7c26c19671 add numDocked and isDocked
Two useful script functions.
2022-11-06 16:19:45 -05:00
Goober5000 4ace4f6d5a nebula fix 2022-11-06 11:27:18 -05:00
Goober5000 1ec38ff71a parse object stuff 2022-11-06 11:27:18 -05:00
Goober5000 b48d2faa80 wing stuff 2022-11-06 11:27:18 -05:00
Goober5000 00acefea86 some fixes 2022-11-06 11:27:18 -05:00
Goober5000 cce4be4bfb refactor mission initialization
Gather all the mission initialization code into a common function for clarity and ease of expansion.  Previously, the various parsing routines contained initialization as well as parsing.  As a bonus, quite a few redundant initializations are streamlined.
2022-11-06 11:27:18 -05:00
Goober5000 f873a6fc99 Merge pull request #4862 from Goober5000/check_sexp_syntax_fix
improve SEXP syntax checking
2022-11-06 11:25:39 -05:00
Asteroth 2777e45a95 Add isMultipart and getModelFlag functions on subsystems (#4846)
* add `getModelFlag` function

* add ismultipartturret function

* fix

* fix link
2022-11-06 23:59:54 +09:00
Asteroth 924013b521 add burst shots and delay to scripts (#4847) 2022-11-06 23:59:34 +09:00
Goober5000 b44f9f6125 improve SEXP syntax checking
When the top-level operator of a SEXP is not found, flag the error instead of crashing.  This is helpful for missions that contain unsupported scripted SEXPs.

Also be sure to set the bad node in the event of a NONOP_ARGS syntax error.
2022-11-06 05:09:40 -05:00
EatThePath aef869aa2a Merge pull request #4859 from EatThePath/fix-loadout-flicker
always set the default gloss uniform since it is now always used
2022-11-05 14:07:05 -05:00
Asteroth 18d3c01576 Allow overriding gvec in fireWeapon on subsystems (#4852)
* allow for overriding of gvec

* update docs

* fix docs
2022-11-05 14:13:01 -04:00
David Gibson 830fed0bdc always set the default gloss uniform since it is now always used. Fixes flickering issue 2022-11-05 11:16:51 -05:00
MjnMixael bff3d433e2 properly get badge name (#4853) 2022-11-05 10:01:44 -04:00
Asteroth f5fe1c5d65 small fix for turret fire pos in beam-fire (#4848) 2022-11-04 19:16:40 -04:00
EatThePath e371032e5e Merge pull request #4850 from qazwsxal/shader_geom_fix
Minor lighting shader fixes
2022-11-03 22:58:01 -05:00
JohnAFernandez 595d63c001 Merge pull request #4841 from JohnAFernandez/Add-check-to-Escort-list-in-multi
Make sure that the escort list only lists valid targets on multi
2022-11-03 12:24:43 -04:00
EatThePath 06fc2c81f9 Shader/Material cleanup pass (#4838)
* Ripping out the gloss override code because it's vestigial

* Remove redundant teammask declaration.

* The NORMAL_ALPHA shader feature appears both useless and unusable.
Consequently, I'm removing it.
2022-11-02 17:19:54 -04:00
Adam Leach 8ec89751bb Use the correct k value for geometry term. Actually use area_norm 2022-11-02 16:32:54 +00:00
BMagnu d85c1431a4 libRocket Texture Passthrough (#4822)
* Properly handle lua texture refcounting

* Add linkTexture ui method

* Incorporate feedback
2022-11-02 18:25:22 +09:00
MjnMixael bd151095b3 implement modular nebula.tbl (#4834)
* implement modular nebula.tbl

* Address feedback and skip > 32 poofs

* read/write nebula poofs by name

* qtfred changes

* variable name

* log -> warning

* nullptr and make sure to only set bitmap_name when it's actually defined
2022-11-02 18:25:13 +09:00
Goober5000 7e8e28e6e8 Merge pull request #4844 from Goober5000/timestamp_compare_fix
fix timestamp_in_between functions
2022-11-01 14:33:58 -04:00
MjnMixael e6ef239ae6 Modular tips (#4843)
* vectorize tips

* make tips.tbl extendable with -tip.tbm
2022-11-01 21:46:22 +09:00
Goober5000 5f54188e5b add a few scripting dock functions (#4839)
* add a few scripting dock functions

Add setDocked, setUndocked, and jettison.

* address feedback
2022-11-01 21:45:49 +09:00
Asteroth a29378d245 Clearable Ship/Subsystem Targets via script (#4842)
* make sure Targets can be cleared with `nil`

* move `set_targeted_subsys` calls
2022-11-01 21:43:26 +09:00
MjnMixael 346817f3d0 Further limit what built-in UI elements can be setup when using SCPUI (#4824)
* Further limit what built-in UI elements can be setup when using SCPUI

* remove superfluous declaration
2022-11-01 21:43:14 +09:00
MjnMixael f0ecf8c2aa allow borrowing flyby sounds from a previously parsed species (#4828) 2022-11-01 21:43:01 +09:00
Goober5000 a86074e3cd fix timestamp_in_between functions
Fix the comparison and add documentation to the compare functions.
2022-11-01 01:10:59 -04:00
MjnMixael 0b9f0f25c9 Dont add whitespace for no_fred ships in the main list (#4833)
* Dont add whitespace for no_fred ships in the main list

* whitespace and better variable name

* fix comparisons
2022-10-31 18:45:21 +09:00
Asteroth 7d800e48ae Add $On Camera Set Up hook (#4832)
* add on camera set up hook

* typo
2022-10-31 03:28:48 -04:00
John Fernandez a00a7a7f26 Make sure that the escort list
Only lists valid targets on multi
2022-10-30 20:52:30 -04:00
Goober5000 874e22b8e1 Merge pull request #4831 from Goober5000/new_autoscale
take non-autoscaling AI classes into account when autoscaling
2022-10-30 00:05:34 -04:00
JohnAFernandez 18c1abb14f Merge pull request #4825 from MjnMixael/full_int3_fix
remove misplaced int3() and allow the game to continue with -1
2022-10-29 16:30:27 -04:00
JohnAFernandez 6cd217589b Merge pull request #4490 from JohnAFernandez/fix-traitors-multilocking-each-other
Allow multilock between traitors
2022-10-29 16:16:08 -04:00
Goober5000 0e477367ef Merge pull request #4827 from Goober5000/asteroid_target_init
asteroid field fix/refactor
2022-10-27 19:54:20 -04:00
BMagnu 8a3a99ccbd UI Popup Scripting Hook (#4806)
* Add Popup Init Hook

* Finish popup hooks

* Fix warnings

* Fix fallthrough

* feedback
2022-10-27 16:23:23 +09:00
MjnMixael 291f4f68ea Allow adding custom head anis to the list in FRED (#4818) 2022-10-27 16:22:49 +09:00
EatThePath 7a9a33d16c These old vars did something once, but not anymore (#4823) 2022-10-27 16:22:36 +09:00
Goober5000 1b0dd83c27 type safety 2022-10-26 21:07:44 -04:00
Goober5000 b42831b981 take non-autoscaling AI classes into account when autoscaling
This adds an AI profiles flag that filters autoscaling so that only the index and number of autoscaled classes are considered, not the index and number of all AI classes.

Fixes #4516.
2022-10-26 21:02:59 -04:00
Goober5000 e8bbb97f96 add clarifying comment 2022-10-26 20:42:03 -04:00
Goober5000 0a9032fc03 asteroid field fix/refactor
Some refactoring with asteroid fields:
1. Moves asteroid throwing targets into the Asteroid_field struct, in anticipation of potentially multiple fields in the future
2. Moves some initialization code into `asteroid_level_init`
3. Calls `asteroid_level_init` when a mission is cleared
4. Loads asteroid targets as part of the asteroid field update/init logic.  This fixes a FRED bug reported in Discord where asteroid targets stay in the dialog when a new mission is loaded
5. Remove `Default_asteroid_throwing_behavior` flag as it is equivalent to checking that the target list is empty
2022-10-26 19:16:08 -04:00
mjn-mixael 8bc5723d43 create mod.tbl and built-in option to enable or disable discord presence 2022-10-26 14:13:53 -05:00
mjn-mixael 37022fa5c2 Setup discord presence to be able to be toggled 2022-10-26 14:12:58 -05:00
mjn-mixael f4f223908c remove misplaced int3() and allow the game to continue with a value of -1 2022-10-26 10:13:48 -05:00
Goober5000 f07c4481ff Merge pull request #4820 from Goober5000/lua_type_check_cleanup
clean up stack when checking type
2022-10-25 09:43:34 -04:00
Goober5000 e6b9ff7361 Merge pull request #4704 from Goober5000/texture_timestamp
upgrade texture animation code to use new timestamps
2022-10-24 23:49:42 -04:00
MjnMixael b3c900803e translate key tokens in tips (#4808) 2022-10-24 16:51:08 -04:00
Goober5000 fdbdcec2b1 clean up stack when checking type
The `ade_odata_is_userdata_type` function didn't clean up its stack properly, as it left type information there for error reporting.  But there are other reasons to check userdata types besides error reporting, so this adds a flag to clean up in most situations.

Fix courtesy of @BMagnu.
2022-10-24 11:09:52 -04:00
MjnMixael 9d122616dd Update credits (#4799)
* add self and naomi to SCP credits

* Add EatThePath, Kiloku, and Lafiel as well
2022-10-24 10:36:32 -04:00
EatThePath f8e99e6012 Actually dynamically populate the empty debug filter files (#4817)
* Actually dynamically populate the default debug filters properly for empty files, rather than just enable everything.

* whitespace shuffle
2022-10-24 18:37:11 +09:00
BMagnu 2116d1fe66 Modular POF Features (#4713)
* Add turret copying

* Ad addturret parsing

* Fix gun_nr error

* Fix strncpy_s

* Fix strings better

* Cleanup submodel / turret copying

* Add 'Add Engine'

* Add Glowpoints, add Special Subsys

* Remember to keep the glowpoint texture

* Fix unused param
2022-10-24 18:35:51 +09:00
Goober5000 1cc027666e Merge pull request #4814 from Goober5000/fix_debris_crash
handle debris model instances correctly when shadows are enabled
2022-10-23 15:04:17 -04:00
Goober5000 fde3589d1d handle debris model instances correctly when shadows are enabled
Fixes #4813.
2022-10-23 14:13:08 -04:00
BMagnu 2080824a20 Can has high rez plz k thx bye (#4805) 2022-10-22 18:47:58 +09:00
Goober5000 11b37bbeae Merge pull request #4787 from Goober5000/createdebris
create debris using script functions
2022-10-21 23:24:47 -04:00
Goober5000 41074956a8 more fixes 2022-10-21 12:01:25 -04:00
MjnMixael c63ce5de8c Allow writing to player mission specific stats (#4801)
* Allow writing to player mission specific stats

* Documentation

* return false
2022-10-21 20:25:35 +09:00
MjnMixael 17e42e92cf cockpitinactive gauges should render in chase view (#4804)
* cockpitinactive gauges should render in chase view

* Simplify
2022-10-21 20:25:24 +09:00
Goober5000 debedf26ef partial fix 2022-10-20 23:32:30 -04:00
MjnMixael 90c4316a5e Update scpui documentation (#4802)
* Update documentation

* Typo
2022-10-20 19:13:03 +09:00
Goober5000 9782f191b9 Merge pull request #4789 from Goober5000/timestamps_3
music and training message timestamp conversion
2022-10-19 20:02:47 -04:00
Goober5000 49fb2f07c0 refactor per feedback, tweak to fix circular #include, use accessor, reorder, fix namespaces, fix API documentation 2022-10-19 14:44:57 -04:00
Goober5000 f24277c39e make clang happy 2022-10-19 14:22:10 -04:00
Goober5000 452c8370dc model instances are not needed for debris in many cases 2022-10-19 14:22:10 -04:00
Goober5000 77179dc183 add mn.createDebris
This is a new Lua API function that allows creation of arbitrary debris pieces, whether chunks of a ship's hull or shards of shrapnel.  All of the parameters are optional, and a wide variety of situations are possible ranging from vaporized bits to static chunks to chunks propelled by an explosion.
2022-10-19 14:22:10 -04:00
Goober5000 d37a446894 music and training message timestamp conversion 2022-10-19 14:11:23 -04:00
MjnMixael 7a5b840338 Allow setting an override wireframe color globally and add option to set target monitor style and wireframe color per gauge (#4786) 2022-10-19 21:51:35 +09:00
MjnMixael 50cd91bd86 Damage, swarm, corkscrew info virtvars (#4798)
* Add access to damage type, swarm, and corkscrew data

* Also return if the weapons have the appropriate flags

* Return nil for invalid handle and clarify documentation
2022-10-19 21:51:22 +09:00
MjnMixael 00c8b946a4 Modular species table (#4775)
* Add modular ability to add intel entries

* Allow for +nocreate in modular tables

* Allow intel.tbl as an alias of species.tbl

* Additional error checking and remove tests that are no longer required

* const
2022-10-19 21:51:15 +09:00
Asteroth 4c6f043274 Add a bunch of movement stats to ship class script api (#4797)
* add a bunch of script physics values

* fix

* small doc fix (its just called "damp" barely worth mentioning)
2022-10-18 20:54:30 -04:00
MjnMixael 307c770c58 Enable hud rearm timer in hud_gauges.tbl (#4777)
* Enable hud rearm timer in hud_gauges.tbl

* Comment
2022-10-18 22:21:51 +09:00
JohnAFernandez bd0e6bb990 Add an update interval for client update packets (#4796) 2022-10-18 21:54:16 +09:00
MjnMixael 0a6729b03d enable target info in hud_gauges.tbl (#4778)
* enable target info in hud_gauges.tbl

* Comment
2022-10-18 17:08:44 +09:00
Fabian Woltermann 9e56ba43a5 Merge pull request #4783 from MjnMixael/render_no_lighting
Allow option to choose to render with no lighting
2022-10-17 19:30:40 +02:00
Fabian Woltermann f76e110c87 Merge pull request #4795 from The-E/fix/4794_bump_max_instance_depth
Bump the MAX_INSTANCE_DEPTH constant to 32
2022-10-17 19:30:08 +02:00
Fabian Woltermann a8328a8ee7 bumps the MAX_INSTANCE_DEPTH constant to 32.
This bump should be sufficient to cover complex animation states. This fixes #4794
2022-10-17 18:59:51 +02:00
mjn-mixael 6464900fa1 Fully deprecate -ship_choice_3d and -weapon_choice_3d 2022-10-17 09:58:48 -05:00
mjn-mixael 64bd233c49 API to access the new 3d select settings in game_settings.tbl 2022-10-17 09:58:15 -05:00
mjn-mixael 2d4d886a6a Add Game Settings options for 3d ship and weapon select 2022-10-17 09:58:15 -05:00
mjn-mixael 32b059ae07 fix documentation 2022-10-17 08:09:26 -05:00
mjn-mixael 1af0a1082b int to bool 2022-10-17 08:04:02 -05:00
Goober5000 f34294cf95 Merge pull request #4788 from Goober5000/force_arrival_for_reinforcements
fix makeShipArrive and makeWingArrive for reinforcements
2022-10-17 01:16:56 -04:00
wookieejedi 5d60e56614 Update $POF file Techroom: Usage (#4785)
* Update `$POF file Techroom:` Usage

Currently `$POF file Techroom:` is only used in the weapons loadout screen (despite having techroom in the name). This PR expands the use of the `$POF file Techroom:` to shiploadout select and the actual techroom.

If it is desired I can put it behind a game settings flag, but IMO it would make the most sense for modders to have this just work as the actual name implies.

* clean up code with feedback

* typo fix in comment
2022-10-15 21:12:19 -04:00
wookieejedi 4d581e92e8 1 Line fix for player view render check (#4790)
Fix for recent updates to cockpit rendering check, which was false if the player was the only ship in a mission. `instance >0` was used but it is supposed to be `instance >= 0` (The object index is valid if larger or equal to 0, while the signature is only valid equal or larger to 1.) Tested and fix works as expected.
2022-10-15 21:59:14 +00:00
Goober5000 3d515ddfb7 upgrade texture animation code to use new timestamps
Timestamp changes for texture animation, both on ships and on the skybox.
2022-10-15 12:24:05 -04:00
Goober5000 9161601cac Merge pull request #4780 from Goober5000/alter_ship_flag_listing
prevent duplicate flag names in the alter-ship-flag list
2022-10-15 11:53:29 -04:00
MjnMixael 09a307b17d Virtvar to access the energy a weapon consumes (#4784)
* Virtvar to access the energy a weapon consumes

* quick fix
2022-10-15 09:54:44 -04:00
Goober5000 848d133fe3 Merge pull request #4767 from Goober5000/enhanced_print
enhance ba.print and add ba.println
2022-10-14 21:40:11 -04:00
Goober5000 8f8a6ca527 warning tweak 2022-10-14 21:08:47 -04:00
Goober5000 a2af63726e fix makeShipArrive and makeWingArrive for reinforcements
The script functions should make the ships/wings arrive even if they are reinforcement, so this PR fixes that.  Also, this PR adds some additional verification of the `num_uses` of reinforcements, especially when the player calls for a wing that is already present but has more uses remaining.
2022-10-14 20:44:39 -04:00
JohnAFernandez 8ea13a2b49 Merge pull request #4773 from MjnMixael/fix_target_team_colors
apply team colors to all target view styles
2022-10-14 15:25:23 -04:00
Goober5000 b67ae48590 Merge pull request #4782 from Goober5000/submodel_indexer_fix
model.Submodels fix
2022-10-14 14:04:12 -04:00
MjnMixael 3dcfa99c4a add warp flash to ingame options (#4776) 2022-10-14 10:04:59 -04:00
mjn-mixael 7a5a54d009 Allow option to choose to render with no lighting 2022-10-14 09:00:35 -05:00
Goober5000 da7228cedb model.Submodels fix
Guard against the indexer being invalid, e.g. if the model isn't loaded yet.
2022-10-14 02:07:35 -04:00
Goober5000 aa7a57ef4e Merge pull request #4781 from Goober5000/collision_fix
collision fix
2022-10-14 01:01:09 -04:00
Goober5000 c300278328 collision fix
Fix a typo in `collide_ship_ship`.  Also tweak some lines for clarity.
2022-10-14 00:28:44 -04:00
Goober5000 8b3dccce1c prevent duplicate flag names in the alter-ship-flag list 2022-10-13 15:35:50 -04:00
MjnMixael d323421817 Use a local int for model storage in renderTechModel (#4779)
* Use a local int for model storage here

* null -> nullptr
2022-10-13 17:06:03 +00:00
MjnMixael 7ab80a0162 Toggle cockpit (#4772)
* proof of concept

* Account for shadows

* Option to tie individual HUD gauges to the cockpit option

* Do this in a more user-friendly way

* Address feedback
2022-10-13 19:42:00 +09:00
Goober5000 d1b16d5269 Merge pull request #4762 from Goober5000/flag_list_cleanup
remove obsolete field
2022-10-13 02:02:08 -04:00
Goober5000 446b50cbaf Merge pull request #4774 from Goober5000/fix_ui_timestamp_check
fix updating of ui_timestamps
2022-10-11 20:02:22 -04:00
Goober5000 187cd35e74 add additional comments 2022-10-11 19:28:02 -04:00
Goober5000 e95d214143 Merge pull request #4756 from Goober5000/ship_entry_and_related
Add Lua API for ship registry
2022-10-11 19:24:54 -04:00
MjnMixael 6ae8674615 Correctly set credits default even for scpui access (#4768)
* Correctly set credits default even for scpui access

* These also need to move up for the same reason

* Match retail functionality
2022-10-11 16:47:10 +09:00
Goober5000 7c01485d2d fix updating of ui_timestamps
Since the debug pause check needs to use UI timestamps, and since UI timestamps must keep track of time regardless of time compression, pausing, or mission status, move the updating and checking to `game_do_state_common`.

Also fix a type conversion warning.
2022-10-11 01:06:33 -04:00
Goober5000 3850acdd23 documentation updates 2022-10-10 22:45:14 -04:00
mjn-mixael e3424b4350 apply team colors to all target view styles 2022-10-10 12:56:04 -05:00
Goober5000 f10e35e8dd Merge pull request #4769 from Goober5000/credits_get_music
get the credits music without starting it
2022-10-10 09:43:24 -04:00
MjnMixael bc6282b34b These were reversed (#4770) 2022-10-10 17:48:47 +09:00
Goober5000 d8ad8ebc77 get the credits music without starting it
Starting the music should happen in `credits_init`, not whenever someone needs to know the file name.
2022-10-09 15:41:54 -04:00
Goober5000 ab83a94eb4 remove obsolete field
The `flag_list` field is left over from before the type-safe refactor.  It was used to specify either the `flags` or `flags2` bitfield.
2022-10-07 13:24:52 -04:00
Goober5000 663474516f Merge pull request #4752 from Goober5000/arrival_departure_info
add arrival and departure info for wings, ships, and parse objects
2022-10-07 12:26:59 -04:00
wookieejedi 0dfed6de4b Add maximum self repair percentages for health and subsystems (#4761)
* Add maximum self repair percentages for health and subsystems

Adds two new options to help with the automatic self repairs for hull and subsystems: `$Hull Self Repair Maximum:` and `$Subsystem Self Repair Maximum:`. These values allow mods to specify how much a ship's hull or subsystem can self repair to, which is very useful to have some auto repair but not enough to make the hull or subsystem 100%.

Also cleans up the `ship_auto_repair_frame` function with removing un-used define values, improving comments, and making formatting consistent. Also updates the parse sections of repair rate for hull and subsystems to print to the log if values are being clamped.

Probably easiest to review with hiding whitespace changes.

* update local names to be easier matches to surrounding code

* incorporate feedback

Add back in define, fix == 0 checks, and fix edge case logic bugs
2022-10-07 12:05:23 -04:00
Goober5000 d73ac59383 enhance ba.print and add ba.println
There was code that could interpret any Lua type as an argument for printing, so I adapted it to be used in ba.print(), ba.warning(), and ba.error().  Also ba.println() seemed like a useful thing to add.
2022-10-06 22:52:58 -04:00
Goober5000 a47b2440d3 add ship registry 2022-10-06 20:43:09 -04:00
Goober5000 7d6f261221 add getWing() to parse_object 2022-10-06 20:43:09 -04:00
Goober5000 473521f5ed Merge pull request #4759 from Goober5000/wing_flags
add wing flags
2022-10-06 18:58:00 -04:00
Goober5000 f1f234b89d Merge pull request #4702 from EatThePath/debug-log-cleanup
Moved more things to debug filters, and associated cleanup
2022-10-06 16:57:27 -04:00
MjnMixael 00d067be47 Fix one missed resize mode (#4765) 2022-10-06 15:53:30 -04:00
David Gibson 2ba9a03d9a Restored submodel detail level message 2022-10-05 20:37:33 -05:00
Goober5000 14929db6fe address feedback and add sexps 2022-10-05 18:00:16 -04:00
Goober5000 6ce8963e13 Merge pull request #4757 from Goober5000/animated_effects_to_timestamp
make animated ship effects use the new timestamps
2022-10-05 16:39:08 -04:00
Goober5000 364741ef8f additional flag error checking 2022-10-05 11:40:54 -04:00
BMagnu 209cb7cba8 Enable PNG blobs in LibRocket (#4754)
* Allow reading PNGs from b64, including in librocket

* fix memleak

* tidyup

* fix bad delete

* Force flush on png write

* Pass more image size
2022-10-05 16:57:09 +09:00
Goober5000 02aed5fde4 Merge pull request #4760 from Goober5000/removeSoundByIndex_fix
removeSoundByIndex should be 1-based
2022-10-05 00:12:31 -04:00
Goober5000 8694c042f7 add wing flags
Add setFlag and getFlag for wings, just like for ships and parse objects
2022-10-04 23:59:30 -04:00
Goober5000 3f86fbc7ad removeSoundByIndex should be 1-based
Looks like no mods use this script method, so this change should be safe.
2022-10-04 23:40:10 -04:00
Goober5000 fded868f8c Merge pull request #4758 from Goober5000/4751_followup
fix a last-minute error check
2022-10-04 23:25:26 -04:00
Taylor Richards f1a7a98639 fix and clean up cf_create_default_path_string(): (#4747)
- consolidate old and new functions
 - add missing location flags override from earlier fix
 - add proper error handling where needed
2022-10-04 23:18:28 -04:00
Goober5000 ec8354957d fix a last-minute error check 2022-10-04 22:49:44 -04:00
Goober5000 afeca7cc8f add the same for ships and parse objects 2022-10-04 21:45:56 -04:00
Goober5000 f0542553d6 make animated ship effects use the new timestamps
In addition to type-safety, this now adjusts ship effects properly for time compression and pausing.
2022-10-04 21:42:47 -04:00
Goober5000 cfefaef385 add arrival and departure info for wings
Virtual variables corresponding to the same fields as in `set-arrival-info` and `set-departure-info`.  Plus more variables.  Some refactoring as well.
2022-10-04 20:59:52 -04:00
Goober5000 90638ce534 Merge pull request #4751 from Goober5000/ship_arrival_script_functions
Ship/Wing arrival script functions
2022-10-04 20:56:30 -04:00
MjnMixael 36b0fa046b Move rendering of the 3d overhead to it's own method and create an api (#4749)
* Move rendering of the overhead model to it's own method and create an API to call it.

* fix typos
2022-10-05 02:52:38 +09:00
Goober5000 c1d687f560 prevent redundant arrivals and return whether ships were created 2022-10-03 19:41:26 -04:00
Goober5000 94f99c35f9 remove obsolete fields 2022-10-03 19:36:27 -04:00
Goober5000 61ceeff893 and also for wings 2022-10-03 19:36:27 -04:00
Goober5000 ae3bbd2959 make a parse object arrive 2022-10-03 19:36:27 -04:00
Goober5000 0702a38e1c Merge pull request #4750 from Goober5000/lua_mission_music_scores
add getMusicScore and setMusicScore
2022-10-03 19:09:56 -04:00
Goober5000 064d3a7549 add getMusicScore and setMusicScore
Two new Lua API methods, plus some minor refactoring.
2022-10-03 17:14:33 -04:00
EatThePath e32e01eb50 Added an API function to allow clearing the log during play. (#4741)
* Added an API function to allow clearing the log during play.

* document test fix maybe

* return something
2022-10-04 04:17:53 +09:00
Goober5000 c661ae4590 Merge pull request #4703 from Goober5000/control_used_upgrade
upgrade controls code to use type-safe timestamps
2022-10-02 21:02:32 -04:00
Goober5000 7a654b7e7b per feedback 2022-10-02 20:13:19 -04:00
MjnMixael d902c7612b Api to render the 3d selection effect (#4737)
* Api to render the 3d selection effect

* Missing include

* documentation

* error message for effect type

* documentation
2022-10-03 08:25:15 +09:00
BMagnu 979d305afe Add screenToBlob scripting function (#4738)
* extract base64 routines

* Add screenToBlob scripting method

* Fix variable shadow

* Fix variable shadow again

* Fix usused variable
2022-10-03 07:33:46 +09:00
Goober5000 f14acf9fc1 Merge pull request #4744 from Goober5000/lua_cap_waypoint_speed
add WaypointSpeedCap
2022-10-02 16:54:52 -04:00
JohnAFernandez c2895ba8a4 Fix subsystem health and comparison frames (#4666)
* Fix subsystem change handling code

Make sure that subsystem help actually gets updated.

* change from pointer to literal

I had decided to use `new` in the past when I was less experienced.  So this changes it back to regular angle variables.

(And White space fix requested by Wookie)
2022-10-02 16:52:36 +00:00
MjnMixael 419c56d012 check if weapon is required by current mission (#4731) 2022-10-02 20:23:36 +09:00
MjnMixael e30931b6d2 API to save the current loadout to the player file (#4739)
* API to save the current loadout to the player file

* cleanup
2022-10-02 20:23:31 +09:00
Goober5000 20653ece8e add WaypointSpeedCap
As requested by FotG
2022-10-02 00:13:50 -04:00
Fabian Woltermann 77476edd73 Merge pull request #4735 from The-E/fix/lua_rendering_outside_of_objectrender
When rendering stuff outside of ON OBJECT RENDER hooks, use immediate mode
2022-10-01 22:06:37 +02:00
Fabian WoltermannandGoober5000 e69f2b3fec Update code/scripting/api/libs/graphics.cpp
Co-authored-by: Goober5000 <[email protected]>
2022-10-01 21:39:08 +02:00
wookieejedi 1e61964055 Add AI flag to support ai bay arrivals > 10 seconds (#4733)
* Add AI flag to support ai bay arrivals > 10 seconds

Currently, if an AI ship is emerging from a bay path, the AI will stop following that path after only 10 seconds (and some distance away from the starting point). This results in AI breaking off a path early if a bay arrival path is long and/or uses a slow bay arrive multipliers. For bays that require the ship to follow the exact path this results in AI that then run into the parent ship and each other.

This PR adds a flag which disables that 10 second timeout. Also, in my tests having a flag to disable works best, as opposed to setting a max time (which is hard to calculate with varying ship speeds and varying bay path lengths).

PR is tested and works as expected.

* fix spelling
2022-10-01 12:39:17 -04:00
MjnMixael f5c83fbb40 primary -> secondary (#4740) 2022-10-01 08:44:55 -04:00
MjnMixael 7819d8262d Only check for greater than, not equal to (#4734) 2022-10-01 08:43:20 -04:00
MjnMixael 1edf63c617 take userdata and return int (#4736) 2022-10-01 08:43:13 -04:00
Fabian Woltermann b2ab98a979 When rendering stuff outside of ON OBJECT RENDER hooks, use immediate mode 2022-10-01 10:49:39 +02:00
Goober5000 1b9ab28d29 Merge pull request #4732 from BMagnu/add_local_anims
Add local coordinate relations to allow restoring old absolute behaviour
2022-09-30 19:03:36 -04:00
Goober5000 c5cbd2297c Merge pull request #4726 from Goober5000/decals_right_side_up
flip decals right-side up
2022-09-30 19:03:09 -04:00
wookieejedi 678922472a Fix Remove-Order not working for Play Dead Orders (#4720)
* Fix Remove-Order not working for Play Dead Orders

Play-dead orders set a special case of the ai mode (AIM_PLAY_DEAD), which had special handling to return early in the AI frame function. Remove-order does not change the ai mode though, and thus even when a play-dead order was removed the `AIM_PLAY_DEAD' remained, which would continually trigger an early out in AI frame, which in turn would make turrets not fire on ships, even when the play-dead order was removed. No other orders had this early return, which is why remove order works for them.

This PR accounts for that special handling case. There also seemed to be an extra cleanup line for rearm and repair, so this was added right after that step.

Tested and works as expected.

* make fix flag enabled

* appease clang
2022-09-30 08:34:02 -04:00
Asteroth c9972f678a add on mouse wheel hook (#4724) 2022-09-30 16:46:52 +09:00
MjnMixael ef850ad302 Handle errors from create_wings() in an API friendly way (#4730) 2022-09-30 16:46:45 +09:00
MjnMixael 4d620bb3c7 API for checking and setting if a slot is filled or empty (#4729) 2022-09-30 16:45:06 +09:00
MjnMixael e963cfda93 return the actual number of starting wings (#4728) 2022-09-30 16:44:58 +09:00
BMagnu 4fa9a43e0e refactor names 2022-09-30 09:31:50 +02:00
BMagnu a9ec68ced6 Encapsulate relation parsing 2022-09-30 09:27:20 +02:00
Birk Magnussen 92a1a2c441 Add Local Coordinate relations to restore old absolute 2022-09-29 22:55:42 +02:00
MjnMixael 384e228347 Reset loadout to default and handle commit mission error returns (#4719)
* Reset loadout to default and handle commit mission error returns

* Return enum instead of int codes

* comment
2022-09-29 22:35:09 +09:00
MjnMixael 35ee34b86a isDisabled returns if the ship is used in the mission + some documentation fixes (#4725) 2022-09-29 16:19:05 +09:00
MjnMixael 2149a0e1ee API access to the remaining ship class strings (#4721)
* API access to the remaining ship class strings

* copy paste errors

* Actually return the string
2022-09-29 16:18:50 +09:00
MjnMixael 5979d29463 Scpui loadout pools (#4698)
* API Access to the ship and weapon pools

* func to indexer

* Make ship and weapon pools writable
2022-09-29 16:18:26 +09:00
MjnMixael e369cf98d3 API access to weapons allowed on a ship class and/or in a specific bank (#4697)
* API access to weapons allowed on a ship class and/or in a specific bank

* Allow just checking the ship and not banks

* # This is a combination of 2 commits.

syntax fix

Add method to get number of primary and secondary banks

* We don't need these

* get default weapons for each bank

* # This is a combination of 2 commits.

documentation

return secondary not primary

* fix merge error

* Address feedback
2022-09-29 16:18:14 +09:00
Goober5000 08b7fc68b7 flip decals right-side up
For some reason, decals appear upside-down unless the uvec is flipped.
2022-09-28 22:07:28 -04:00
MjnMixael 44d042edb8 Make Wss_slots writable (#4717)
* Make Wss_slots writable

* cleanup
2022-09-28 22:53:45 +09:00
EatThePath 8edb25c235 Merge pull request #4479 from Kiloku/long_turrets
Allow turrets to use their firepoints for target-leading calculations
2022-09-27 20:21:22 -05:00
EatThePath f641f0283e Merge branch 'master' into debug-log-cleanup 2022-09-27 10:34:12 -05:00
David Gibson b76294e528 Returned some more serious lines to the general categories. 2022-09-27 10:32:18 -05:00
David Gibson e86bbb0138 cleanup to the cleanup of filters
Moved more things to debug filters, and associated cleanup
2022-09-27 10:25:50 -05:00
Asteroth af4b23b7c4 handle 0 duration better (#4716) 2022-09-27 20:11:14 +09:00
BMagnu f0068b13a0 Prevent dangling threads from crashing FSO on close (#4701)
* Prevent dangling threads from crashing FSO on close

* Fix warning

* Properly allow multiple parent threads for unittests

* Fix Test

* Redo it using the lua GC method

* tidyup

* Fix Warnings

* Fix double default

* get rid of explicitly defined copy constructor to allow implicit copy assign to exist
2022-09-27 15:32:13 +09:00
JohnAFernandezandwookieejedi 2e3ff7410c Add corrections in multi ship record (#4650)
The ship record for player ships is not always accurate.  So as to correct entries as valid packets are received.

Also, remove a case where null vectors were being passed to the physics engine.

Co-Authored-By: wookieejedi <[email protected]>

Co-authored-by: wookieejedi <[email protected]>
2022-09-26 22:14:08 -04:00
Goober5000 ac57537f94 Merge pull request #4718 from Goober5000/script_vecmat_copy
a couple of scripting enhancements
2022-09-26 21:21:34 -04:00
Goober5000 1794ba87b3 address feedback 2022-09-26 19:54:18 -04:00
EatThePath 03a9c24330 Merge pull request #4711 from EatThePath/finaldata
created new "_override" universal mod directory
2022-09-26 18:43:09 -05:00
Goober5000 e2dbfca1c3 allow customizing of debug particle color 2022-09-26 18:45:19 -04:00
Goober5000 00746f1f92 add copy methods for matrixes and vectors 2022-09-26 18:43:50 -04:00
Fabian Woltermann 11ec3b64c6 Merge pull request #4712 from MjnMixael/ShipSelect3b
Lua API read-only access to the actual loadout
2022-09-26 15:38:31 +02:00
mjn-mixael eb3c8a25fb MAX_SHIP_WEAPONS 2022-09-26 08:03:40 -05:00
Asteroth 6cad66c7e7 Make sure immobile objects always have 0 velocity (#4708)
* make sure immobile objects are always 0 vel

* doesnt need to be conditional
2022-09-26 18:52:12 +09:00
David Gibson b69ac0cdd3 Implementing formatting and naming feedback 2022-09-25 19:53:54 -05:00
Goober5000 7d854c96c4 Merge pull request #4707 from Goober5000/fix_scripting_line_num
fix off-by-one error in Lua line numbering
2022-09-25 18:35:31 -04:00
David Gibson b572ef45eb added command line flag for override and addressed feedback 2022-09-25 16:16:09 -05:00
Fabian Woltermann ac27124243 Merge pull request #4715 from EatThePath/ltp-mult-lab-fix
Moved lab access to light multipliers to cleaner path
2022-09-25 19:06:21 +02:00
EatThePath 0152b7829a Merge pull request #4714 from Baezon/no-continuous-turn
Flag to turn off continuous turn when attacking
2022-09-25 11:37:57 -05:00
David Gibson 7d0393d565 Moved lab access to light multipliers to cleaner path 2022-09-25 11:35:29 -05:00
Asteroth 76c54a1016 flag to turn off continuous turn when attacking 2022-09-24 19:59:00 -04:00
mjn-mixael 1e7ee8b345 Lua API read-only access to the actual loadout 2022-09-24 16:30:44 -05:00
EatThePath 367e19b751 Merge pull request #4694 from MjnMixael/ScpuiShipSelect
Scpui ship select
2022-09-24 15:15:13 -05:00
David Gibson d0241d060c created new "load_last" universal mod directory 2022-09-24 15:00:16 -05:00
kiloku ad9bf0af71 Reset setting on mod_table_reset() 2022-09-24 10:35:25 -03:00
kiloku 4f8cf06e57 Game settings option to consider all turrets long 2022-09-24 10:32:54 -03:00
kiloku 8ef408c746 ship_get_global_turret_gun_info needs a gvec to not crash 2022-09-24 10:31:33 -03:00
kiloku 075bbe7e3b Add flag to list for parsers 2022-09-24 10:31:33 -03:00
kiloku 0a6558eea9 Adds new flag Turret_distant_firepoint that allows long turrets to aim correctly 2022-09-24 10:31:32 -03:00
BMagnu 19a7814e50 Merge Show Ship and Cockpit Renderpasses (#4705)
* Setup merge of ship model and cockpit

* Merge extmodel and cockpit rendering

* Fix hasCockpitModel check

* Fix non-coord-share mode and deferred

* Make extmodel shadowcast toggleable

* Fix extmodel shadows

* Make cockpit pass somewhat configurable

* tidyup
2022-09-24 22:10:55 +09:00
Goober5000 44802949da fix off-by-one error in Lua line numbering
This fixes the newline count used to make the parsed Lua code align with the source file.
2022-09-23 23:43:30 -04:00
BMagnu d186aefa92 Adds a cache for modular POFs (#4690)
* cleanup submodel index replacement

* Add modelreplace cache

* Move RenameSubobjects to new API

* Fix and tidyup

* Fix GCC error

* fix macro

* Appease Clang

* Properly skip reading non-final leaves from the cache

* fix warning

* Safe-stringify, incorporate comments
2022-09-23 18:38:50 +09:00
EatThePath 7c3e07ab7b Unify default filters and consolidate the new lua category 2022-09-22 21:58:24 -05:00
Goober5000 b49f70fbc3 upgrade controls code to use type-safe timestamps
This requires splitting the `used` field into digital and analog components.  The digital field stores the last-used timestamp, whereas the analog field stores the last value.
2022-09-22 22:26:34 -04:00
Adam Leach fed039fd54 logic error fix - update envMatrix even if there's no specmap (#4699) 2022-09-22 22:00:19 -04:00
Goober5000 2b1e08431c Merge pull request #4633 from Goober5000/event_and_goal_timestamps
convert event-related timestamps to new system
2022-09-22 18:51:06 -04:00
Goober5000 b0e8f260bb Merge pull request #4695 from Goober5000/more_sexps_to_scripts
a few more script enhancements
2022-09-22 18:50:11 -04:00
MjnMixael f7d84dfe76 Update ui.cpp
return
2022-09-22 09:13:27 -05:00
mjn-mixael 601a41bb60 return invalid handle 2022-09-22 08:17:19 -05:00
MjnMixael 5f183832e1 Scpui api briefing map (#4656)
* API version of the briefing map

* Cleanup

* Further cleanup

* # This is a combination of 2 commits.

Fix resizing and cleanup remaining static anim calls

Revert changes completely

* Fix documentation

* implement initBriefing and rearrange map drawing methods to match.

* Documentation

* nullptr
2022-09-22 16:04:14 +09:00
Goober5000 c7b1092a96 a few more script enhancements
1) Add the "no-thrusters" ship flag to the list of flag that can be used by alter-ship-flag or the ship's setFlag function
2) Add a `FireRateMultiplier` virtvar to control the firing rate of turrets (fulfills #4300)
3) Add a `setGlowPointBankActive` function to do the same thing as `activate-glow-point-bank`/`deactivate-glow-point-bank`
2022-09-22 02:12:17 -04:00
mjn-mixael 764c996361 Swap order 2022-09-21 18:39:58 -05:00
mjn-mixael 2f5ccc5b1a unused parameter 2022-09-21 18:02:52 -05:00
mjn-mixael 3a171493b0 Cleanup 2022-09-21 17:29:20 -05:00
mjn-mixael 655fe8d7f1 Loadout wing API (+4 squashed commit)
Squashed commit:

[83e8522d1] Comments

[50686ce6a] Wing Slot data

[450a0f6e1] Common Init

[0c603313e] Rough in WIP
2022-09-21 17:27:38 -05:00
wookieejedi 0c2a6a4f28 Fix multi lib (#4692)
Just adding 1 missing include
2022-09-21 22:08:38 +00:00
MjnMixael 3d700589c5 Give Lua access to the select anims and images (#4687) 2022-09-22 05:31:24 +09:00
EatThePath 33f24f1b4d -luadev flag and lua log filter (#4681)
* Adds new default 'lua' filter category for all lua errors and output
Adds -luadev flag that currently only makes lua errors non-fatal.

* Correcting unreachable code.

* Missed a halting code path for luadevmode

* comment fix
2022-09-22 05:31:06 +09:00
Goober5000 5e3f72229c Merge pull request #4684 from Goober5000/set_and_get_ship_flags
add setFlag and getFlag for ships and parse objects
2022-09-21 12:39:00 -04:00
Goober5000 544234743e update ship flags 2022-09-21 08:43:29 -04:00
Goober5000 fdb5506d41 make autodoc happy 2022-09-20 20:16:54 -04:00
Goober5000 7ff6da8b8b Merge pull request #4664 from Goober5000/script_model_queue_render
use queued rendering instead of immediate rendering for scripts
2022-09-20 20:09:34 -04:00
Goober5000 ce4563867d Merge pull request #4682 from MjnMixael/MissionTime
Mission time
2022-09-20 20:09:25 -04:00
Goober5000 9c71a3a1a0 allow an arbitrary number of flag arguments 2022-09-20 20:06:11 -04:00
MjnMixael eddda373d3 Allow API to optionally not start the next mission. (#4679)
* Allow API to optionally not start the next mission.

* false -> true
2022-09-21 08:16:04 +09:00
Joshua Glatt 86f458f01a Allow modifying map container data when the map is an argument (#4683)
* allow modifying map container data when the map is an argument

* skip past an invalid map key, avoid infinite loop
2022-09-21 08:11:17 +09:00
wookieejedi 7926366ee6 Update max priority for scripting AIgoals (#4685) 2022-09-20 19:09:16 -04:00
MjnMixael 710d7a614c These go here (#4689) 2022-09-21 08:08:47 +09:00
Goober5000 a379411d7a add ParsedShips indexer and update terminology 2022-09-20 16:08:43 -04:00
Goober5000 35abc3e3f5 Merge pull request #4688 from Goober5000/hud_gauge_fix
fix cargo scan type parsing
2022-09-20 15:18:04 -04:00
Goober5000 a89ba892a2 add setFlag and getFlag for ships and parse objects
This mirrors alter-ship-flag and are-ship-flags-set.
2022-09-20 14:43:24 -04:00
Goober5000 d1ba57bc23 fix cargo scan type parsing
Because of idiosyncrasies of `required_string_one_of`, use a different technique.
2022-09-20 14:16:04 -04:00
mjn-mixael 931cfdebb0 explicit bool 2022-09-19 20:34:10 -05:00
mjn-mixael f7b19553c8 nullptr while I'm here 2022-09-19 19:36:11 -05:00
mjn-mixael 6579719a04 documentation 2022-09-19 19:17:34 -05:00
mjn-mixael 68f03b5328 Add isInMission and always return getMissionTime 2022-09-19 19:05:54 -05:00
Goober5000 7fea61f618 Merge pull request #4669 from TRBlount/feature/movie_alpha
Allow movies to be alpha blended through the LUA Movie Player API
2022-09-19 18:50:20 -04:00
Goober5000 91d8031c32 Merge pull request #4677 from BMagnu/absolute_translation
Add Absolute Translation
2022-09-19 18:50:12 -04:00
wookieejedi 7b3705ad61 Fix VS Warning (#4676)
* Fix VS Warning

If this is trivial and not needed feel free to dismiss, but this one-line PR simply fixes a warning that keeps showing up when building with VS.

* individually cast

* cleaner fix
2022-09-19 17:40:35 -04:00
Goober5000 9a2a85198a Merge pull request #4680 from MjnMixael/ReverseHasDebriefing
This needs to be reversed to return the expected value
2022-09-19 17:25:06 -04:00
mjn-mixael cbd3d7da24 This needs to be reversed to return the expected value 2022-09-19 15:26:09 -05:00
JohnAFernandez 54f030ae6c Merge pull request #4671 from Goober5000/custom_hud_scan
add -dualscanlines as a HUD config option
2022-09-19 13:26:19 -04:00
Goober5000 be31334212 Merge pull request #4675 from MjnMixael/FixScramble
Fix returning int when bool expected in API
2022-09-19 11:50:40 -04:00
mjn-mixael 41dd60d111 Fix returning int when bool expected 2022-09-19 08:48:17 -05:00
BMagnu e88b898839 Add absolute translation 2022-09-19 11:57:40 +02:00
Goober5000 94fe34f619 a couple of animation fixes (#4673)
Done at Lafiel's direction.
2022-09-18 23:08:19 +00:00
Goober5000 56803e7c9f Merge pull request #4615 from MjnMixael/ScpuiDebriefingLibrary
Scpui API debriefing library
2022-09-18 18:36:33 -04:00
Goober5000 7a8b8d5fdc Merge pull request #4667 from BMagnu/seamless_anim_flag
Flag for seamless animations with startup period
2022-09-18 18:36:11 -04:00
Goober5000 782600ba7a Merge pull request #4663 from Goober5000/lighting_followup
lighting followup
2022-09-18 04:41:34 -04:00
Goober5000 36972b35f5 Merge pull request #4668 from Goober5000/stop_looping_animation
add stopLoopingSubmodelAnimation
2022-09-18 04:41:24 -04:00
Birk Magnussen cc027a91fc Incorporate Feedback 2022-09-18 10:23:15 +02:00
Goober5000 222a75f3e6 semi-deprecate dualscanlines, and put the default option in the 'else' block 2022-09-18 02:13:11 -04:00
Asteroth 5823c5f4b5 add disco scan lines 2022-09-18 01:41:14 -04:00
Goober5000 4c16c95b9b add -dualscanlines as a HUD config option
Allow different types of cargo scans, including the -dualscanline behavior, to be specified in the HUD gauges table.  Right now the options are "default" and "dualscanlines".
2022-09-18 00:50:28 -04:00
mjn-mixael ac82d8349c Virtvar -> Func 2022-09-17 22:24:48 -05:00
Tyler Blount 2f0a15da28 Remove alpha conditional check in VideoPresenter 2022-09-17 17:02:35 -07:00
Tyler Blount 0d78538a91 Update video shader and add alpha controls to VideoPresenter API 2022-09-17 15:53:04 -07:00
Goober5000 1e0845ca5e Merge pull request #4661 from scp-fs2open/dependabot/pip/ci/post/mako-1.2.2
Bump mako from 1.1.5 to 1.2.2 in /ci/post
2022-09-17 18:47:39 -04:00
Goober5000 6d204a7bc5 lighting followup
Two small fixes to follow up the lighting PRs

1) Change the mprintf to a Warning, both to be consistent with other deprecation warnings and to notify modders that they might need to accommodate the new lighting system
2) Parse any leftover data so that legacy tables don't cause FSO to choke on parsing
2022-09-17 18:43:36 -04:00
Goober5000 622c99fa2f add stopLoopingSubmodelAnimation
A script command to mirror the SEXP operator.
2022-09-17 17:45:28 -04:00
Goober5000 aafa386f22 Merge pull request #4237 from TheForce172/fix/shipEditorCleanup
QTFRED: Ship Editor Cleanup 2
2022-09-17 16:51:41 -04:00
Goober5000 29f1280df7 Merge pull request #4336 from virusman/pr/mac-release-builds
Add release CI config for Mac
2022-09-17 16:43:50 -04:00
BMagnu 5593bd168d Add optional deferred lighting pass for cockpits (#3445)
* Add deferred cockpit lighting

* Put deferred Cockpits behind a flag

* (hopefully) fix bad in-case initializer

* clear non base color buffer in subsequent deferred passes

* Proper deferred Cockpit rendering

* undo whitespace changes
2022-09-17 15:29:35 -04:00
Goober5000 b14db41126 Merge pull request #4647 from Goober5000/frame_debug_tweak
better adjustment of timestamp delta
2022-09-16 22:20:55 -04:00
Goober5000 85c1ae1f4b use queued rendering instead of immediate rendering for scripts
Scripts that render models in the On Object Render hook were effectively doing immediate renders in the middle of queued renders.  This caused some data, such as model orientation, to 'leak' between renders.  It might also have something to do with why the bug in #4637 had the particular graphical side effects that it did.

Anyway, changing the immediate renders to queued renders fixes the leaky orientations, and is probably a good upgrade for other reasons as well.
2022-09-16 17:27:50 -04:00
wookieejedi ad817795e2 Fix smart spawn flag (#4662)
Courtesy of Lafiel, this code fixes special flags such as those related to `spawn`. (Bug arose in #4620).

Tested and fixes the problem and works as expected.
2022-09-16 20:46:16 +00:00
Birk Magnussen 2a8ee1f80b Properly set flag 2022-09-16 21:43:34 +02:00
dependabot[bot] 1b82c101f6 Bump mako from 1.1.5 to 1.2.2 in /ci/post
Bumps [mako](https://github.com/sqlalchemy/mako) from 1.1.5 to 1.2.2.
- [Release notes](https://github.com/sqlalchemy/mako/releases)
- [Changelog](https://github.com/sqlalchemy/mako/blob/main/CHANGES)
- [Commits](https://github.com/sqlalchemy/mako/commits)

---
updated-dependencies:
- dependency-name: mako
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-09-16 19:03:37 +00:00
BMagnu 7d42bf08a6 Fix Animation 3D Sound (#4658)
* Add options to enable animation sound to actually be 3D

* Fix typo

* Fix objnum valid check
2022-09-16 14:35:10 -04:00
mjn-mixael 8d8cf0a41c Prevent multiple instances of evaluated debrief sexps 2022-09-16 12:44:10 -05:00
Fabian Woltermann ef496f08e0 Merge pull request #4657 from Goober5000/4602_followup
additional polishing of the briefing API
2022-09-16 15:47:49 +02:00
BMagnu 47b5bc6b64 Add flag safeguard 2022-09-16 13:38:15 +02:00
BMagnu 3f3ff4f685 Add Seamless with startup animation mode 2022-09-16 13:15:07 +02:00
BMagnu dc320d0768 Add special flag to animations 2022-09-16 11:36:00 +02:00
Goober5000 c9ca58f504 update 2022-09-15 20:09:55 -04:00
BMagnu cf8f90e93d Properly encapsulate special flag parsing (#4620)
* properly encapsulate special flag parsing

* Cleanup Cpp11 mess

* Fix missing include in vmallocator.h

* Fix bad merge

* address feedback
2022-09-16 07:39:45 +09:00
Goober5000 06fc8c73a5 this flag deserves its own commit 2022-09-15 18:38:57 -04:00
Goober5000 d92496ee02 convert event-related timestamps to new system
This change covers just the timestamps associated with goals and events, for better review and isolation purposes.

Follow-up to #4569.
2022-09-15 18:38:53 -04:00
Goober5000 c13e262bb8 Merge pull request #4640 from Goober5000/hud_scripting_enhancements
several minor HUD enhancements
2022-09-15 18:34:36 -04:00
Fabian Woltermann 8d93276423 Merge pull request #4654 from qazwsxal/light-power-fix
Light power fix
2022-09-15 20:08:58 +02:00
Fabian Woltermann 69915a1364 Merge pull request #4653 from qazwsxal/thicc_lights
Improved beam, blob and warp lighting
2022-09-15 20:07:53 +02:00
Fabian Woltermann 179f0c0f47 Merge pull request #4659 from qazwsxal/fix/sim_room_fix
Fix retail UI crash when campaign missions are selected in simulator
2022-09-15 19:09:58 +02:00
Adam Leach 5254a5867d keep MSVC happy 2022-09-15 17:51:02 +01:00
Adam Leach 2a4b5b0dee Remove duplicate. 2022-09-15 17:49:22 +01:00
David Gibson fea116ea82 fix ambient lighting to match 2022-09-15 17:47:25 +01:00
David Gibson b6bc5175da Add default brightness profile adjust and retune the techroom rendering appropriately. 2022-09-15 17:47:25 +01:00
David Gibson 02ebdd50d0 Switched to default size zero light emitters 2022-09-15 17:47:00 +01:00
David Gibson c5800b722d Adding configurable source radius to the lighting data and uniforms 2022-09-15 17:46:42 +01:00
Adam Leach 0eb5197ecd Fixes retail UI crash when campaign missions are selected in simulator 2022-09-15 17:35:13 +01:00
David Gibson cf0a785029 adjusted the width of beam light cores 2022-09-15 17:04:25 +01:00
Adam Leach a9a9c89c98 Actually fix lighting error (and document) 2022-09-15 17:04:25 +01:00
Adam Leach f9424a1b88 Factor out spherelight calcs, fix lighting error when inside spherelight 2022-09-15 17:04:25 +01:00
Adam Leach b0467d0697 Clamp beam length to prevent light from going past start/end points. 2022-09-15 17:04:25 +01:00
David Gibson d93e6cf752 Adjusted fireball sizing 2022-09-15 17:04:25 +01:00
David Gibson e00635d430 Switched to default size zero light emitters 2022-09-15 17:04:25 +01:00
David Gibson 413e817733 Attached reasonabled defaults to the new source radius settings 2022-09-15 17:04:25 +01:00
David Gibson e37427a24b Adding configurable source radius to the lighting data and uniforms 2022-09-15 17:04:25 +01:00
Adam Leach 30d534fe32 Documentation and a small optimisation. 2022-09-15 17:04:25 +01:00
Adam Leach b77b820aa2 Initial work for lights with adjustable emitter size and tube rendering. 2022-09-15 17:04:25 +01:00
mjn-mixael ce9dd1eaf3 cleanup includes 2022-09-15 10:41:57 -05:00
Fabian Woltermann 6c83a72403 Merge pull request #4652 from qazwsxal/qaz-shaders
Improved shaders and image based lighting
2022-09-15 17:39:07 +02:00
mjn-mixael 54b6efcf25 Address feedback 2022-09-15 10:27:45 -05:00
mjn-mixael 925aa44ebb Compare pointer to nullptr instead of 0 2022-09-15 10:27:42 -05:00
mjn-mixael f0f23b5fd0 Address feedback 2022-09-15 10:27:38 -05:00
mjn-mixael 7d77b8ebc0 Return this exactly to previous state 2022-09-15 10:27:35 -05:00
mjn-mixael 6f0f3a10eb Address feedback 2022-09-15 10:27:31 -05:00
mjn-mixael f011e59d61 Remove unreachable code 2022-09-15 10:27:22 -05:00
mjn-mixael d718c76906 Some cleanup 2022-09-15 10:27:21 -05:00
Mike N 895d4dce1a debriefing api access 2022-09-15 10:27:19 -05:00
Goober5000 e146a24f9e additional polishing of the briefing API
Follow-up to #4602.  Overall the PR was good, but there are a few extra small changes that should go in. In order of priority:

1) The `exitLoop`, `skipMission`, and `skipTraining` functions should check for campaign mode.
2) The `isVisible` virtvar should be changed to a function, because calling it may have side effects.  In standard usage, the briefing formula is evaluated exactly once per stage on briefing initialization, so scripts should follow this convention.
3) The `hasGoalsSlide` function should be called `hasGoalsStage`, because "stage" is the common terminology in FSO.
4) Paging out mission messages is already done in `game_level_close` and should be removed from not only the scripting method but the method it was based on.
5) For consistency, unused parameters should use the `SCP_UNUSED` macro.
6) The `isTraining` flag check can be slightly streamlined using the double-not trick.
2022-09-15 11:20:00 -04:00
EatThePath c66f90b46d Implemented a command line flag that forces a fixed RNG seed, (#4599)
* Implemented a command line flag that forces a fixed RNG seed, which reseeds the RNG on every mission load.

* Naming changes and bounds checking
2022-09-15 22:30:26 +09:00
Adam Leach d4ad137251 Converted warning to log message as the data is just ignored 2022-09-15 13:21:11 +01:00
Adam Leach 1e695cf807 Merge branch 'master' into qaz-shaders 2022-09-15 10:18:03 +01:00
Goober5000 850f2904dc Merge pull request #4603 from Goober5000/timestamp_migration_2
more timestamp migration
2022-09-15 02:01:19 -04:00
Goober5000 086e386b75 Merge pull request #4655 from Goober5000/improve_huge_fire_info_lookup
improve huge_fire_info lookup
2022-09-14 22:32:09 -04:00
EatThePath 452f554193 Crossing the specular rubicon (#4302)
* Applying directional brightness profile value, disconnected spec flags and made specular light always equal to diffuse light

* Switched over to new command line arguments

* Wire lab up to new lighting controls, and provide backwards-compatible defaults for emissive.

* cleanup unused new function

* make static some functions that can be static

* revise command-line and emissive handling

* handled specular sun depreciation and general removal of specular value handling

* Removed specular light color as a separate value in the uniform buffers.

* cleanup of leftover/post-rebase specular references

* further post-rebase repair of light flags command line and leftover specular

* move techroom/selection/breifing 'room' lights to a common function and
augment lighting setup for current rendering

* fixed some mishandling of lighting modifiers.

* Addressed code clarity and comments from review
2022-09-15 05:47:58 +09:00
Goober5000 15dc0aba77 improve huge_fire_info lookup
According to EatThePath's frame profiling, this one ship name lookup takes 2% of the frame time.  It can be easily optimized by making use of the ship registry.
2022-09-14 14:39:32 -04:00
Adam Leach 9cccab3f18 unused var check 2022-09-14 17:54:05 +01:00
Adam Leach 36a714b93f Merge branch 'master' into qaz-shaders 2022-09-14 16:56:57 +01:00
MjnMixael 70609bb3b9 Cleanup Fiction, Red Alert, and Loop Brief based on feedback on other PRs (#4649) 2022-09-14 16:01:57 +09:00
BMagnu 10a47781a0 Change cmd_briefing API to reference from copy (#4646) 2022-09-14 16:01:42 +09:00
MjnMixael ff55a39dd4 Scripting functions required for SCPUI conversion of all four Tech Room UIs (#4591)
* Documentation (+6 squashed commit)

Squashed commit:

[ea8550b54] Resolve errors

[9ab0a576d] Add way to count number of elements in the arrays

[eb74146cc] Correct this boolean check

[60fbc6008] Missed one

[78e65a4b7] Avoid naming collision

[4ea5ddead] Clean unneeded log print and compare like variables

* Adding simulator room here seems like a pretty safe option

* Scpui API to access to build the tech room cutscene list and a few methods to help playing the cutscene and return to the menu accurately

* Scpui API access for credits related data

* # This is a combination of 7 commits.

Clean unneeded log print and compare like variables

Avoid naming collision

Missed one

Correct this boolean check

Add way to count number of elements in the arrays

Resolve errors

Documentation

* Address feedback

* Address feedback

* Add virtvar isCampaignMission
2022-09-14 16:01:34 +09:00
Goober5000 ae57ea7158 Merge pull request #4643 from Goober5000/small_hook_refactor
small hook refactor
2022-09-13 18:24:45 -04:00
MjnMixael ef85e94e40 SCPUI API elements required for the Briefing (#4602)
* API elements required for the Briefing

* Resolve errors

* Check if the mission is a Scramble mission

* Add one missed flag check

* Slight API naming adjustment

* Address feedback

* Address Feedback again

* Differentiate var names
2022-09-14 04:39:20 +09:00
Goober5000 258e735af2 better adjustment of timestamp delta
When debugging, don't adjust the timestamp by the exact difference, since that would make the frametime 0 and cause div-0 errors.  Instead pretend that the previous frame was a reasonable duration.  Also, perform the timestamp check separately from the frametime check, since they are not always consistent.
2022-09-12 21:22:56 -04:00
Goober5000 19f193f533 Merge pull request #4644 from Goober5000/remove_asserts
remove two unnecessary asserts
2022-09-12 15:56:51 -04:00
wookieejedi d5eca2fab1 Auto Truncate default ship names (#4642)
* Auto Truncate default ship names

Previously, placing a ship that had a long class name might create a default name that was too long and thus trigger a buffer overflow assert.

Such behavior was confusing if someone was just placing things in FRED and not sure at all what happened or how to fix it.

This PR replaces the assert with code to auto truncate the ship class part of the name to ensure that the default name will fit into the designated size.

* change var name
2022-09-12 13:26:53 -04:00
Goober5000 f932c2da6a Merge pull request #4645 from Goober5000/fix_4637
fix script conditions for ships
2022-09-12 03:09:25 -04:00
BMagnu 14f94eb34f Add Angle SEXPs (#4641)
* Add angle SEXPs

* Convert to Degrees
2022-09-12 15:11:57 +09:00
Goober5000 4be8851c16 fix script conditions for ships
Like #4559 before it for weapons, this fixes the script conditions for ships.  The problem was the same: the script condition would evaluate to true if none of the objects under consideration were ships.  The fix is the same as well.  I checked all the other script condition categories, so no similar bugs should pop up in the future.

Fixes #4637.
2022-09-12 00:05:24 -04:00
Goober5000 5e4abb30a3 remove two unnecessary asserts
It's not necessary here to assert on the correct variable type, as having the wrong type here won't cause the code to break.  More importantly, the error will have been flagged before this point anyway, and this code is used for formatting the SEXP to be displayed in an error message.  It's not helpful to pre-empt an error message with an assert.
2022-09-11 23:21:16 -04:00
wookieejedi f2dd37fab3 Allow Autotarget to target new target when current target is deathrolling (#4638)
Discussion starts here: https://discord.com/channels/223511295431933953/722747742996267068/1018264927699476571
2022-09-11 22:29:56 -04:00
Goober5000 974981520d change names 2022-09-11 22:25:57 -04:00
Goober5000 46bd9ecae8 fred and qtfred 2022-09-11 22:24:25 -04:00
Goober5000 9fcf17b9e6 better distinguish between builtin and custom hud gauges, and allow both when the functions can handle it 2022-09-11 22:09:24 -04:00
Goober5000 9056a9c89b partial revert of 2e839eda0; these sexps need to get any gauge, not just the custom ones 2022-09-11 21:16:50 -04:00
Goober5000 0480fa69d9 several minor HUD enhancements
add `getDirectiveLines` and `setPosition` script functions
properly error if trying to set a HUD gauge name
remove the unneeded `Directive_frames_loaded` variable
improve accuracy of SEXP help for HUD gauge operators
2022-09-11 21:16:50 -04:00
virusman 288e3b86d1 Add release CI config for Mac 2022-09-11 16:03:55 -07:00
Goober5000 8bc4064670 small hook refactor
Basically just changing some parameter names.
2022-09-11 15:07:17 -04:00
Goober5000 9e6e95108d Merge pull request #4636 from Goober5000/fix_4635
properly account for string sizes in debrief_choose_voice
2022-09-11 13:00:29 -04:00
wookieejedi 375ccd7413 Fix conditional for Always_warn_player_about_unbound_keys (#4639)
Properly check if mission is singleplayer for the `Always_warn_player_about_unbound_keys` game option.
2022-09-11 11:17:00 -04:00
Kiloku d0c76a7eaa New options for lead indicators (#4411)
* Adds Lead Indicator Behavior option to game_settings.tbl

* Adds dont merge lead indicators flag to weapons, allowing homing secondaries to have their own lead indicators no matter what.

* Removed unused variable that was added just for testing

* add explicit int to float conversion to appease build checks

* Move some things around to avoid potentially undefined values

* Clean-up + address feedback

* Remove redundancy
2022-09-11 23:57:40 +09:00
Goober5000 7462dd68f8 fix subtitle clipping (#4625)
For subtitles drawn using the `$Show-subtitle base resolution:` feature, text near the side of the screen would get clipped off mysteriously.  The clipping corresponded precisely to the edge of a 4:3 boundary, which led me to discover that the clip boundary was still at the side of a 4:3 box, rather than a 16:10 box as was expected.  Explicitly setting the clip boundary when setting the screen scale fixed the issue.

For any graphics coders in the know, is this actually the proper fix?
2022-09-11 20:00:54 +09:00
Fabian Woltermann 9ba91d870c Merge pull request #4632 from The-E/fix/4614_demotion_went_too_far
Fix issue with new pilots getting demoted too fast
2022-09-10 21:15:05 +02:00
Asteroth ef57ffc2f4 Add maneuvering thruster easing (#4623)
some thruster and comment clean up, and thruster easing
2022-09-09 18:36:04 -05:00
Goober5000 1509448a34 properly account for string sizes in debrief_choose_voice
The null terminator was written past the end of the string buffer, which intruded on the next field in the struct.  Fixing this fixes #4635.  Also adjust the string concatenation a couple lines up because it could also write past the end of the buffer.
2022-09-09 12:07:07 -04:00
EatThePath bb232382cf Merge pull request #4528 from MageKing17/feature/default-shockwave-damage-types
Add default shockwave damage types functionality.
2022-09-09 09:53:30 -05:00
Fabian Woltermann e21dfcb457 when resetting stats before replaying a mission, check the rank table to see which rank the player should be 2022-09-08 19:17:47 +02:00
Goober5000 ae3fb54c02 add more timestamp documentation 2022-09-08 02:42:38 -04:00
Goober5000 16a8a46f42 Merge pull request #4579 from MjnMixael/RenderWeaponTechModel
Implement renderTechModel() and renderTechModel2() for weapons
2022-09-07 20:09:06 -04:00
Goober5000 9cb2892ca9 Merge pull request #4629 from Goober5000/script_interpolate_matrices
rotational interpolation
2022-09-07 16:48:26 -04:00
Fabian Woltermann c9c4632a87 Merge pull request #4631 from The-E/fix/lab_crash_when_destroying_dead_ship
Fix lab crash when destroying a destroyed ship
2022-09-07 19:29:43 +02:00
Fabian Woltermann f2abe516f3 check if the current lab object is actually a ship before trying to destroy it 2022-09-07 18:54:05 +02:00
Asteroth cb7d117bdf Automatic thruster activation (#4617)
* automatic thruster activation and glide thruster activation

* finalizing tweaks

* fixes

* whoops
2022-09-07 18:36:37 +09:00
Asteroth de503bb2d5 small fix for banking (#4624) 2022-09-07 18:35:30 +09:00
Goober5000 39b57cbf41 rotational interpolation
Add script support for rotational interpolation of matrixes (orientations) and vectors.
2022-09-06 21:48:03 -04:00
Goober5000 66473f03ab Merge pull request #4621 from Goober5000/fix_supercap_warpout
fix supercap immediate warpout
2022-09-06 18:20:15 -04:00
MageKing17 dbd3721b00 Default-enable inheriting damage type in mods targeting 22.4+. 2022-09-06 13:04:44 -07:00
BMagnu 565047e93b Implement a proper std::optional alternative (#4619)
* Add optional lib

* Replace modelreplace optionals

* Replace Animation Optional

* rework modelanimationdata constructors
2022-09-06 17:05:05 +09:00
BMagnu ee4d74a1af Prevent closed thread from re-closing (#4622) 2022-09-06 03:17:13 +00:00
JohnAFernandez f2038a8a1a Merge pull request #4613 from JohnAFernandez/Add-Interpolate-Matrices-For-Multi
Add interpolate matrices for multi
2022-09-05 19:40:36 -04:00
John Fernandez a93eeebff0 Fixes for Matrix interp 2022-09-05 19:05:12 -04:00
Goober5000 5d57da1755 fix supercap immediate warpout
Supercaps have a special physics flag applied when they warp in so that they slow down quickly.  However, if a supercap immediately warps out again - as in Deus Ex Machina and DEM: Interlude - this physics flag will interfere with the process so that the ship doesn't accelerate immediately even though the warpout portal is opening.  This will cause the ship to miss the portal and clip off a section.  The solution is to clear the flag once the warpout process starts.
2022-09-05 16:35:03 -04:00
Goober5000 fe44dda809 Merge pull request #4521 from Goober5000/end_of_mission_cutscene
mission-specific cutscene enhancements
2022-09-05 04:51:15 -04:00
Goober5000 3da5910c23 Merge pull request #4618 from Goober5000/object_radius
add Radius virtvar for objects
2022-09-05 04:25:22 -04:00
Goober5000 268a483bdb add Radius virtvar for objects
Surprised it hasn't been added before now.
2022-09-05 01:31:18 -04:00
Asteroth 6440c64b77 Fix cfread string's handling of null terminated strings (#4583)
* fix cfread string's handling of null terminated strings

* clarity and doc edits
2022-09-05 04:15:50 +09:00
BMagnu 2a2ed22e5b Enable LuaAI to use more arguments (#4577)
* Enhance LuaAI args

* Pass the Lua Parameters

* Cleanup debugging comment

* Fix warnings
2022-09-03 22:31:52 +09:00
PhantomHoover 402ee8636e Remove unused and costly checksum during model read (#4592)
Profiling shows this taking about 10% of the total time in loading BP's Icarus mission, and the result isn't even read any more!
2022-09-03 22:16:50 +09:00
BMagnu 74ba7899fd Virtual / Modular POFs (#4590)
* Integrate Barebones Framework

* further integration

* Add brak in read

* Defer subsystem generation

* Unentangle pof parsing and subsystem info writing

* finalize modelreplace skeleton

* Begin submodel copying

* First prototype of modular pofs demonstratable

* Allow Submodel Renaming

* Add copy children and set offset

* properly handle depth

* Add header modification

* Fix issues with parsing

* Fix Warnings

* incorporate feedback

* de std-ify

* Incorporate Feedback 2

* Fix macro

* Remove ref

* Enhance error messages
2022-09-03 22:15:56 +09:00
Goober5000 bc5ee36bd8 Merge pull request #4552 from Goober5000/additional_shudder_support
enhanced control for the global ship shudder
2022-09-03 00:12:42 -04:00
naomimyselfandi a8c8549015 Respect hashes in ship and wing names in the loadout screen (#4609)
* Respect hashes in ship and wing names in the loadout screen

* Use get_display_name()
2022-09-02 08:36:07 -04:00
naomimyselfandi 89dc0c66dc Allow assigning support ship per species (#4608)
* Allow assigning support ship per species

* Respond to PR feedback
2022-09-02 08:15:26 -04:00
Kiloku 05495cd1bc Add optional Drop Shadows to HUD (#4543)
* Add drop shadows to HUD text

* Add drop shadow to reticle

* Add control to toggle Drop Shadows

* Double render reticle shadows

* Use gauge_color instead of creating a temp var

* Add shadows to ETS gauges

* Set shadow default to false and adjust formatting

* Restore numbering for controlsconfig
2022-09-01 22:06:00 -04:00
wookieejedi d905410591 Allow mods to change Emp flash color, intensity, and string (#4607)
* Allow mods to change Emp flash color, intensity, and string

EMP is the only text warning that does not use an entry in the strings table (and thus it's the only text warning gauge that mods cannot change and/or translate). This PR adds a string entry for it to allow mods to translate and change the string like all other HUD gauge text warnings.

Also, EMP flash has a hard coded color and strength factor for the flash, whereas generic pain and shield pain have a configurable flash strength factor (shield pain flash is based on shield color, while generic pain is based on damage dealt). This PR also allows modders to change the strength intensity and color following previously established methods.

This PR also fixes a case of "Launch" that fell through the cracks. The function is supplied the translated string, but within the function it does not check for the translation.

Everything is tested and works as expected.

* incorporate feedback

* convert to float during parse

* incorporate more feedback

* improve safety checks
2022-09-01 21:31:16 -04:00
Fabian Woltermann 9a5e34b546 Merge pull request #4612 from The-E/fix/4604-defer_adding_hooks_until_safe
defer adding new scripting hooks until after hook processing is done
2022-09-01 19:03:24 +02:00
Fabian Woltermann a1b48d0a9e defer adding new scripting hooks until after hook processing is done 2022-09-01 18:30:48 +02:00
Taylor Richards bb06c75cb4 handle irc motd error to prevent connection hang (#4610)
A MOTD missing (422) message is non-fatal and should be handled the
same as a MOTD end (376) message to prevent the chat connection
process from hanging.
2022-09-01 05:57:01 -04:00
Taylor Richards ea2d9d9167 prepend PXO game identity to chat lobby window (#4606)
For help with troubleshooting, list what game/mod PXO identifies
this instance is running in the chat lobby stream.
2022-09-01 05:56:24 -04:00
John Fernandez 5d267307b2 Change last orient to sensible value
Previously this could be set to bad data, since the last orient calculated could be based on stale data.
2022-08-31 15:54:56 -04:00
John Fernandez dc625bca33 Change to interpolating matrices
Should create a steadier interpolation
2022-08-31 13:33:25 -04:00
John FernandezandAsteroth 2b0f35b58b Add an explicit Interpolate Matrices function
Written by Asteroth, derived from our ai code.  I added a couple safety checks and changed the type to void to match our library.

Co-Authored-By: Asteroth <[email protected]>
2022-08-31 13:33:25 -04:00
Asteroth a9b485da3d associate a single version to submodel translation (#4605) 2022-08-31 01:13:11 -04:00
MjnMixael ebc8ebd638 Add $Mod Title and $Mod Version options to game_settings.tbl (#4565)
* Add $Mod Title and $Mod Version options to game_settings.tbl for mainhall and Lua use

* Fix comparison

* documentation

* address feedback

* typo
2022-08-30 10:57:06 -04:00
Goober5000 ba82e4ef57 Merge pull request #4582 from Goober5000/model_translation
Model translation
2022-08-29 12:46:28 -04:00
Goober5000 6c7c093729 some more timestamps 2022-08-29 10:42:03 -04:00
Goober5000 3d74bac90b more timestamp migration
More conversion of timestamps to the new system.  Follow-up to #4569.
2022-08-29 09:27:30 -04:00
Goober5000 74ab0f7878 Merge pull request #4601 from Goober5000/good_rearm_time_fix
fix good-rearm-time bug
2022-08-29 00:59:56 -04:00
Goober5000 ef4c3984b5 fix good-rearm-time bug
The original implementation of `ai_good_time_to_rearm` did not revert to being a "bad" time to rearm when the time was up.  This fixes that and adds an AI profiles flag to toggle it.

Also converts `ai_rearm_timestamp` to use the new TIMESTAMP type.
2022-08-29 00:00:15 -04:00
JohnAFernandez 51ca0d20ee Merge pull request #4600 from MjnMixael/ColorTagFix
This should be func not virtvar
2022-08-28 18:17:22 -04:00
Goober5000 41d2cdc82c Merge pull request #4569 from Goober5000/asteroid_debris_timestamps
convert some timestamps to the new system
2022-08-28 17:44:41 -04:00
mjn-mixael 63d4a7ce8c This should be func not virtvar 2022-08-28 14:52:31 -05:00
MjnMixael 6425a999a6 Some User Interface API cleanup and generalization (#4595)
* Move colors up one level and generalize

* Initialize this first

* These are common to both all Briefings, so put them in the general Briefing category
2022-08-28 14:27:17 -04:00
MjnMixael be00e257b8 Scripting functions required for SCPUI conversion of Red Alert (#4587)
* Scripting functions required for SCPUI conversion of Red Alert

* Correct documenation

* Address feedback

* Missed return

* Briefings
2022-08-28 13:18:12 -04:00
wookieejedi 650ae9a074 Some extra safety checks for fiction viewer scripts (#4598)
Protects `Fiction_viewer_active_stage` if it reads a stage of -1 (it would have thrown a vector access error because the index is out of range). Also, given a lot of other scripting functions have additional built in error checks, I just added those to the fiction viewer functions.
2022-08-28 09:11:57 -04:00
MjnMixael 60509b2c3c Scripting functions required for SCPUI conversion of Loop Brief. (#4586)
* Scripting functions required for SCPUI conversion of Loop Brief.

* nullptr

* Fix documentation and make setting choice optional, defaulting to false.

* Documetation fix
2022-08-28 08:52:41 -04:00
Goober5000 67729990e3 we don't need to bump the multi version yet 2022-08-27 13:10:05 -04:00
Goober5000 9116f5de2d improve API 2022-08-27 13:10:05 -04:00
Goober5000 018363dac6 edit lab flag 2022-08-27 13:10:05 -04:00
Goober5000 662d71a57a add model animation support, based on Lafiel's guidance 2022-08-27 13:10:05 -04:00
Goober5000 d3807cbd08 add subsystem sexps 2022-08-27 13:10:05 -04:00
Goober5000 5cf412aad8 implement stepped and regular translation as controlled by subsystems 2022-08-27 13:10:05 -04:00
Goober5000 a1215c6d6f infrastructure for handling submodel translations - maintaining, colliding, rendering 2022-08-27 13:10:05 -04:00
Goober5000 d25a477ffc Merge pull request #4560 from Goober5000/floating_point_followup
floating-point followup
2022-08-27 13:00:43 -04:00
MjnMixaelandAsteroth 150608a980 Base method to determine Debug vs Release (#4597)
* Base method to determine Debug vs Release

* small spelling fix

Co-authored-by: Asteroth <[email protected]>
2022-08-27 11:42:06 -04:00
wookieejedi 1df396bbf4 Allow test_line_of_sight to return intersecting object signature (#4596)
* Allow `test_line_of_sight` to return intersecting object signature

The `test_line_of_sight` can currently provide the closest intersecting distance, but it would be very useful, especially for AI scripting, if this function could also return the signature of the intersecting object. This PR adds that functionality.

Tested and works as expected. Happy to discuss strategies for changing implementation, too. The extra, third return value for object signature was added to `getLineOfSightFirstIntersect` function because that function already returns 2 values. Thus, it will remain compatible with older scripts which only save the first 2 returned values.

* fix documentation

* fix typo

* return object instead of sig

* fix pointer

* use pointer pointer for full fix

* name clarification
2022-08-26 23:05:07 -04:00
MjnMixael a884633723 Fix documentation (#4594) 2022-08-26 23:03:54 -04:00
mjn-mixael 762d855e99 Implement renderTechModel() and renderTechModel2() for weapons 2022-08-26 12:21:40 -05:00
Goober5000 19e407df62 convert some timestamps to the new system
Mostly debris and asteroid timestamps, but also arc timestamps for ships.
2022-08-25 21:40:18 -04:00
Goober5000 8c47a03df9 Merge pull request #4469 from Goober5000/more_voice_acting_buttons
Voice acting manager enhancements
2022-08-25 21:37:55 -04:00
Goober5000 4dfb29f9d8 adjust MOI values per feedback 2022-08-25 21:36:40 -04:00
Goober5000 e67ea63121 use std::max 2022-08-25 21:36:40 -04:00
Goober5000 60540d2a57 floating-point followup
Floating-point comparisons are tricky beasts.  See this article for a good summary of the issues involved:
https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/

This PR improves support somewhat, although there are obviously situations in the code (such as comparisons to 0) that should still be addressed.  This PR makes the following improvements:
1) Tightens the threshold on `IS_VEC_NULL` and `IS_VEC_NULL_SQ_SAFE` from 1e-16 and 1e-36 to FLT_EPSILON
2) Tightens the threshold for parsing `turn_time` in POFs
3) Restores the previous implementation of `fl_equal`
4) Adds a dedicated `IS_MOI_VEC_NULL` for moment of inertia values
5) Improves documentation

Follow-up to #4535 and #4443.
2022-08-25 21:36:40 -04:00
Goober5000 a1f58671e5 enhanced control for the global ship shudder
Allow the variables controlling ship shudder to be independently set using scripting.  Also add new flags to apply the shudder without decay and apply the shudder regardless of camera.

Also change the shudder timestamp to the new style.
2022-08-25 21:36:17 -04:00
Goober5000 c239490899 Merge pull request #4593 from virusman/pr/fix-mac-builds
Fix Mac builds by overriding py7zr version
2022-08-25 21:06:41 -04:00
virusman c30500b66e Fix Mac builds by overriding py7zr version 2022-08-25 17:11:46 -07:00
MjnMixael 6d26547928 Scripting functions necessary for SCPUI Fiction Viewer (#4584)
Scripting functions necessary for SCPUI Fiction Viewer
2022-08-25 18:16:42 -04:00
wookieejedi 261dc508f8 Script function for turnTowardsOrientation (#4578)
A simple copy of the same function on `ai_helper`, now usable on plain ships too.
2022-08-23 22:23:30 -04:00
Goober5000 a0890c291a Merge pull request #4585 from Goober5000/fix_sound_parsing
fix overriding of originally-empty sounds
2022-08-23 22:13:16 -04:00
MjnMixael 89ff900e68 Make cutscenes.tbl extendable with -csn.tbm (#4571)
* Make cutscenes.tbl extendable with -ccn.tbm

* Only let first cutscene of any parsed file be visible by default

* Implement +nocreate support and change modular ext from ccn to csn

* Remove commented out code

* Initialize char* as NULL

* Address feedback

* cleanup
2022-08-23 07:38:46 -04:00
Goober5000 f469da2606 fix overriding of originally-empty sounds
Follow-up to #3743.  A sound that was originally parsed as empty, but then re-parsed as non-empty, would still have the `GAME_SND_NOT_VALID` flag from the original attempt.  This fixes that by clearing the flag each time the filename is read.
2022-08-23 01:28:12 -04:00
Goober5000 38d099ebd6 Merge pull request #4581 from Goober5000/fs1_reticle_supplement
add missing hud_gauges.tbl options
2022-08-22 21:54:11 -04:00
Goober5000 063bf44a19 Merge pull request #4397 from Goober5000/separate_ondeath_hooks
add new hooks for each object type
2022-08-22 19:38:07 -04:00
Goober5000 9c61b389d6 add missing hud_gauges.tbl options
These options for controlling the locking animation are toggled by `$Reticle Style:` but were otherwise not available to HUD gauges.
2022-08-21 22:10:45 -04:00
Goober5000 2b582676a6 make OnShipDeath overridable, per request 2022-08-21 20:53:04 -04:00
Goober5000 ba36ad69f5 add new hooks for each object type
Splits the existing On Death hook into independent hooks for each relevant type.  Adds On Ship Death, On Missile Death, etc.  Also adds On Missile Death Started to complement On Ship Death Started.
2022-08-21 20:53:04 -04:00
BMagnu 76be16f6b2 Fix Typo (#4580) 2022-08-21 23:31:04 +00:00
BMagnu 2557478d55 Allow changing Animation Instance speed (#4572)
* Allow changing animation speed

* Return nil from function

* address feedback
2022-08-22 03:14:34 +09:00
Asteroth c68e737c51 cap zoom distance and lower sensitivity (#4557) 2022-08-22 02:18:01 +09:00
PhantomHoover a95ecf9c9c Fix dangling pointer in sexp.cpp (#4561)
If you define a variable inside a block, its lifetime is confined to that block. So oswpt needs to be lifted into the parent block.
2022-08-22 02:17:49 +09:00
PhantomHoover c153fa8d26 Fix dangling pointer in hudparse.cpp (#4558) 2022-08-22 02:16:42 +09:00
wookieejedi 0f6ea85224 Fix setting of $Shadow Quality Default: (#4576)
`$Shadow Quality Default:` allows mods to specify what the default shadow quality should be, given that `-enable_shadows` flag is used. If a mod used this game settings option but the player did not use the `-enable_shadows` flag, then a parsing error would show up.

This PR fixes that bug by reordering two lines. Tested and fix works as expected.
2022-08-21 12:04:35 -04:00
JohnAFernandez d1d63a912a Prioritize players in object update (#4575)
* Make sure that players are updated the more often

Mitigates the increased latency from multiple clients getting each other's positions.

And Adjust update times:

Because LAN settings are now widely used even on non-LAN connections, shift High to a little bit less frequently in some situations, and adjust LAN settings so that it doesn't take quite as much bandwidth for updating ships that are `rear_medium` or `rear_far`.

Also update comments.

* Remove unused define

This was used in the previous version of the object update code and doesn't need to be here anymore.
2022-08-21 11:15:47 -04:00
BMagnu 55eab4c7e7 Add turnTowardsOrientation (#4563) 2022-08-21 08:24:39 -04:00
Goober5000 38fbe6311e Merge pull request #4555 from MjnMixael/LuaPersonaAccess
Implement ability to get and set a ship's persona index
2022-08-21 00:54:50 -04:00
EatThePath 0b97fc2c8e Merge pull request #4554 from MjnMixael/OnLoadoutStarted
Add hook just before loadout parsing
2022-08-20 23:21:27 -05:00
MjnMixael 5f5b08b594 Mouse option strings (#4570)
* Updated display strings for mouse settings

* Reverse these to match input functionality

* Fix whitespace

* Update mouse.cpp

Fix whitespace again
2022-08-20 22:10:03 -04:00
The Force 88bae48ded Actually Alt-name & callsigns and don't update window if closed 2022-08-20 19:23:20 +01:00
Goober5000 12227fd0ab Merge pull request #4567 from Goober5000/fix_stepped_rotation
fix stepped rotation
2022-08-20 12:15:13 -04:00
Goober5000 74112e13f7 fix stepped rotation
As part of the cleanup in preparation for model translation, there was a bit of code review that was actually incorrect.  The calculation of the current step needs to be rounded down, because the step isn't actually complete until it fully reaches the next number.  Rounding the step causes the submodel to jump around in all sorts of weird ways.

Follow-up to #4443.
2022-08-20 10:53:50 -04:00
wookieejedi f82bf2276b Allows default shadow quality to be per mod (#4553) 2022-08-20 07:16:29 -04:00
BMagnu 61197d4c12 Add SEXP to stop an animation after loop (#4566)
* Add Animation Instance Flags

* Add SEXP barebones

* Unify and simplify animation parsing

* Clean up animation calling and use new animationlist api

* Add missing break
2022-08-20 18:44:17 +09:00
BMagnu 5a53de0eb8 Fix WeaponClass Script Condition (#4559)
* Fix Weaponclass hook

* remove bad include
2022-08-20 03:23:51 +09:00
MjnMixael 9b36fd1f6f Lua scan time (#4551)
* Add Lua access to a ship's Scan Time

* Disallow writing to the shipclass value

* Remove ship access in favor of shipclass access. Resolve read only issue.

* Cleanup and error if script attempts to set Scan Time

* Whoops. Still need to get the shipclass.
2022-08-19 07:57:56 -04:00
PhantomHoover 5ea90dcb46 Fix: Missing includes breaking Linux builds. Including the same thing twice in a row. A completely unnecessary recursive include loop. (#4556) 2022-08-19 07:50:51 -04:00
mjn-mixael 1d5c457c83 Fix issue 2022-08-19 00:28:59 -05:00
Mike N c0c7854c86 Address feedback 2022-08-18 16:01:32 -05:00
Mike N 3e884bd384 Change hook name 2022-08-18 12:57:38 -05:00
Mike N 103522b72a Implement ability to get and set a ship's persona index 2022-08-18 12:55:16 -05:00
Mike N 9a08bbf597 Add hook just before loadout parsing 2022-08-18 11:21:07 -05:00
Goober5000 34018db925 Merge pull request #4421 from Goober5000/add_missing_sexp_goals
add missing SEXP goals
2022-08-18 10:11:39 -04:00
Kiloku 843eda19dd Prevent subsystem fireWeapon scripting function from triggering an assert (#4537)
* Prevent an assert from being triggered down the line by giving a LuaError for invalid weapons

* Reword error message to match function documentation
2022-08-18 21:26:10 +09:00
Asteroth bfb77b2a00 add isPositionInFOV script function (#4540) 2022-08-18 21:25:40 +09:00
BMagnu 269bb1b221 Add scripting API and conditions for executing on server only (#4548)
* Add scripting API and conditions for executing on server only

* feedback
2022-08-18 21:13:05 +09:00
Goober5000 f68849f0d3 add missing SEXP goals
The rearm-ship and fly-to-ship goals were never set up to work with the `add-goal` SEXP.  This adds the necessary code to make them both work.
2022-08-17 23:07:38 -04:00
BMagnu 967619ab09 Add options to selectively disable shadows (#4536)
* Add options to selectively disable shadows

* Encapsulate logic

* Add comment for new functions
2022-08-18 05:42:43 +09:00
Asteroth 6e7fcdaac7 copy script function from ai helpers to plain ships (#4539) 2022-08-17 14:33:06 -04:00
Asteroth 96d6b8bc3f error if they try to change this (#4549) 2022-08-17 14:31:51 -04:00
Goober5000 3d741cea93 Merge pull request #4427 from Goober5000/ai_goal_refinement
Ai goal refinement
2022-08-17 12:24:43 -04:00
JohnAFernandez 9d6cdd9d84 Multi collision fix (ship-ship) collisions (#4542)
Change Interpolation function to bool

And calculate last position instead of just setting it

This should help FSO prevent some very odd collision issues when two ships collide
2022-08-17 09:14:07 -04:00
Goober5000 7eee0f9164 reorder code 2022-08-17 00:37:28 -04:00
Asteroth 8dc9081244 add script function for turret num fire points (#4538) 2022-08-16 12:09:30 -04:00
wookieejedi 31dc7c2269 Fix misspelled ID name for in-game options (#4541)
Thanks to MjnMixael for catching this.
2022-08-15 17:03:52 +00:00
Goober5000 0ca8add409 Merge pull request #4535 from wookieejedi/fix-null-vec-calculations
Fix False Null MOI warnings
2022-08-15 00:33:36 -04:00
wookieejedi 48cd864a59 comment update 2022-08-13 22:16:06 -04:00
Kiloku 89b369cd07 Merge pull request #4352 from Kiloku/aspect_immune_ship_flag
Add new ship flag Aspect_immune
2022-08-14 01:00:19 +01:00
kiloku f78f94c1f0 Merge branch 'master' of https://github.com/scp-fs2open/fs2open.github.com into aspect_immune_ship_flag 2022-08-13 19:33:18 -03:00
MageKing17 f2f4ade45e Automatically calculate length of flag name lists. (#4532)
`Ai_flag_names[]`, `Object_flag_names[]`, and `Ship_flag_names[]` all had an associated `#define` containing their length that had to manually be incremented whenever new flag names were added to the list. This commit instead makes the number of flags in the list be computed by simple `sizeof` division, so now adding a new entry just requires adding the entry, rather than remembering to bump a `#define`. Tested in FRED to make sure populating `OPF_SHIP_FLAG` entries still works.
2022-08-13 13:30:06 -04:00
wookieejedi 294b8bd9ec appease clang 2022-08-13 10:58:32 -04:00
wookieejedi 4074cf4c9c Fix False Null MOI warnings
In #4443, `fl_near_zero` was set to use default epsilon values in the `IS_VEC_NULL` check. In this comparison, epsilon is the wrong threshold because it used to have a much smaller threshold. The fix restores the previous definitions of `IS_VEC_NULL` and `IS_VEC_NULL_SQ_SAFE` by exposing the epsilon value as an optional parameter (similar to how `IS_NEAR_ZERO` used to work. This PR also restores `IS_VEC_NULL_SQ_SAFE` where it was replaced by `IS_VEC_NULL.`
2022-08-13 09:59:10 -04:00
wookieejedi 8420e00ee1 Allow Mods to specific default multi update speeds (#4531)
Previosuly, the default object update speed setting for new players was `High`. Many mods, such as Fate of the Galaxy, do multiplayer tests where we have to ensure players are using the highest object update speed, which is LAN. This extra step is cumbersome and prone to players' forgetfulness.

This PR allows mods to set the default multiplayer object update speed for new pilots to mitigate this issue. Tested and works as expected.
2022-08-13 08:57:18 -04:00
Kiloku f767190ce8 Merge branch 'scp-fs2open:master' into aspect_immune_ship_flag 2022-08-13 12:30:04 +01:00
Goober5000 165db5d28b Merge pull request #4400 from Goober5000/lua_frame_cleanup
clean up Lua frame handling a bit
2022-08-12 21:29:20 -04:00
Goober5000 5f1ab9bfa8 Merge pull request #4442 from Goober5000/turret_barrel_fov
add ships.tbl override for turret fov
2022-08-12 21:28:49 -04:00
kiloku da51f480ed Yet another formatting fix 2022-08-12 14:27:17 -03:00
kiloku fa494aa8ce Fix comment formatting 2022-08-12 12:52:04 -03:00
kiloku 4e29b31ed8 Merge branch 'Kiloku-aspect_immune_ship_flag' into aspect_immune_ship_flag 2022-08-12 11:45:33 -03:00
kiloku a90e95bb33 Merge branch 'aspect_immune_ship_flag' of https://github.com/Kiloku/fs2open.github.com into Kiloku-aspect_immune_ship_flag 2022-08-12 11:42:17 -03:00
Goober5000 dfeb15f8e5 more cleanup in preparation for model translation (#4443)
* more cleanup in preparation for model translation

1) Clean up stepped rotation, fixing some logic, adding safeguards for invalid values, and allowing rotations to go in the opposite direction
2) Add more specific SEXP error checking for AWACS and rotating subsystems
3) Assorted refactoring and polishing

* address feedback, plus a bit of extra cleanup
2022-08-11 08:17:17 -04:00
JohnAFernandez 7733f2b0bb Only check that ships have left the mission (#4511) 2022-08-11 08:16:08 -04:00
Goober5000 5a6b389916 Merge pull request #4518 from Goober5000/hud_gauges_ux
don't prune HUD gauges by resolution in FRED
2022-08-09 19:55:50 -04:00
Goober5000 59f0b7eddf Merge pull request #4464 from Goober5000/must_go_faster
add x500 and x1000 movement speeds
2022-08-09 19:55:36 -04:00
Goober5000 ed1bce988f only attenuate a persistent sound by engine strength if it's an engine sound (#4506)
Previously the persistent object sound management code would attenuate all script-assigned sounds by engine strength, and would not play them at all if the engine was off.  This fixes the code to only apply that logic if the sound is in fact and engine sound.
2022-08-09 10:32:58 -04:00
Asteroth 53cb148180 bugfix for salvo mode and forced target (#4508) 2022-08-09 10:32:28 -04:00
JohnAFernandez f2f00cdb6e Bump to 22.3 (#4529) 2022-08-09 07:36:19 -04:00
MageKing17 7bd18faafa Add optional suffixes to add to inherited damage types.
This allows you to automatically append, for example, "-shock" to the damage type to make the shockwave damage type, so a weapon with "Heavy" damage type would automatically have its shockwave assigned the damage type "Heavy-shock".
2022-08-06 23:04:01 -07:00
MageKing17 9869f2f8d5 Allow shockwaves to have a default damage type.
This includes both separate defaults for dinky and non-dinky shockwaves, as well as automatic inheritance of the parent weapon's damage type (and if both are enabled simultaneously, the default is only used if there's nothing to inherit because the parent weapon doesn't set a damage type).
2022-08-06 23:04:01 -07:00
MageKing17 372f96cfc0 Const-correctness for damage_type_add() and damage_type_get_idx().
Neither of these modify their input, so the argument not being `const` was just stopping `const` strings from being used as input.
2022-08-06 23:04:01 -07:00
Tyler Blount 8038422eda Capture empty strings too 2022-08-06 16:21:18 -07:00
Tyler Blount dca5d84ae6 Merge pull request #4502 from Kiloku/markdown-testing
Preliminary Changelog for 22.2.0
2022-08-06 15:22:35 -07:00
Kiloku c5bd3ba96e Update Changelog.md 2022-08-05 09:31:30 -03:00
Kiloku f75837922e Formatting fix 2022-08-05 09:30:56 -03:00
Kiloku 71fc9cc37b Update Changelog.md 2022-08-05 09:25:19 -03:00
JohnAFernandez 6359cb973c Merge pull request #4526 from JohnAFernandez/Allow-OBJ-GHOST-in-Assert
Add OBJ_GHOST to this assert and add comments
2022-08-04 19:59:06 -04:00
John Fernandez bafa6d9896 Add OBJ_GHOST to this assert and add comments
This assert catches any weapon's parent object type, which can include OBJ_GHOST, which is a dead player.  OBJ_GHOST is being encountered in this function using BPC when the player dies via beam weapon and (likely) when the players weapon are hitting an enemy ship at the same time.  Because the player ship can damage an enemy after it is dead, allow for that in this function.
2022-08-03 10:34:39 -04:00
Kiloku 7f1310bef5 Update Changelog.md 2022-08-03 09:19:55 -03:00
Goober5000 d48cab0fce mission-specific cutscene enhancements
Add `$Post-debriefing Cutscene:`, and make `$Post-briefing Cutscene:` a synonym for `$Pre-game Cutscene:`.
2022-08-01 20:58:19 -04:00
Goober5000 8c7f9e5e9e don't prune HUD gauges by resolution in FRED
FRED needs to work with any HUD gauge in the table, so don't prune any based on resolution.  Fixes #4517.

This also improves checking for duplicate names in the FRED gauge list.
2022-07-30 17:31:48 -04:00
Kiloku 6095e2ae1c Hopefully final changelog version for 22.2.0! 2022-07-28 07:42:59 -03:00
Kiloku f24a8e6876 Add changes up to RC8 2022-07-25 08:51:54 -03:00
Kiloku a1973e323e Move item to the correct category. 2022-07-25 08:51:27 -03:00
Kiloku 72d9d86008 Address feedback 2022-07-25 08:42:14 -03:00
Kiloku fec0c7a3b6 Merge branch 'scp-fs2open:master' into markdown-testing 2022-07-25 12:37:45 +01:00
Kiloku 4619ab6b59 Minor grammar, spelling and formatting fixes 2022-07-20 11:32:15 -03:00
Kiloku 4070013d8a Add changes up to RC7 2022-07-20 11:08:23 -03:00
Kiloku c8fac05fbe Update Changelog.md 2022-07-20 10:23:52 -03:00
Kiloku 0bc03a1dab Improve changelog from feedback 2022-07-20 10:21:40 -03:00
Kiloku b1c0793bff Preliminary Changelog for 22.2.0 2022-07-19 19:15:09 -03:00
Adam Leach 92d4820995 Fix envmap shading transparent pixels. 2022-07-16 17:46:41 +01:00
Adam Leach 6b6b58fa9d specColor is already premultiplied by aoFactors.y 2022-07-13 23:38:14 +01:00
Adam Leach b8f0b8ec05 optimisation. with envmap, halfVec == normal by definition. 2022-07-13 23:22:23 +01:00
Adam Leach a8f1f668c1 Fixed bug where anti-glint could be too strong 2022-07-13 23:12:35 +01:00
Adam Leach d2d7f17385 moved anti-glint so IBL glint prevented too. 2022-07-13 23:12:11 +01:00
John Fernandez 4b23a1bd44 Feedback 2022-07-12 21:33:16 -04:00
John Fernandez 9f40a341cc Allow multilock between traitors
Use the proper attacking function here, as traitors need to be able to attack each other in dogfight mode.
2022-07-12 21:24:30 -04:00
Goober5000 826dfd01fc clean up Lua frame handling a bit
There's no need to keep all this infrastructure to run every frame for a barely used situation.  This cleans it up a bit and does the position reset in the actual drawString function.
2022-07-08 18:59:10 -04:00
Goober5000 67d8d56dd0 add a message if the copy detects inconsistent personas 2022-07-08 18:55:08 -04:00
Goober5000 b95e04743e restrict to wingman personas rather than fighter/bombers 2022-07-08 00:30:10 -04:00
Goober5000 495010275b add helpful dialog box 2022-07-06 12:08:38 -04:00
Goober5000 4b686359ec tweak dialog and add note 2022-07-05 22:53:26 -04:00
Goober5000 09e72fe917 bugfixes 2022-07-05 22:43:58 -04:00
Goober5000 7c019c4157 implement functions 2022-07-05 22:43:58 -04:00
Goober5000 bc44909501 constify 2022-07-05 21:14:30 -04:00
Goober5000 f942837785 stub out functions 2022-07-05 20:56:03 -04:00
Goober5000 72355be198 FRED UI for new voice acting buttons 2022-07-05 20:49:27 -04:00
Adam Leach af1da1c93f Potential fix for warp portal envmap lighting? 2022-07-04 10:42:31 +01:00
Goober5000 d0d22f04a7 add x500 and x1000 movement speeds
As requested by Asteroth.
2022-07-02 13:26:27 -04:00
Goober5000 abb81c6eaa add ships.tbl override for turret fov
Add `$Turret Barrel FOV:` option for turrets in ships.tbl, as requested by CP5670.
2022-06-25 18:42:50 -04:00
Goober5000 5b87f62d6a add optional distance to ai-stay-near-ship 2022-06-19 19:04:45 -04:00
Goober5000 b0057e959d move ai goal stuff to aigoals.h 2022-06-19 19:04:44 -04:00
Adam Leach 5e4d6cc5de Implement IBL based off envmaps
Fixed environment map rendering


shift fresnel term to match ordering of ComputeGGX, document shader code.


Envmaps: Use tangentMatrix to build local coordinate system 


Fixed geometry self-shading calcs to improve shading of rough surfaces.


Cite paper correctly


optimsed env sampling 


Put envmap face generation a loop to make it easier to read


Precalculate points on circle for even faster envmap sampling..


Guard against NaNs


Revert to simpler envmap calcs, significantly faster on slower GPUs.


typo


We don't need the sample points any more.


Diffuse IBL shading


Fix gamma issues in envmap rendering


AO term on envmaps.


fix lab crash with retail data


Always render envmaps - PBR shouldn't care if a shine/specmap exists.
2022-06-18 19:57:54 +01:00
Adam Leach 5f4566620f UE4 based shaders
Better approximation in geometry/visibility term
Fixed Fresnel/Schlick model to be dependent on view in line with learn openGL PBR theory
introduce energy conservation term for diffuse rendering

Just use specColor instead of trying to figure out metalness.


Pull out g1 function for reuse


UE4 based shaders

Better approximation in geometry/visibility term
Fixed Fresnel/Schlick model to be dependent on view in line with learn openGL PBR theory
introduce energy conservation term for diffuse rendering

Just use specColor instead of trying to figure out metalness.


Pull out g1 function for reuse
2022-06-18 19:57:12 +01:00
David Gibson e78157908d fixed some mishandling of lighting modifiers. 2022-06-12 18:51:08 -05:00
The Force 16d32f3730 Fix text entry
Try and fix editable dropdowns
Change  pass-by value rather than refrence
2022-06-12 02:24:19 +01:00
The Force 1e7cdbda47 Move All Ship Editor file so subfolder
Move All Ship Editor file so subfolder so it easier to navigate
2022-06-11 00:02:42 +01:00
The Force 7b04b3b27a Missed bit 2022-06-10 23:27:14 +01:00
The Force 13f3322ae8 Address Feedback 2022-06-10 23:24:34 +01:00
David Gibson 70b9c34f1a move techroom/selection/breifing 'room' lights to a common function and
augment lighting setup for current rendering
2022-06-04 20:40:12 -05:00
kiloku 69d3f47e34 Re-added missing linebreak in ship flag list 2022-06-04 14:02:54 -03:00
kiloku ecbebfab00 Fix some undesired whitespace changes 2022-06-04 13:26:28 -03:00
kiloku aecc626634 Add new ship flag Aspect_immune which stops ships from being locked onto by aspect seeking weapons 2022-06-04 12:54:16 -03:00
David Gibson 13180db544 Merge remote-tracking branch 'origin/master' into light-flags-rubicon-2 2022-06-03 15:50:26 -05:00
David Gibson a7b59b4620 further post-rebase repair of light flags command line and leftover specular 2022-06-03 15:39:08 -05:00
David Gibson ee72bcec69 cleanup of leftover/post-rebase specular references 2022-06-03 14:07:57 -05:00
David Gibson cfa7d1736b Removed specular light color as a separate value in the uniform buffers. 2022-06-03 13:27:06 -05:00
David Gibson 252d0cb56a handled specular sun depreciation and general removal of specular value handling 2022-06-03 13:27:05 -05:00
David Gibson 4e835bafdb revise command-line and emissive handling 2022-06-03 13:26:29 -05:00
David Gibson 33f8109dfb make static some functions that can be static 2022-06-03 13:26:05 -05:00
David Gibson 89e17ec2f1 cleanup unused new function 2022-06-03 13:26:05 -05:00
David Gibson d73f8bf968 Wire lab up to new lighting controls, and provide backwards-compatible defaults for emissive. 2022-06-03 13:26:05 -05:00
David Gibson 6ee2699f51 Switched over to new command line arguments 2022-06-03 13:26:05 -05:00
David Gibson 23a46dcb65 Applying directional brightness profile value, disconnected spec flags and made specular light always equal to diffuse light 2022-06-03 13:22:54 -05:00
The Force 9a04166d9f Add comment to address feedback
Add comment
2022-05-25 16:13:49 +01:00
The Force f86a869509 Change class to dialog rather than widget 2022-05-25 16:13:49 +01:00
The Force e4cadff3f5 const initial status editor
Finish Consting
2022-05-25 16:13:49 +01:00
The Force 465c8cb2d4 More Doxy and clarify function names
Finish doxy ship editor
2022-05-25 16:13:49 +01:00
The Force 9acc16dde3 Properly encapsulate data 2022-05-25 16:13:49 +01:00
The Force 6fc5f2e979 Fix crash bug with cargo 2022-05-25 16:13:49 +01:00
The Force a6665320e9 Add clang fixies that accidently got removed 2022-05-25 16:13:49 +01:00
The Force 9100cc9bc5 Const Parameters
Properly privatise and const model data
2022-05-25 16:13:49 +01:00
The Force 6024b0026f Convert to unique_ptr 2022-05-18 18:59:53 +01:00
The Force 4320760e8e Merge branch 'master' into fix/shipEditorCleanup 2022-05-18 18:16:26 +01:00
The Force a20afd147e Doxygen Ship Editor 2022-05-17 19:27:49 +01:00
The Force cea490ab62 Constify Ship Editor
Add missed lines
2022-05-17 17:42:56 +01:00
The Force 20faa3083d Merge branch 'master' into fix/shipEditorCleanup 2022-05-17 15:18:57 +01:00
The Force 65ef9e3ac4 Fix references to changed name 2022-05-15 13:34:53 +01:00
The Force 42e2870410 Merge branch 'feature/shipTBLViewer' into fix/shipEditorCleanup 2022-05-15 13:32:56 +01:00
The Force ca3bc07959 More descriptive Name 2022-05-15 13:31:15 +01:00
The Force f21ac8fd04 Clean-up Special stats dialog 2022-05-04 03:43:17 +01:00
The Force cb36670ce0 Clang-tidy 2022-05-04 03:39:01 +01:00
The Force bc2be1cbdf Clean-up Player orders dialog 2022-05-04 03:36:06 +01:00
The Force fa4c49e951 Clean-up Texture Replacement 2022-05-04 03:23:34 +01:00
The Force b6e259e374 Clean-up Flags Dialog 2022-05-04 03:05:52 +01:00
The Force ab307fe4a6 Clean-up Initial Status Dialog 2022-05-04 02:58:41 +01:00
The Force 9e8982edb4 GCC Appeasement 2022-05-01 20:22:08 +01:00
The Force 9afe340f46 Cleqanup Goals Dialog 2022-05-01 20:05:24 +01:00
The Force c07a679d87 Add TBL VIewer 2022-05-01 19:20:11 +01:00
The Force ba2ef3cb9d Fix newtype loading 2022-05-01 18:45:27 +01:00
The Force 30537a2ce9 Clang fix 2022-04-30 23:56:04 +01:00
The Force 328d3cce8c Try to avoid trigraph error 2022-04-30 23:43:18 +01:00
The Force b18f9ecee0 More GCC 2022-04-30 23:41:04 +01:00
The Force a5dbc27018 Cater to gcc 2022-04-30 23:33:58 +01:00
The Force c18ae68d65 Missed this 2022-04-30 23:29:29 +01:00
The Force 6c22137075 Change to new dialog loading style 2022-04-30 23:27:26 +01:00
The Force 41a3d9561d Add Tooltips 2022-04-30 23:16:04 +01:00
The Force e3228c0241 Fix Crash Bug 2022-04-30 18:02:49 +01:00
The Force b63da42715 Memory Cleanup 2022-04-30 16:44:19 +01:00
The Force 9d6f729f81 Add TBL Viewer 2022-04-30 14:48:00 +01:00
755 changed files with 130776 additions and 20801 deletions

No files matched your search

+54 -53
View File
@@ -17,20 +17,20 @@ jobs:
runs-on: ubuntu-latest
container: ghcr.io/scp-fs2open/linux_build:sha-8a6bbbe
steps:
- name: Cache Qt
id: cache-qt-lin
uses: actions/cache@v1
with:
path: ${{ github.workspace }}/../Qt
key: ${{ runner.os }}-QtCache-${{ env.QT_VERSION }}
- name: Install Qt
uses: jurplel/install-qt-action@v2
with:
version: ${{ env.QT_VERSION }}
dir: ${{ github.workspace }}/..
cached: ${{ steps.cache-qt-lin.outputs.cache-hit }}
setup-python: 'false'
aqtversion: ==1.1.3
# - name: Cache Qt
# id: cache-qt-lin
# uses: actions/cache@v1
# with:
# path: ${{ github.workspace }}/../Qt
# key: ${{ runner.os }}-QtCache-${{ env.QT_VERSION }}
# - name: Install Qt
# uses: jurplel/install-qt-action@v2
# with:
# version: ${{ env.QT_VERSION }}
# dir: ${{ github.workspace }}/..
# cached: ${{ steps.cache-qt-lin.outputs.cache-hit }}
# setup-python: 'false'
# aqtversion: ==1.1.3
- uses: actions/checkout@v1
name: Checkout
@@ -109,30 +109,30 @@ jobs:
name: Checkout
with:
submodules: true
- name: Cache Qt
id: cache-qt-win
uses: actions/cache@v1
with:
path: ${{ github.workspace }}/../Qt
key: ${{ runner.os }}-${{ matrix.arch }}-QtCache-${{ env.QT_VERSION }}
- name: Install Qt (32 bit)
uses: jurplel/install-qt-action@v2
if: ${{ matrix.arch == 'Win32' }}
with:
version: ${{ env.QT_VERSION }}
dir: ${{ github.workspace }}/..
arch: win32_msvc2017
cached: ${{ steps.cache-qt-win.outputs.cache-hit }}
aqtversion: ==0.8
- name: Install Qt (64 bit)
uses: jurplel/install-qt-action@v2
if: ${{ matrix.arch == 'x64' }}
with:
version: ${{ env.QT_VERSION }}
dir: ${{ github.workspace }}/..
arch: win64_msvc2017_64
cached: ${{ steps.cache-qt-win.outputs.cache-hit }}
aqtversion: ==0.8
# - name: Cache Qt
# id: cache-qt-win
# uses: actions/cache@v1
# with:
# path: ${{ github.workspace }}/../Qt
# key: ${{ runner.os }}-${{ matrix.arch }}-QtCache-${{ env.QT_VERSION }}
# - name: Install Qt (32 bit)
# uses: jurplel/install-qt-action@v2
# if: ${{ matrix.arch == 'Win32' }}
# with:
# version: ${{ env.QT_VERSION }}
# dir: ${{ github.workspace }}/..
# arch: win32_msvc2017
# cached: ${{ steps.cache-qt-win.outputs.cache-hit }}
# aqtversion: ==0.8
# - name: Install Qt (64 bit)
# uses: jurplel/install-qt-action@v2
# if: ${{ matrix.arch == 'x64' }}
# with:
# version: ${{ env.QT_VERSION }}
# dir: ${{ github.workspace }}/..
# arch: win64_msvc2017_64
# cached: ${{ steps.cache-qt-win.outputs.cache-hit }}
# aqtversion: ==0.8
- name: Configure CMake
env:
@@ -146,7 +146,7 @@ jobs:
cmake -DCMAKE_INSTALL_PREFIX="$(pwd)/install" -DFSO_USE_SPEECH="ON" \
-DFSO_USE_VOICEREC="ON" -DMSVC_SIMD_INSTRUCTIONS="$SIMD" \
-DFSO_BUILD_QTFRED=ON -DFSO_BUILD_TESTS=ON \
-DFSO_BUILD_QTFRED=OFF -DFSO_BUILD_TESTS=ON \
-DFSO_INSTALL_DEBUG_FILES="ON" -A "$ARCHITECTURE" \
-G "Visual Studio 16 2019" -T "v142" ..
- name: Compile
@@ -220,20 +220,21 @@ jobs:
name: Mac
runs-on: macos-latest
steps:
- name: Cache Qt
id: cache-qt-mac
uses: actions/cache@v1
with:
path: ${{ github.workspace }}/../Qt
key: ${{ runner.os }}-QtCache-${{ env.QT_VERSION }}
- name: Install Qt
uses: jurplel/install-qt-action@v2
with:
version: ${{ env.QT_VERSION }}
dir: ${{ github.workspace }}/..
cached: ${{ steps.cache-qt-mac.outputs.cache-hit }}
setup-python: 'false'
aqtversion: ==1.1.3
# - name: Cache Qt
# id: cache-qt-mac
# uses: actions/cache@v1
# with:
# path: ${{ github.workspace }}/../Qt
# key: ${{ runner.os }}-QtCache-${{ env.QT_VERSION }}
# - name: Install Qt
# uses: jurplel/install-qt-action@v2
# with:
# version: ${{ env.QT_VERSION }}
# dir: ${{ github.workspace }}/..
# cached: ${{ steps.cache-qt-mac.outputs.cache-hit }}
# setup-python: 'false'
# aqtversion: ==1.1.3
# py7zrversion: '==0.19.*'
- uses: actions/checkout@v1
name: Checkout
+136 -43
View File
@@ -46,9 +46,9 @@ jobs:
runs-on: ubuntu-latest
container: ghcr.io/scp-fs2open/linux_build:sha-8a6bbbe
steps:
- name: Cache Qt
id: cache-qt-lin
uses: actions/cache@v1
# - name: Cache Qt
# id: cache-qt-lin
# uses: actions/cache@v1
# cache the Qt directory so we don't have to reinstall it every time
# cache.inputs:
# path - A list of files, directories, and wildcard patterns to cache and restore. See @actions/glob for supported patterns.
@@ -56,11 +56,11 @@ jobs:
# restore-keys - An ordered list of keys to use for restoring the cache if no cache hit occurred for key
# cache.outputs:
# cache-hit true when an exact match was found for the key, false otherwise.
with:
path: ${{ github.workspace }}/../Qt
key: ${{ runner.os }}-QtCache-${{ env.QT_VERSION }}
- name: Install Qt
uses: jurplel/install-qt-action@v2
# with:
# path: ${{ github.workspace }}/../Qt
# key: ${{ runner.os }}-QtCache-${{ env.QT_VERSION }}
# - name: Install Qt
# uses: jurplel/install-qt-action@v2
# installs Qt in the action workflow
# install-qt-action.inputs:
# version desired qt version to install
@@ -81,12 +81,12 @@ jobs:
# Qt5_DIR / Qt6_DIR
# Qt bin dir appended to PATH
# QT_PLUGIN_PATH, QML2_IMPORT_PATH, PKG_CONFIG_PATH, LD_LIBRARY_PATH
with:
version: ${{ env.QT_VERSION }}
dir: ${{ github.workspace }}/..
cached: ${{ steps.cache-qt-lin.outputs.cache-hit }}
setup-python: 'false'
aqtversion: ==1.1.3
# with:
# version: ${{ env.QT_VERSION }}
# dir: ${{ github.workspace }}/..
# cached: ${{ steps.cache-qt-lin.outputs.cache-hit }}
# setup-python: 'false'
# aqtversion: ==1.1.3
- uses: actions/checkout@v1
# checks-out your repository under $GITHUB_WORKSPACE, so your workflow can access it.
@@ -186,33 +186,33 @@ jobs:
name: Checkout
with:
submodules: true
- name: Cache Qt
# Cache Qt
id: cache-qt-win
uses: actions/cache@v1
with:
path: ${{ github.workspace }}/../Qt
key: ${{ runner.os }}-${{ matrix.arch }}-QtCache-${{ env.QT_VERSION }}
- name: Install Qt (32 bit)
# Install Qt 32bit if matrix.arch == Win32
uses: jurplel/install-qt-action@v2
if: ${{ matrix.arch == 'Win32' }}
with:
version: ${{ env.QT_VERSION }}
dir: ${{ github.workspace }}/..
arch: win32_msvc2017
cached: ${{ steps.cache-qt-win.outputs.cache-hit }}
aqtversion: ==0.8
- name: Install Qt (64 bit)
# Install Qt 64bit if matrix.arch == x64
uses: jurplel/install-qt-action@v2
if: ${{ matrix.arch == 'x64' }}
with:
version: ${{ env.QT_VERSION }}
dir: ${{ github.workspace }}/..
arch: win64_msvc2017_64
cached: ${{ steps.cache-qt-win.outputs.cache-hit }}
aqtversion: ==0.8
# - name: Cache Qt
# # Cache Qt
# id: cache-qt-win
# uses: actions/cache@v1
# with:
# path: ${{ github.workspace }}/../Qt
# key: ${{ runner.os }}-${{ matrix.arch }}-QtCache-${{ env.QT_VERSION }}
# - name: Install Qt (32 bit)
# # Install Qt 32bit if matrix.arch == Win32
# uses: jurplel/install-qt-action@v2
# if: ${{ matrix.arch == 'Win32' }}
# with:
# version: ${{ env.QT_VERSION }}
# dir: ${{ github.workspace }}/..
# arch: win32_msvc2017
# cached: ${{ steps.cache-qt-win.outputs.cache-hit }}
# aqtversion: ==0.8
# - name: Install Qt (64 bit)
# # Install Qt 64bit if matrix.arch == x64
# uses: jurplel/install-qt-action@v2
# if: ${{ matrix.arch == 'x64' }}
# with:
# version: ${{ env.QT_VERSION }}
# dir: ${{ github.workspace }}/..
# arch: win64_msvc2017_64
# cached: ${{ steps.cache-qt-win.outputs.cache-hit }}
# aqtversion: ==0.8
- name: Configure CMake
env:
@@ -226,7 +226,7 @@ jobs:
cmake -DCMAKE_INSTALL_PREFIX="$(pwd)/install" -DFSO_USE_SPEECH="ON" \
-DFSO_USE_VOICEREC="ON" -DMSVC_SIMD_INSTRUCTIONS="$SIMD" \
-DFSO_BUILD_QTFRED=ON -DFSO_BUILD_TESTS=ON \
-DFSO_BUILD_QTFRED=OFF -DFSO_BUILD_TESTS=ON \
-DFSO_INSTALL_DEBUG_FILES="ON" -A "$ARCHITECTURE" \
-G "Visual Studio 16 2019" -T "v142" ..
- name: Compile
@@ -310,11 +310,104 @@ jobs:
${{ steps.generate_package.outputs.package_path }}
${{ steps.generate_package.outputs.debug_path }}
build_mac:
strategy:
matrix:
configuration: [FastDebug, Release]
compiler: [clang]
arch: [x86_64]
name: Mac
needs: create_release
runs-on: macos-latest
steps:
# - name: Cache Qt
# id: cache-qt-mac
# uses: actions/cache@v1
# with:
# path: ${{ github.workspace }}/../Qt
# key: ${{ runner.os }}-QtCache-${{ env.QT_VERSION }}
# - name: Install Qt
# uses: jurplel/install-qt-action@v2
# with:
# version: ${{ env.QT_VERSION }}
# dir: ${{ github.workspace }}/..
# cached: ${{ steps.cache-qt-mac.outputs.cache-hit }}
# setup-python: 'false'
# aqtversion: ==1.1.3
- uses: actions/checkout@v1
name: Checkout
with:
submodules: true
fetch-depth: 0
- name: Configure CMake
env:
CONFIGURATION: ${{ matrix.configuration }}
COMPILER: ${{ matrix.compiler }}
ARCHITECTURE: ${{ matrix.arch }}
JOB_CMAKE_OPTIONS: ${{ matrix.cmake_options }}
run: $GITHUB_WORKSPACE/ci/linux/configure_cmake.sh
- name: Compile
working-directory: ./build
run: LD_LIBRARY_PATH=$Qt5_DIR/lib:$LD_LIBRARY_PATH ninja all
- name: Run Tests
working-directory: ./build
env:
CONFIGURATION: ${{ matrix.configuration }}
XDG_RUNTIME_DIR: /root
run: $GITHUB_WORKSPACE/ci/linux/run_tests.sh
- name: Package build result
working-directory: ./build
run: cd bin && tar -cvzf macos-build.tar *.app
- name: Upload build result
uses: actions/upload-artifact@v2
with:
name: mac-${{ matrix.configuration }}
path: ${{ github.workspace }}/build/bin/macos-build.tar
mac_zip:
name: Build Mac distribution zip
needs: build_mac
runs-on: ubuntu-latest
container: ghcr.io/scp-fs2open/sftp_upload:sha-748b19d
steps:
- uses: actions/checkout@v2
name: Checkout
with:
submodules: true
fetch-depth: '0'
ref: '${{ github.ref }}'
- name: Download Release builds
uses: actions/download-artifact@v2
with:
name: mac-Release
path: builds
- name: Download FastDebug builds
uses: actions/download-artifact@v2
with:
name: mac-FastDebug
path: builds
- name: Create Distribution package
id: generate_package
working-directory: ./builds
run: $GITHUB_WORKSPACE/ci/linux/create_dist_pack.sh Mac
- name: Upload result package
uses: actions/upload-artifact@v2
with:
name: ${{ steps.generate_package.outputs.package_name }}
path: ${{ steps.generate_package.outputs.package_path }}
- name: Publish result package
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: ${{ steps.generate_package.outputs.package_path }}
post_build:
name: Post builds to Nebula and Forum
needs: [linux_zip, windows_zip]
needs: [linux_zip, windows_zip, mac_zip]
uses: ./.github/workflows/post-build-release.yaml
with:
linux_result: ${{ needs.linux_zip.result }}
windows_result: ${{ needs.windows_zip.result }}
mac_result: ${{ needs.mac_zip.result }}
releaseTag: ${{ github.ref_name }}
+54 -53
View File
@@ -17,20 +17,20 @@ jobs:
runs-on: ubuntu-latest
container: ghcr.io/scp-fs2open/linux_build:sha-8a6bbbe
steps:
- name: Cache Qt
id: cache-qt-lin
uses: actions/cache@v1
with:
path: ${{ github.workspace }}/../Qt
key: ${{ runner.os }}-QtCache-${{ env.QT_VERSION }}
- name: Install Qt
uses: jurplel/install-qt-action@v2
with:
version: ${{ env.QT_VERSION }}
dir: ${{ github.workspace }}/..
cached: ${{ steps.cache-qt-lin.outputs.cache-hit }}
setup-python: 'false'
aqtversion: ==1.1.3
# - name: Cache Qt
# id: cache-qt-lin
# uses: actions/cache@v1
# with:
# path: ${{ github.workspace }}/../Qt
# key: ${{ runner.os }}-QtCache-${{ env.QT_VERSION }}
# - name: Install Qt
# uses: jurplel/install-qt-action@v2
# with:
# version: ${{ env.QT_VERSION }}
# dir: ${{ github.workspace }}/..
# cached: ${{ steps.cache-qt-lin.outputs.cache-hit }}
# setup-python: 'false'
# aqtversion: ==1.1.3
- uses: actions/checkout@v1
name: Checkout
@@ -122,30 +122,30 @@ jobs:
[[ "${{ github.ref }}" =~ ^refs\/heads\/test\/(.*)$ ]]
# Override the revision string so that the builds are named correctly
echo "set(FSO_VERSION_REVISION_STR ${BASH_REMATCH[1]})" > "version_override.cmake"
- name: Cache Qt
id: cache-qt-win
uses: actions/cache@v1
with:
path: ${{ github.workspace }}/../Qt
key: ${{ runner.os }}-${{ matrix.arch }}-QtCache-${{ env.QT_VERSION }}
- name: Install Qt (32 bit)
uses: jurplel/install-qt-action@v2
if: ${{ matrix.arch == 'Win32' }}
with:
version: ${{ env.QT_VERSION }}
dir: ${{ github.workspace }}/..
arch: win32_msvc2017
cached: ${{ steps.cache-qt-win.outputs.cache-hit }}
aqtversion: ==0.8
- name: Install Qt (64 bit)
uses: jurplel/install-qt-action@v2
if: ${{ matrix.arch == 'x64' }}
with:
version: ${{ env.QT_VERSION }}
dir: ${{ github.workspace }}/..
arch: win64_msvc2017_64
cached: ${{ steps.cache-qt-win.outputs.cache-hit }}
aqtversion: ==0.8
# - name: Cache Qt
# id: cache-qt-win
# uses: actions/cache@v1
# with:
# path: ${{ github.workspace }}/../Qt
# key: ${{ runner.os }}-${{ matrix.arch }}-QtCache-${{ env.QT_VERSION }}
# - name: Install Qt (32 bit)
# uses: jurplel/install-qt-action@v2
# if: ${{ matrix.arch == 'Win32' }}
# with:
# version: ${{ env.QT_VERSION }}
# dir: ${{ github.workspace }}/..
# arch: win32_msvc2017
# cached: ${{ steps.cache-qt-win.outputs.cache-hit }}
# aqtversion: ==0.8
# - name: Install Qt (64 bit)
# uses: jurplel/install-qt-action@v2
# if: ${{ matrix.arch == 'x64' }}
# with:
# version: ${{ env.QT_VERSION }}
# dir: ${{ github.workspace }}/..
# arch: win64_msvc2017_64
# cached: ${{ steps.cache-qt-win.outputs.cache-hit }}
# aqtversion: ==0.8
- name: Configure CMake
env:
@@ -159,7 +159,7 @@ jobs:
cmake -DCMAKE_INSTALL_PREFIX="$(pwd)/install" -DFSO_USE_SPEECH="ON" \
-DFSO_USE_VOICEREC="ON" -DMSVC_SIMD_INSTRUCTIONS="$SIMD" \
-DFSO_BUILD_QTFRED=ON -DFSO_BUILD_TESTS=ON \
-DFSO_BUILD_QTFRED=OFF -DFSO_BUILD_TESTS=ON \
-DFSO_INSTALL_DEBUG_FILES="ON" -A "$ARCHITECTURE" \
-G "Visual Studio 16 2019" -T "v142" ..
- name: Compile
@@ -234,20 +234,21 @@ jobs:
name: Mac
runs-on: macos-latest
steps:
- name: Cache Qt
id: cache-qt-mac
uses: actions/cache@v1
with:
path: ${{ github.workspace }}/../Qt
key: ${{ runner.os }}-QtCache-${{ env.QT_VERSION }}
- name: Install Qt
uses: jurplel/install-qt-action@v2
with:
version: ${{ env.QT_VERSION }}
dir: ${{ github.workspace }}/..
cached: ${{ steps.cache-qt-mac.outputs.cache-hit }}
setup-python: 'false'
aqtversion: ==1.1.3
# - name: Cache Qt
# id: cache-qt-mac
# uses: actions/cache@v1
# with:
# path: ${{ github.workspace }}/../Qt
# key: ${{ runner.os }}-QtCache-${{ env.QT_VERSION }}
# - name: Install Qt
# uses: jurplel/install-qt-action@v2
# with:
# version: ${{ env.QT_VERSION }}
# dir: ${{ github.workspace }}/..
# cached: ${{ steps.cache-qt-mac.outputs.cache-hit }}
# setup-python: 'false'
# aqtversion: ==1.1.3
# py7zrversion: '==0.19.*'
- uses: actions/checkout@v1
name: Checkout
+14 -14
View File
@@ -27,20 +27,20 @@ jobs:
runs-on: ubuntu-latest
container: ghcr.io/scp-fs2open/linux_build:sha-8a6bbbe
steps:
- name: Cache Qt
id: cache-qt-lin
uses: actions/cache@v1
with:
path: ${{ github.workspace }}/../Qt
key: ${{ runner.os }}-QtCache-${{ env.QT_VERSION }}
- name: Install Qt
uses: jurplel/install-qt-action@v2
with:
version: ${{ env.QT_VERSION }}
dir: ${{ github.workspace }}/..
cached: ${{ steps.cache-qt-lin.outputs.cache-hit }}
setup-python: 'false'
aqtversion: ==1.1.3
# - name: Cache Qt
# id: cache-qt-lin
# uses: actions/cache@v1
# with:
# path: ${{ github.workspace }}/../Qt
# key: ${{ runner.os }}-QtCache-${{ env.QT_VERSION }}
# - name: Install Qt
# uses: jurplel/install-qt-action@v2
# with:
# version: ${{ env.QT_VERSION }}
# dir: ${{ github.workspace }}/..
# cached: ${{ steps.cache-qt-lin.outputs.cache-hit }}
# setup-python: 'false'
# aqtversion: ==1.1.3
- uses: actions/checkout@v1
name: Checkout
+14 -1
View File
@@ -10,6 +10,9 @@ on:
windows_result: # job.result
required: true
type: string
mac_result: # job.result
required: true
type: string
releaseTag:
required: true
type: string
@@ -55,6 +58,15 @@ jobs:
env:
LINUX_RESULT: ${{ inputs.linux_result }}
WINDOWS_RESULT: ${{ inputs.windows_result }}
MAC_RESULT: ${{ inputs.mac_result }}
GITHUB_REPO: ${{ github.repository }} # repo this workflow was called from
INDIEGAMES_USER: ${{ secrets.INDIEGAMES_USER }}
INDIEGAMES_SSHPASS: ${{ secrets.INDIEGAMES_PASSWORD }}
NEBULA_USER: ${{ secrets.NEBULA_USER }}
NEBULA_PASSWORD: ${{ secrets.NEBULA_PASSWORD }}
HLP_API: ${{ secrets.HLP_API }}
HLP_KEY: ${{ secrets.HLP_KEY }}
RELEASE_TAG: ${{ inputs.releaseTag }}
run: python ci/post/main.py release
- name: Post Builds (Manual trigger)
@@ -63,7 +75,8 @@ jobs:
env:
LINUX_RESULT: success
WINDOWS_RESULT: success
MAC_RESULT: success
run: |
echo "releaseTag= ${{ env.RELEASE_TAG }}"
echo "repository= ${{ github.repository }}"
python ci/post/main.py release
python ci/post/main.py release
+54 -53
View File
@@ -24,20 +24,20 @@ jobs:
runs-on: ubuntu-latest
container: ghcr.io/scp-fs2open/linux_build:sha-8a6bbbe
steps:
- name: Cache Qt
id: cache-qt-lin
uses: actions/cache@v1
with:
path: ${{ github.workspace }}/../Qt
key: ${{ runner.os }}-QtCache-${{ env.QT_VERSION }}
- name: Install Qt
uses: jurplel/install-qt-action@v2
with:
version: ${{ env.QT_VERSION }}
dir: ${{ github.workspace }}/..
cached: ${{ steps.cache-qt-lin.outputs.cache-hit }}
setup-python: 'false'
aqtversion: ==1.1.3
# - name: Cache Qt
# id: cache-qt-lin
# uses: actions/cache@v1
# with:
# path: ${{ github.workspace }}/../Qt
# key: ${{ runner.os }}-QtCache-${{ env.QT_VERSION }}
# - name: Install Qt
# uses: jurplel/install-qt-action@v2
# with:
# version: ${{ env.QT_VERSION }}
# dir: ${{ github.workspace }}/..
# cached: ${{ steps.cache-qt-lin.outputs.cache-hit }}
# setup-python: 'false'
# aqtversion: ==1.1.3
- uses: actions/checkout@v1
name: Checkout
@@ -89,30 +89,30 @@ jobs:
name: Checkout
with:
submodules: true
- name: Cache Qt
id: cache-qt-win
uses: actions/cache@v1
with:
path: ${{ github.workspace }}/../Qt
key: ${{ runner.os }}-${{ matrix.arch }}-QtCache-${{ env.QT_VERSION }}
- name: Install Qt (32 bit)
uses: jurplel/install-qt-action@v2
if: ${{ matrix.compiler == 'MSVC' && matrix.arch == 'Win32' }}
with:
version: ${{ env.QT_VERSION }}
dir: ${{ github.workspace }}/..
arch: win32_msvc2017
cached: ${{ steps.cache-qt-win.outputs.cache-hit }}
aqtversion: ==0.8
- name: Install Qt (64 bit)
uses: jurplel/install-qt-action@v2
if: ${{ matrix.compiler == 'MSVC' && matrix.arch == 'x64' }}
with:
version: ${{ env.QT_VERSION }}
dir: ${{ github.workspace }}/..
arch: win64_msvc2017_64
cached: ${{ steps.cache-qt-win.outputs.cache-hit }}
aqtversion: ==0.8
# - name: Cache Qt
# id: cache-qt-win
# uses: actions/cache@v1
# with:
# path: ${{ github.workspace }}/../Qt
# key: ${{ runner.os }}-${{ matrix.arch }}-QtCache-${{ env.QT_VERSION }}
# - name: Install Qt (32 bit)
# uses: jurplel/install-qt-action@v2
# if: ${{ matrix.compiler == 'MSVC' && matrix.arch == 'Win32' }}
# with:
# version: ${{ env.QT_VERSION }}
# dir: ${{ github.workspace }}/..
# arch: win32_msvc2017
# cached: ${{ steps.cache-qt-win.outputs.cache-hit }}
# aqtversion: ==0.8
# - name: Install Qt (64 bit)
# uses: jurplel/install-qt-action@v2
# if: ${{ matrix.compiler == 'MSVC' && matrix.arch == 'x64' }}
# with:
# version: ${{ env.QT_VERSION }}
# dir: ${{ github.workspace }}/..
# arch: win64_msvc2017_64
# cached: ${{ steps.cache-qt-win.outputs.cache-hit }}
# aqtversion: ==0.8
- name: Configure CMake
env:
@@ -130,7 +130,7 @@ jobs:
else
cmake -DFSO_USE_SPEECH="ON" -DFSO_FATAL_WARNINGS="ON" -DFSO_USE_VOICEREC="OFF" -DFSO_BUILD_TESTS="ON" \
-DMSVC_SIMD_INSTRUCTIONS=SSE2 -DFSO_BUILD_FRED2="ON" -G "Visual Studio 16 2019" \
-DFSO_BUILD_QTFRED=ON -T "v142" -A "$ARCHITECTURE" ..
-DFSO_BUILD_QTFRED=OFF -T "v142" -A "$ARCHITECTURE" ..
fi
- name: Compile
working-directory: ./build
@@ -167,20 +167,21 @@ jobs:
name: Mac
runs-on: macos-latest
steps:
- name: Cache Qt
id: cache-qt-mac
uses: actions/cache@v1
with:
path: ${{ github.workspace }}/../Qt
key: ${{ runner.os }}-QtCache-${{ env.QT_VERSION }}
- name: Install Qt
uses: jurplel/install-qt-action@v2
with:
version: ${{ env.QT_VERSION }}
dir: ${{ github.workspace }}/..
cached: ${{ steps.cache-qt-mac.outputs.cache-hit }}
setup-python: 'false'
aqtversion: ==1.1.3
# - name: Cache Qt
# id: cache-qt-mac
# uses: actions/cache@v1
# with:
# path: ${{ github.workspace }}/../Qt
# key: ${{ runner.os }}-QtCache-${{ env.QT_VERSION }}
# - name: Install Qt
# uses: jurplel/install-qt-action@v2
# with:
# version: ${{ env.QT_VERSION }}
# dir: ${{ github.workspace }}/..
# cached: ${{ steps.cache-qt-mac.outputs.cache-hit }}
# setup-python: 'false'
# aqtversion: ==1.1.3
# py7zrversion: '==0.19.*'
- uses: actions/checkout@v1
name: Checkout
+1
View File
@@ -4,3 +4,4 @@
[submodule "lib/libRocket"]
path = lib/libRocket
url = https://github.com/asarium/libRocket.git
+14 -4
View File
@@ -39,7 +39,13 @@ endif(NOT CMAKE_BUILD_TYPE AND NOT DEFINED CMAKE_CONFIGURATION_TYPES)
# Override standard CMake configurations
set(CMAKE_CONFIGURATION_TYPES Debug Release FastDebug CACHE STRING "Available configurations" FORCE)
PROJECT(FS2_Open)
set(FSO_LANGUAGES C CXX)
if(APPLE)
set(FSO_LANGUAGES ${FSO_LANGUAGES} OBJC OBJCXX)
endif()
PROJECT(FS2_Open LANGUAGES ${FSO_LANGUAGES})
find_program(CCACHE_PROGRAM ccache)
# Currently only GCC support ccache properly without generating additional warnings
@@ -83,9 +89,11 @@ IF(RESET_INSTALL_PREFIX)
ENDIF(NOT $ENV{FS2PATH} STREQUAL "")
ENDIF(RESET_INSTALL_PREFIX)
IF (WIN32)
OPTION(FSO_USE_SPEECH "Use Windows specific text-to-speach libraries" ON)
IF(WIN32 OR APPLE)
OPTION(FSO_USE_SPEECH "Use text-to-speach libraries" ON)
ENDIF(WIN32 OR APPLE)
IF (WIN32)
OPTION(FSO_USE_VOICEREC "Enable voice recognition support" ON)
OPTION(FSO_BUILD_FRED2 "Build FRED2 binary" ON)
@@ -208,8 +216,10 @@ include(package)
include(doxygen)
# Print used options to log
IF (WIN32)
IF(WIN32 OR APPLE)
message(STATUS "Using text to speech: ${FSO_USE_SPEECH}")
ENDIF()
IF (WIN32)
message(STATUS "Using voice recogition: ${FSO_USE_VOICEREC}")
message(STATUS "Building FRED2: ${FSO_BUILD_FRED2}")
elseif(UNIX)
+387
View File
@@ -3,7 +3,394 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [22.2.0] - 2022-08-06
```
Changelog note:
As of this version, in an attempt to make the changelog easier to navigate and read,
each section will have collapsible subsections, ordered alphabetically by topic.
Headlining features will always be on top.
```
### Added
<details><summary> <b>Big Feature: SEXP Containers</b> </summary>
> As opposed to a SEXP variable, which stores only one value, a SEXP container stores a collection of values.
> Consequently, containers allow for handling data in much more sophisticated ways than variables.
> Containers come in two types:
> * List container - an ordered sequence of values, sort of a cross between Python lists and deques
> * Map container - pairs of keys associated with data, like Lua tables or Python dictionaries
> Further details in the [SEXP Containers announcement thread](https://www.hard-light.net/forums/index.php?topic=98209.0)
</details>
<details><summary> <b>Big Feature: LuaAI</b> </summary>
> LuaAI allows scripters to add a new AI Goal (like ai-chase) that will run script instead of internal logic.
> Adding a Lua AI section in a -sexp.tbm and a few functions to a corresponding -sct.tbm to define the AI logic in certain conditions. More documentation on these functions is available in the LuaAISEXP-Object of the Scripting Docs.
</details>
<details><summary>AI:</summary>
- `$AI ignores aspect lock for leading:` Flag, which lets AI continue to lead their target while performing an Aspect Lock
</details>
<details><summary>Animation: </summary>
- `pause on reverse` Flag
</details>
<details><summary>Controls: </summary>
- Handle international keyboard layouts
- Re-Add `-joy-info` command line flag, for slightly quicker Joystick GUID retrieval
- Add `-controlconfig_tbl` command line flag to print out a template controlconfigdefaults.tbl
</details>
<details><summary>FRED: </summary>
- Support the full number of nebula poofs using a multi-select list
- Add the ability to edit nebula fog colors, since that previously was not part of the FRED UI
- Flags `same-arrival-warp-when-docked` and `same-departure-warp-when-docked` to allow docked ships to still use custom warp parameters
- Allow highlighting custom-colored events by drawing a border on them
- Can now rotate objects relative to other objects in the Object Editor
- Dialog to calculate relative distance and orientation between ships
- Flag "Point using uvec" to point ships while incorporating the ship's uvec
- `ai-attackable-if-no-collide` flag, which prevents turrets from ignoring a target with `no_collide`
</details>
<details><summary>QtFRED: </summary>
- Reinforcements Dialog
- Implemented Replace Data for Number and String
- Texture Replacement Dialog
- TBL Viewer in the Ship Editor
</details>
<details><summary>Graphics: </summary>
- Allow particles to use a random chance for spawning through the `+Chance` parameter
- Command-line parameter `-fov_cockpit` which allows setting an FoV for the cockpit model separately from the viewport FoV. This allows using custom FoVs without distorting the cockpit
- Allow user to export environment map to a PNG from the F3 Lab by pressing M
- Weapon lights: Configurable lighting data for weapons, both on a per-weapon basis and globally via lighting profiles
- Implemented debug sphere queuing and rendering
</details>
<details><summary>Localization: </summary>
- Make strings for Match Speed Indicator, Glide Indicator, and Afterburner Indicator translateable
</details>
<details><summary>Modding: </summary>
- `game_settings.tbl` setting `$Supernova hits at zero:`, which causes Supernovae to hit when the timer gets to 0, instead of the default of hitting 5 seconds before the time is up
- `game_settings.tbl` settings `$Show-subtitle uses pixels:` and `$Show-subtitle base resolution:`, which can be used in conjunction to scale subtitles
- `game_settings.tbl` setting `$Always warn player about unbound keys used in Directives Gauge:`, to show such warning to players when needed (without it these warnings only apply to Training Missions)
- Ship flags `fail-sound-locked-primary` and `fail-sound-locked-secondary` to allow the firing fail sound to play if the player tries to fire weapons that are locked
- Subsystem Flag "hide turret from loadout stats"
- Allow weapon to override turret name with `$Turret Name:`
</details>
<details><summary>Multiplayer: </summary>
- Save PXO stats to local pilot file
</details>
<details><summary>Performance: </summary>
- Preload subspace tunnel if the `mission-set-subspace` SEXP is used in the mission
</details>
<details><summary>SEXPs: </summary>
- `cancel-future-waves`, for stopping wings that still had waves queued from spawning
- Added optional flag to `show-subtitle-text` and `show-subtitle-image` to not change the subtitle aspect ratio
- `set-nav-color` and `set-nav-visited-color`, which allows setting custom colors to Navpoints in a mission
</details>
<details><summary>Scripting: </summary>
- Support for decals (see `decaldefinition` in the Scripting documentation)
- Missile list iterator: `mn.getMissileList()`
- Campaign Start hook: `On Campaign Begin`
- Player Loaded hook: `On Player Loaded`
- Added a few functions to get information on HUD gauges (check `HudGauge` in the Scripting documentation)
- Function `ship.checkVisibility` which checks if a ship can appear on the viewer's radar
- Function `hu.flashTargetBox` which causes the target box to flash
- Function `hu.getTargetDistance` to return the distance to target as reported by the HUD
- Function `mn.hasLineOfSight` which checks if one point has line of sight to the other
- Function `mn.getLineOfSightFirstIntersect` which checks for line of sight and returns the distance of the first interruption if not
- Variable `gr.CurrentResizeMode`, which can get or set the scaling mode to be used by the `gr.*` drawing methods
- Function `gr.draw3dLine`, which draws a line in space between two points
- Allow SCPUI to run `$On Briefing Stage:` hooks
- New bindings to allow proper hooking into control actions based on the control's enumeration name
- Allow scripted controls to override hardcoded functionality
- Fennel script support
- Lua BitOp 1.0.2 extension library, allowing the usage of bit operations
</details>
<details><summary>Technical: </summary>
- Class encapsulation for Volition's linked list
- Improve a debug console message to be more informative
- Type-safe `TIMESTAMP` class
- Add `timestamp_since()` function
- Add methods to compare timestamps, calculate deltas from an existing timestamp and a number of milliseconds, and to calculate deltas between timestamps
- Create a command line option for logging data packets
- Add more information to Multi-related debug logging
- Enable Doxygen for QTFred
- Set up Mac builds on CI, allowing builds to be published automatically for Mac
- Add some logging to `waitAsync`
</details>
### Changed
<details><summary>Game: </summary>
- Only display one popup when the player gets to the main hall
- Allow an unlimited number of ship flags to be parsed at once
</details>
<details><summary>AI: </summary>
- Improve Player Orders to allow for a nearly unlimited number of player orders, as opposed to the 32 before
- Update `ai_turn_towards_vector` to use a target velocity for banking
</details>
<details><summary>Audio: </summary>
- Allow unlimited soundtracks and spooled music (Previously limited to 30 and 50 respectively)
- Allow unlimited sound effects
- Dynamically set the maximum number of audio channels based on how many the user's system can support
</details>
<details><summary>FRED: </summary>
- CTRL+V is now add-paste (used to be CTRL+P)
- CTRL+SHIFT+V is now overwrite-paste (used to be CTRL+V)
- Replace `Always_show_goals` with `Toggle_showing_goals` which toggles whether the goals are shown, and works in any mission (instead of only Training Missions)
- No longer disable icon dropdowns for models that have their own icons
- No longer change the ship class when the icon type is a special popup
- Make the number of player orders FRED can handle dynamic
- Restore original Error Checking behavior where the function would exit after one check (for consistency)
- Exclude player ships from Error Checking for ships in a wing sharing the same orders
- Split "No subsystems found" and "Not all subsystems have a record in ships.tbl" warnings into two different warning flags
</details>
<details><summary>Graphics: </summary>
- Improved light attenuation to look more real
- Increase POF vertex limit, allowing up to `2^32 - 1` vertices to be used by a single subobject
</details>
<details><summary>Performance: </summary>
- Delay `ai_new_maybe_reposition_attack_subsys` to only run once a second. Before this change, it could take around 13% of runtime in crowded missions
- Cached subsystem indexing, speeding up subsystem lookups, which run for multiple ships, multiple times per frame
</details>
<details><summary>Scripting: </summary>
- Enhance help text for Lua SEXPs
- Converted the following Lua Hooks to the new format to add documentation: `On Death`, `On Game Init`, `On Ship Collision`
</details>
<details><summary>Technical: </summary>
- Turn `insertion_sort` into a templated function that uses assignment
- CMake: Update `PREBUILT_VERSION_NAME` to latest (mac libs)
- Optimized space used in the new POF version
- Cleanup model code
- Cleanup beam light functions by consolidating some duplicated code and removing unreachable logic
- Cleanup wing wave code
- Move special parsing functions into new `parsehi.cpp` and `parsehi.h` files
- Actually clear delayed SSM parsing data when it's no longer needed
- Allow C++ to interact more with LuaTables, allowing it to extract userdata like objects or ships from them
- Use `SCP_string` for constructing multi/event log lines
- Replace `+Orders Accepted:` Bitfield with flag list
- Handle deprecated command line flags programmatically, avoiding lots of code duplication
- Set up debug_filter.cfg to have default filters that can be turned off
</details>
### Removed
<details><summary>FRED: </summary>
- Remove the `Allow Daisy-Chained Docking` mission flag
- Remove "Delete Item" from the right-click menu in the Event Editor
</details>
<details><summary>Technical: </summary>
- Remove light filtering data which didn't work and increased code complexity
- Remove a pointless assert that checked if `SEXP_NODE_INCREMENT` (a define, set at 250) was greater than zero
</details>
### Fixed
<details><summary>Game: </summary>
- Missing whitespace in credits
- Stopped destroyed submodels from showing in Techroom
- Prevent a crash when an object dies in the same frame as their goal
- Always record primary bank ammo capacity during ship creation, preventing situations where a ballistic weapon would accidentally be set to zero ammo
- Properly remove ships from the Techroom when they're not in the Tech Database
- Load the correct Techroom data after a Tech Database Reset
- Don't tick Supernova timer while the game is paused
- Make `set-camera-facing` use default identity orientation when the `$Use host orientation` flag is active and no host is present
- When a hotkey text replacement string refers to an unbound control, use the name of the binding instead of "none"
- Fix usage of default tech database flags
- Prevent a crash in the loadout screen with a weapons-locked ship
- Fix two crashes in the F3 lab
- End the campaign properly when a mission is skipped, preventing crashing in some situations
- Prevent a crash when a message is sent from an invalid source
- Prevent a broken campaign state if the player quits the game from the options menu during the debriefing
- Add some checks before converting a message to Command
- Prevent accidentally skipping cutscenes caused by hitting the spacebar during a loading screen
- Fixed an issue where ships would start with the wrong hull values in Red Alert missions
</details>
<details><summary>AI: </summary>
- Fix turret swarm weapons by removing a few checks that are no longer valid
- Fix a few issues with maneuvers
</details>
<details><summary>Animations: </summary>
- Fix broken turret animations in the Techroom
</details>
<details><summary>Audio: </summary>
- Fix cockpit engine sound volume changing unexpectedly
- Fix a timing bug that would sometimes prevent music from being initialized when re-playing a mission
- Check all possible extensions for audio files
</details>
<details><summary>Controls: </summary>
- Flush the mouse state after toggling between `Use_mouse_to_fly` states, preventing situations where a stale mouse state would be used
- Fix a conflict between Free Look View controls and directional thrust controls
</details>
<details><summary>FRED: </summary>
- Prevent Ship Select Dialog from crashing if there are too many IFFs
- Support saving nebula fog colors
- Properly save `nav-carry-status` flag
- Don't treat a bare `<argument>` as an error
- Prevent adding duplicated variables and display an error to the user when they try
- Clean up some parse problems
- Fix assignment of alt-name when using the hash
- Guard against off-by-one errors in `replace_one` and `replace_all`
- Improve error checking of campaign loop branches
- Improve error reporting for bad SEXP nodes
- Prevent a crash with paste/add-paste when the clipboard was empty
- Prevent rounding/conversion issues that caused FRED to think an angle or position was modified when it wasn't
- Skip absent ships or wings when running `clear-goals`, instead of stopping the whole operation
</details>
<details><summary>Graphics: </summary>
- Disable Lightshafts while the Supernova glare effect is active. This partial fix ensures the glare shows up with the correct brightness
- Update and correctly load environment maps in F3 Lab
- Correctly set textures and Team Colors with `change-ship-class`
- Fixes Team Colors not working with `show-ship`
- Correct positioning and angles for background bitmaps and suns
- Clean up ship arrival and departure effects
- Fix clearing a skybox model when it isn't the mission default
- Fix an assertion with Fireball LODs which would wrongly trigger if the number of LODs was the same as the maximum
</details>
<details><summary>HUD: </summary>
- Make HUD Target distance consistent
- Fix a crash with scripted HUDs
- Correctly update RTT Cockpit Gauges with `change-ship-class`
- Ignore HUD brackets with a size of zero or less (instead of just crashing)
- Squad menu wasn't scrolling properly with PageDown in some cases
- Fix issues with loading of hud config presets
- Fix parsing issues with HUD color presets
- Continue parsing remaining gauges if one isn't found
- Use translated strings both when saving and loading
- Fix an issue where a target's orders would be displayed wrongly in the target box
- Fix asteroid brackets disappearing or displaying wrong values
</details>
<details><summary>Modding: </summary>
- Delay processing `$Player Weapon Precedence:` until after parsing, avoiding ships starting with the wrong weapons in some situations
- Make the `$Player Weapon Precedence:` list actually give precedence
- Empty `+Orders Accepted List:` entries were causing the ship to accept the default orders, instead of no orders as would be correct
- Show a Warning if a turret submodel is not an immediate child of the base object and handle it as a single-part object to prevent a crash
</details>
<details><summary>Multiplayer: </summary>
- Limit client collisions to prevent bugs, such as flinging players with high pings who collided multiple times between packet updates
- Fix multiple timestamp issues
- Multi messaging and multi pause screen
- Make sure maintenance stuff (pings, voice, file xfer, etc.) isn't affected by pausing or time compression
- Sync issues caused by options menu and screenshots
- Prevent an error with long messages in PXO Chat by using proper buffer size
- Fix some issues with Multiplayer SEXPs
- Try to handle incompatible sexp packets better
- Fix operator name issue with debug messages
- Enable the new show-subtitle-text options
- Improve interpolation, fixing the jerkiness that used to occur when the interpolation code basically guessed the timing on when packets were coming in
- Fix rollback primary collisions, vastly improving accuracy on moving targets even at high pings
- Fix the standalone ship being added to ship list
- Stop non-printable keys adding text to multi message buffer
- Prevent the standalone from crashing if a player tried to switch secondaries in a ship that doesn't have secondaries
- Fix a standalone crash from disabled uniform buffer manager
- Prevent a crash related to Observer-type players
- Fix network issues on MacOS
</details>
<details><summary>Scripting: </summary>
- Make hook conditions consistent and handle combinations that didn't work properly before
- Fix `maybePlayCutscene` arguments
- Add `isActive` checks for new-style script hooks
- Sync the two `VIRTVAR`s for Orientation in subsystems and submodel instances, which behaved in different ways
- Fixed a few timing and framerate related issues for playing movies via script
- Ensure the Lua interpreter has enough space in its stack, and allow reserving more space if necessary
- Fixed an memory leak in the Lua interpreter caused by string-eval sexps, which never cleaned up the generated code
</details>
<details><summary>SEXPs: </summary>
- Avoid setting .rest for `Locked_sexp_true/false` with malformed SEXPs
- Fix some memory management problems in the `for-*` operators, avoiding a memory leak
- Fix crash when removing form-on-wing order with `remove-goal`
- Fix `show-subtitle` SEXP which was missing the `width` argument
- Reset volumes changed via `adjust-audio-volume` when the mission closes
- Prevent too many dynamic SEXPs from breaking the SEXP system
</details>
<details><summary>Technical: </summary>
- Check if index is valid before accessing `Weapon_info`, preventing CTDs under certain conditions
- When `weapon_create` was called while `MAX_WEAPONS` was reached, the previous algorithm didn't achieve desired results, and simply locked up the game. Instead, we now simply won't allow a new weapon to be created in such condition
- Refactored Supernova code and fixed some state transition issues in it
- Prevent crashes in the event of a subsystem mismatch during `change_ship_type`
- Change include order to fix compilation of unit tests on Mac
- Patch freeing of SEXP nodes, preventing a crash in certain conditions
- Fix a memory leak in model code
- Fix a crash in the Ship Creation code if a ship's name was exactly the maximum allowed length
- Removed vestigial bit-depth asserts for aabitmaps, preventing crashes with certain image types
- Prevent a crash when Escort Priority was parsed for a ship not present in the Escort List
- Fix a bunch of graphics functions to respect GR_STUB, preventing problems in standalone server
- Clean up line endings in several files (replaced CRLF with LF basically everywhere)
- Fixed a timestamp issue which helps lay the groundwork to add In-Game Joining to multiplayer
- Prevent pilot and campaign files from having invalid values, by clamping them within the expected ranges when saving and loading
- Also warn the player if such an invalid value was detected, telling them which setting had the wrong value and what it was reset to
- Try to avoid assertions by preventing invalid types from being handled by `obj_team()`
- Shut down the SEXP system before the Scripting system, otherwise a crash could happen if the SEXP system held references to Lua
</details>
----
## [22.0.0] - 2022-04-01 ([Thread](https://www.hard-light.net/forums/index.php?topic=98125.0))
### Changed
- Controls5 PR (aka multi-joy)
+2 -2
View File
@@ -133,7 +133,7 @@ if ($DeployBuild) {
cmake -DCMAKE_INSTALL_PREFIX="$env:APPVEYOR_BUILD_FOLDER/../install" -DFSO_USE_SPEECH="ON" `
-DFSO_USE_VOICEREC="ON" -DMSVC_SIMD_INSTRUCTIONS="$($buildConfig.SimdType)" `
-DQT5_INSTALL_ROOT="$($buildConfig.QtDir)" -DFSO_BUILD_QTFRED=ON `
-DQT5_INSTALL_ROOT="$($buildConfig.QtDir)" -DFSO_BUILD_QTFRED=OFF `
-DFSO_INSTALL_DEBUG_FILES="ON" `
-G "$($buildConfig.Generator)" -T "$($buildConfig.Toolset)" ..
@@ -153,7 +153,7 @@ if ($DeployBuild) {
Push-AppveyorArtifact "$($PackageName)-debug-$($buildConfig.PackageType).7z"
} else {
cmake -DFSO_USE_SPEECH="ON" -DFSO_FATAL_WARNINGS="ON" -DFSO_USE_VOICEREC="ON" -DFSO_BUILD_TESTS="ON" -DMSVC_SIMD_INSTRUCTIONS=SSE2 `
-DFSO_BUILD_QTFRED=ON -DQT5_INSTALL_ROOT="$env:QT_DIR" -DFSO_BUILD_FRED2="ON" `
-DFSO_BUILD_QTFRED=OFF -DQT5_INSTALL_ROOT="$env:QT_DIR" -DFSO_BUILD_FRED2="ON" `
-G "$Env:CMAKE_GENERATOR" -T "$Env:PlatformToolset" ..
cmake --build . --config "$Env:CONFIGURATION" -- /verbosity:minimal
+1 -1
View File
@@ -43,5 +43,5 @@ if [ "$RUNNER_OS" = "macOS" ]; then
fi
cmake -G Ninja -DFSO_FATAL_WARNINGS=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON $CMAKE_OPTIONS $PLATFORM_CMAKE_OPTIONS \
-DCMAKE_INSTALL_PREFIX="$(pwd)/install" -DCMAKE_BUILD_TYPE=$CONFIGURATION \
-DFFMPEG_USE_PRECOMPILED=ON -DFSO_BUILD_TESTS=ON -DFSO_BUILD_INCLUDED_LIBS=ON -DFSO_BUILD_QTFRED=ON \
-DFFMPEG_USE_PRECOMPILED=ON -DFSO_BUILD_TESTS=ON -DFSO_BUILD_INCLUDED_LIBS=ON -DFSO_BUILD_QTFRED=OFF \
-DSHADERS_ENABLE_COMPILATION=ON ..
+1 -1
View File
@@ -40,7 +40,7 @@ class ForumAPI:
"body": content
})
if resp.text != "OK":
if resp.status_code != 200:
print("Post failed! Response: %s" %resp.text)
return resp.json()
+1 -1
View File
@@ -42,7 +42,7 @@ MAJOR_VERSION_PATTERN = re.compile("(?:set_if_not_defined|set)\(FSO_VERSION_MAJO
MINOR_VERSION_PATTERN = re.compile("(?:set_if_not_defined|set)\(FSO_VERSION_MINOR (\d+)\)")
BUILD_VERSION_PATTERN = re.compile("(?:set_if_not_defined|set)\(FSO_VERSION_BUILD (\d+)\)")
REVISION_VERSION_PATTERN = re.compile("(?:set_if_not_defined|set)\(FSO_VERSION_REVISION (\d+)\)")
REVISION_STR_VERSION_PATTERN = re.compile("(?:set_if_not_defined|set)\(FSO_VERSION_REVISION_STR (\w+)\)")
REVISION_STR_VERSION_PATTERN = re.compile("(?:set_if_not_defined|set)\(FSO_VERSION_REVISION_STR (\w*)\)")
LOG_FORMAT = """
------------------------------------------------------------------------%n
+25 -18
View File
@@ -7,6 +7,13 @@ import requests
from file_list import ReleaseFile
from util import retry_multi, GLOBAL_TIMEOUT
LINUX_KEY = "Linux"
MACOSX_KEY = "Mac"
WIN32_SSE2_KEY = "Win32-SSE2"
WIN64_SSE2_KEY = "Win64-SSE2"
WIN32_AVX_KEY = "Win32-AVX"
WIN64_AVX_KEY = "Win64-AVX"
metadata = {
'type': 'engine',
'title': 'FSO',
@@ -26,28 +33,28 @@ metadata = {
}
platforms = {
'Linux': 'linux',
'MacOSX': 'macosx',
'Win32-SSE2': 'windows',
'Win64-SSE2': 'windows',
'Win32-AVX': 'windows',
'Win64-AVX': 'windows'
LINUX_KEY: 'linux',
MACOSX_KEY: 'macosx',
WIN32_SSE2_KEY: 'windows',
WIN64_SSE2_KEY: 'windows',
WIN32_AVX_KEY: 'windows',
WIN64_AVX_KEY: 'windows'
}
envs = {
'Linux': 'linux && x86_64', # Linux only has 64bit builds
'MacOSX': 'macosx',
'Win32-SSE2': 'windows',
'Win64-SSE2': 'windows && x86_64',
'Win32-AVX': 'windows && avx',
'Win64-AVX': 'windows && avx && x86_64'
LINUX_KEY: 'linux && x86_64', # Linux only has 64bit builds
MACOSX_KEY: 'macosx',
WIN32_SSE2_KEY: 'windows',
WIN64_SSE2_KEY: 'windows && x86_64',
WIN32_AVX_KEY: 'windows && avx',
WIN64_AVX_KEY: 'windows && avx && x86_64'
}
subdirs = {
'Win32-SSE2': 'x86',
'Win64-SSE2': 'x64',
'Win32-AVX': 'x86_avx',
'Win64-AVX': 'x64_avx'
WIN32_SSE2_KEY: 'x86',
WIN64_SSE2_KEY: 'x64',
WIN32_AVX_KEY: 'x86_avx',
WIN64_AVX_KEY: 'x64_avx'
}
@@ -103,7 +110,7 @@ def render_nebula_release(version, stability, files, config):
'filename': dest_fn
})
if group == 'Linux' and fn.endswith('.AppImage'):
if group == LINUX_KEY and fn.endswith('.AppImage'):
if 'qtfred' in fn:
if '-FASTDBG' in fn:
label = 'QtFRED Debug'
@@ -128,7 +135,7 @@ def render_nebula_release(version, stability, files, config):
'label': label,
'properties': props,
})
elif group == 'MacOSX' and fn.startswith(os.path.basename(fn) + '.app/'):
elif group == MACOSX_KEY and fn.startswith(os.path.basename(fn) + '.app/'):
if 'qtfred' in fn:
if '-FASTDBG' in fn:
label = 'QtFRED Debug'
+1 -1
View File
@@ -1,3 +1,3 @@
Mako==1.1.5
Mako==1.2.2
requests==2.26.0
semantic-version==2.8.5
+1 -1
View File
@@ -31,7 +31,7 @@ if [ "$TRAVIS_OS_NAME" = "linux" ]; then
cd ..
done
else
eval $CMAKE -DCMAKE_BUILD_TYPE=$CONFIGURATION -DFSO_BUILD_TESTS=ON -DFSO_BUILD_INCLUDED_LIBS=ON -DFSO_BUILD_QTFRED=ON ..
eval $CMAKE -DCMAKE_BUILD_TYPE=$CONFIGURATION -DFSO_BUILD_TESTS=ON -DFSO_BUILD_INCLUDED_LIBS=ON -DFSO_BUILD_QTFRED=OFF ..
fi
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
if [ "$BUILD_DEPLOYMENT" = true ]; then
+16
View File
@@ -0,0 +1,16 @@
buildType:
default: release
description: R
choices:
release:
short: Release
long: Release builds
buildType: Release
fastDebug:
short: FastDebug
long: Debug with optimizations
buildType: FastDebug
debug:
short: Debug
long: Debug without optimizations
buildType: Debug
+2
View File
@@ -9,6 +9,8 @@ if (WIN32)
if (NOT HAVE_SAPI_H)
message(SEND_ERROR "sapi.h could not be found on your platform. Please disable speech support.")
endif()
elseif(APPLE)
# it should just work
else()
message(SEND_ERROR "Text to Speech is not supported on this platform!")
endif()
+1
View File
@@ -10,6 +10,7 @@ SET(WIN32_LIBS
winmm
ws2_32
psapi
shlwapi
)
IF (MINGW)
+1 -1
View File
@@ -7,7 +7,7 @@ if (EXISTS "${PROJECT_SOURCE_DIR}/version_override.cmake")
endif()
set_if_not_defined(FSO_VERSION_MAJOR 22)
set_if_not_defined(FSO_VERSION_MINOR 1)
set_if_not_defined(FSO_VERSION_MINOR 3)
set_if_not_defined(FSO_VERSION_BUILD 0)
# A numeric revision e.g. the CI build number
+4
View File
@@ -68,6 +68,10 @@ target_link_libraries(code PUBLIC variant)
target_link_libraries(code PUBLIC any)
target_link_libraries(code PUBLIC optional)
target_link_libraries(code PUBLIC imgui)
# Headers for standalone "gui" on UNIX
IF(UNIX)
TARGET_LINK_LIBRARIES(code PUBLIC ${MONGOOSE_LIBS})
+1 -1
View File
@@ -18,7 +18,7 @@ struct ProgramLocals {
matrix localOrient = vmd_identity_matrix;
int hostSubobject = -1;
int waitTimestamp = 0;
TIMESTAMP waitTimestamp = TIMESTAMP::invalid();
expression::ProgramVariables variables;
};
+3 -3
View File
@@ -20,7 +20,7 @@ WaitAction::~WaitAction() = default;
ActionResult WaitAction::execute(actions::ProgramLocals& locals) const
{
if (!timestamp_valid(locals.waitTimestamp)) {
if (!locals.waitTimestamp.isValid()) {
auto waitTime = _waitTimeExpression.execute(locals.variables);
// Catch errors in the expression
@@ -28,7 +28,7 @@ ActionResult WaitAction::execute(actions::ProgramLocals& locals) const
waitTime = 0.001f;
}
locals.waitTimestamp = timestamp(fl2i(waitTime * TIMESTAMP_FREQUENCY));
locals.waitTimestamp = _timestamp(fl2i(waitTime * MILLISECONDS_PER_SECOND));
}
if (!timestamp_elapsed(locals.waitTimestamp)) {
// Wait until the timestamp is elapsed
@@ -36,7 +36,7 @@ ActionResult WaitAction::execute(actions::ProgramLocals& locals) const
}
// Timestamp is elapsed. The timestamp is elapsed so that timestamp_valid above returns false for the next wait
// action
locals.waitTimestamp = 0;
locals.waitTimestamp = TIMESTAMP::invalid();
return ActionResult::Finished;
}
std::unique_ptr<Action> WaitAction::clone() const
-28
View File
@@ -52,34 +52,6 @@ void ai_free_slot(int ai_index)
Ai_info[ai_index].shipnum = -1;
}
int get_wingnum(int objnum)
{
int shipnum, ai_index;
shipnum = Objects[objnum].instance;
ai_index = Ships[shipnum].ai_index;
return Ai_info[ai_index].wing;
}
void set_wingnum(int objnum, int wingnum)
{
int shipnum, ai_index;
Assert(Objects[objnum].type == OBJ_SHIP);
shipnum = Objects[objnum].instance;
Assert((shipnum >= 0) && (shipnum < MAX_SHIPS));
ai_index = Ships[shipnum].ai_index;
Assert( (ai_index >= 0) && (ai_index < MAX_AI_INFO) );
Ai_info[ai_index].wing = wingnum;
}
const char *ai_get_goal_target_name(const char *name, int *index)
{
Assertion(name != nullptr && index != nullptr, "Arguments cannot be null!");
+9 -61
View File
@@ -12,6 +12,7 @@
#ifndef _AI_H
#define _AI_H
#include "ai/aigoals.h"
#include "ai/ai_profiles.h"
#include "globalincs/globals.h"
#include "globalincs/pstypes.h"
@@ -33,8 +34,8 @@ typedef struct ai_flag_name {
char flag_name[TOKEN_LENGTH];
} ai_flag_name;
#define MAX_AI_FLAG_NAMES 2
extern ai_flag_name Ai_flag_names[];
extern const int Num_ai_flag_names;
// dock_orient_and_approach() modes.
#define DOA_APPROACH 1 // Approach the current point on the path (aip->path_cur)
@@ -55,18 +56,6 @@ extern ai_flag_name Ai_flag_names[];
#define AISS_3 43 // Gotten near spot, fly about there.
#define AISS_1a 44 // Pick a new nearby spot because we are endangered, then go to AISS_2
#define MAX_AI_GOALS 5
// types of ai goals -- tyese types will help us to determination on which goals should
// have priority over others (i.e. when a player issues a goal to a wing, then a seperate
// goal to a ship in that wing). We would probably use this type in conjunction with
// goal priority to establish which goal to follow
#define AIG_TYPE_EVENT_SHIP 1 // from mission event direct to ship
#define AIG_TYPE_EVENT_WING 2 // from mission event direct to wing
#define AIG_TYPE_PLAYER_SHIP 3 // from player direct to ship
#define AIG_TYPE_PLAYER_WING 4 // from player direct to wing
#define AIG_TYPE_DYNAMIC 5 // created on the fly
// Flags to ai_turn_towards_vector().
#define AITTV_FAST (1<<0) // Turn fast, not slowed down based on skill level.
#define AITTV_VIA_SEXP (1<<1) // Goober5000 - via sexp
@@ -76,39 +65,7 @@ extern ai_flag_name Ai_flag_names[];
#define KAMIKAZE_HULL_ON_DEATH -1000.0f // Hull strength ship gets set to if it crash-dies.
// structure for AI goals
typedef struct ai_goal {
int signature; // Unique identifier. All goals ever created (per mission) have a unique signature.
int ai_mode; // one of the AIM_* modes for this goal
int ai_submode; // maybe need a submode
int type; // one of the AIG_TYPE_* values above
flagset<AI::Goal_Flags> flags; // one of the AIGF_* values above
fix time; // time at which this goal was issued.
int priority; // how important is this goal -- number 0 - 100
const char *target_name; // name of the thing that this goal acts upon
int target_name_index; // index of goal_target_name in Goal_target_names[][]
waypoint_list *wp_list; // waypoints that this ship might fly.
int target_instance; // instance of thing this ship might be chasing (currently only used for weapons; note, not the same as objnum!)
int target_signature; // signature of object this ship might be chasing (currently only used for weapons; paired with above value to confirm target)
// unions for docking stuff.
// (AIGF_DOCKER_INDEX_VALID and AIGF_DOCKEE_INDEX_VALID tell us to use indexes; otherwise we use names)
// these are the dockpoints used on the docker and dockee ships, not the ships themselves
union {
const char *name;
int index;
} docker;
union {
const char *name;
int index;
} dockee;
object_ship_wing_point_team lua_ai_target;
} ai_goal;
// individual AI modes aka AI behaviors
#define AIM_CHASE 0
#define AIM_EVADE 1
#define AIM_GET_BEHIND 2 // This mode is not actually implemented.
@@ -138,8 +95,7 @@ typedef struct ai_goal {
#define MAX_WAYPOINTS_PER_LIST 20
#define MAX_ENEMY_DISTANCE 2500.0f // Maximum distance from which a ship will pursue an enemy.
#define AI_GOAL_NONE -1
#define MAX_AI_GOALS 5
#define AI_ACTIVE_GOAL_DYNAMIC 999
typedef struct ai_class {
@@ -277,8 +233,6 @@ extern pnode *Ppfp; // Free pointer in path points.
typedef struct ai_info {
flagset<AI::AI_Flags> ai_flags; // Special flags for AI behavior.
int shipnum; // Ship using this slot, -1 means none.
int type; //
int wing; // Member of what wing? -1 means none.
int behavior; // AI behavior; vestigial field from early development of FS1
int mode;
@@ -504,9 +458,12 @@ typedef struct ai_info {
int multilock_check_timestamp; // when to check for multilock next
SCP_vector<std::pair<int, ship_subsys*>> ai_missile_locks_firing; // a list of missile locks (locked objnum, locked subsys) the ai is currently firing
object_ship_wing_point_team lua_ai_target;
ai_lua_parameters lua_ai_target;
} ai_info;
int ai_maybe_autoscale(int absolute_index = -1);
int ai_get_autoscale_index(int absolute_index = -1);
// Goober5000
typedef struct {
vec3d docker_point;
@@ -531,11 +488,6 @@ typedef struct {
extern int Mission_all_attack; // !0 means all teams attack all teams.
extern void update_ai_info_for_hit(int hitter_obj, int hit_obj);
extern void ai_frame_all(void);
extern int find_guard_obj(void);
extern ai_info Ai_info[];
extern ai_info *Player_ai;
@@ -546,7 +498,6 @@ extern int Num_ai_classes;
extern int Ai_firing_enabled;
extern const char *Skill_level_names(int skill_level, int translate = 1);
extern int Ai_goal_signature;
extern control_info AI_ci;
@@ -570,9 +521,6 @@ void ai_object_init(object * obj, int ai_index);
// Called once a frame
void ai_process( object * obj, int ai_index, float frametime );
int get_wingnum(int objnum);
void set_wingnum(int objnum, int wingnum);
const char *ai_get_goal_target_name(const char *name, int *index);
void ai_clear_goal_target_names();
@@ -687,6 +635,6 @@ void do_random_sidethrust(ai_info *aip, ship_info *sip);
void ai_formation_object_recalculate_slotnums(int form_objnum, int exiting_objnum = -1);
bool test_line_of_sight(vec3d* from, vec3d* to, std::unordered_set<const object*>&& excluded_objects = {}, float threshold = 10.0f, bool test_for_shields = false, bool test_for_hull = true, float* first_intersect_dist = nullptr);
bool test_line_of_sight(vec3d* from, vec3d* to, std::unordered_set<const object*>&& excluded_objects = {}, float threshold = 10.0f, bool test_for_shields = false, bool test_for_hull = true, float* first_intersect_dist = nullptr, object** first_intersect_obj = nullptr);
#endif
+5
View File
@@ -145,6 +145,11 @@ namespace AI {
Prevent_negative_turret_ammo,
Fix_keep_safe_distance,
Ignore_aspect_when_leading,
Fix_good_rearm_time_bug,
No_continuous_turn_on_attack,
Fixed_removing_play_dead_order,
Disable_bay_emerge_timeout,
Adjusted_AI_class_autoscale,
NUM_VALUES
};
+15
View File
@@ -600,6 +600,16 @@ void parse_ai_profiles_tbl(const char *filename)
set_flag(profile, "$AI ignores aspect lock for leading:", AI::Profile_Flags::Ignore_aspect_when_leading);
set_flag(profile, "$fix good-rearm-time bug:", AI::Profile_Flags::Fix_good_rearm_time_bug);
set_flag(profile, "$no continuous turn on attack:", AI::Profile_Flags::No_continuous_turn_on_attack);
set_flag(profile, "$remove-goal properly removes play-dead order:", AI::Profile_Flags::Fixed_removing_play_dead_order);
set_flag(profile, "$bay arrivals not time limited:", AI::Profile_Flags::Disable_bay_emerge_timeout);
set_flag(profile, "$use adjusted AI class autoscale:", AI::Profile_Flags::Adjusted_AI_class_autoscale);
// if we've been through once already and are at the same place, force a move
if (saved_Mp && (saved_Mp == Mp))
@@ -768,4 +778,9 @@ void ai_profile_t::reset()
flags.set(AI::Profile_Flags::Prevent_negative_turret_ammo);
flags.set(AI::Profile_Flags::Fix_keep_safe_distance);
}
if (mod_supports_version(23, 0, 0)) {
flags.set(AI::Profile_Flags::Fix_good_rearm_time_bug);
flags.set(AI::Profile_Flags::No_continuous_turn_on_attack);
flags.set(AI::Profile_Flags::Fixed_removing_play_dead_order);
}
}
+1 -1
View File
@@ -21,7 +21,7 @@
#define AI_RANGE_AWARE_SEC_SEL_MODE_RETAIL 0
#define AI_RANGE_AWARE_SEC_SEL_MODE_AWARE 1
#define MAX_AI_PROFILES 5
#define MAX_AI_PROFILES 8
class ai_profile_t {
public:
+44 -17
View File
@@ -661,16 +661,17 @@ int ai_big_maybe_start_strafe(ai_info *aip, ship_info *sip)
// are near
if ( sip->is_small_ship() ) {
if ( timestamp_elapsed(aip->scan_for_enemy_timestamp) ) {
ship_obj *so;
object *test_objp;
ship *test_sp;
float dist_squared;
aip->scan_for_enemy_timestamp = timestamp(SCAN_FIGHTERS_INTERVAL);
// iterate through ships, and see if any fighter/bomber from opposite team are near
so = GET_FIRST(&Ship_obj_list);
while( so != END_OF_LIST(&Ship_obj_list) ) {
for (auto so: list_range(&Ship_obj_list)) {
test_objp = &Objects[so->objnum];
if (test_objp->flags[Object::Object_Flags::Should_be_dead])
continue;
test_sp = &Ships[test_objp->instance];
if ( iff_x_attacks_y(Ships[Pl_objp->instance].team, test_sp->team) ) {
@@ -681,7 +682,6 @@ int ai_big_maybe_start_strafe(ai_info *aip, ship_info *sip)
}
}
}
so = GET_NEXT(so);
}
}
}
@@ -706,6 +706,9 @@ void ai_big_chase_attack(ai_info *aip, ship_info *sip, vec3d *enemy_pos, float d
if (Pl_objp->phys_info.speed < 3.0f) {
object *objp;
for ( objp = GET_FIRST(&obj_used_list); objp !=END_OF_LIST(&obj_used_list); objp = GET_NEXT(objp) ) {
if (objp->flags[Object::Object_Flags::Should_be_dead])
continue;
if ((objp->type == OBJ_WEAPON) && (iff_x_attacks_y(Ships[Pl_objp->instance].team, Weapons[objp->instance].team)))
if (Weapon_info[Weapons[objp->instance].weapon_info_index].subtype == WP_LASER) {
vec3d in_vec;
@@ -900,7 +903,7 @@ static void ai_big_maybe_fire_weapons(float dist_to_enemy, float dot_to_enemy)
// Chance of hitting ship is based on dot product of firing ship's forward vector with vector to ship
// and also the size of the target relative to distance to target.
if (dot_to_enemy > MAX(0.5f, 0.90f + aip->ai_accuracy/10.0f - En_objp->radius/MAX(1.0f,dist_to_enemy))) {
if (dot_to_enemy > std::max(0.5f, 0.90f + aip->ai_accuracy / 10.0f - En_objp->radius / std::max(1.0f, dist_to_enemy))) {
ship *temp_shipp;
temp_shipp = &Ships[Pl_objp->instance];
@@ -1019,6 +1022,8 @@ void ai_big_switch_to_chase_mode(ai_info *aip)
aip->submode_start_time = Missiontime;
}
extern weapon_info* ai_get_weapon(ship_weapon* swp);
// Make object Pl_objp chase object En_objp, which is a big ship, not a small ship.
void ai_big_chase()
{
@@ -1038,16 +1043,38 @@ void ai_big_chase()
player_pos = Pl_objp->pos;
ai_big_pick_attack_point(En_objp, Pl_objp, &enemy_pos, 0.8f);
// Compute the predicted position of the center of the ship, then add the delta to the goal pos.
if (En_objp->phys_info.speed > 3.0f) {
set_predicted_enemy_pos(&predicted_enemy_pos, Pl_objp, &En_objp->pos, &En_objp->phys_info.vel, aip);
vm_vec_add2(&enemy_pos, &predicted_enemy_pos);
vm_vec_sub2(&enemy_pos, &En_objp->pos);
} else
predicted_enemy_pos = En_objp->pos;
weapon_info* wip = ai_get_weapon(&shipp->weapons);
bool ballistic_aiming = !IS_VEC_NULL(&The_mission.gravity) && wip->gravity_const != 0.0f;
bool valid_ballistic_trajectory = true;
if (aip->targeted_subsys != NULL) {
get_subsystem_pos(&enemy_pos, En_objp, aip->targeted_subsys);
if (!ballistic_aiming) {
// Compute the predicted position of the center of the ship, then add the delta to the goal pos.
if (En_objp->phys_info.speed > 3.0f) {
set_predicted_enemy_pos(&predicted_enemy_pos, Pl_objp, &En_objp->pos, &En_objp->phys_info.vel, aip);
vm_vec_add2(&enemy_pos, &predicted_enemy_pos);
vm_vec_sub2(&enemy_pos, &En_objp->pos);
} else
predicted_enemy_pos = En_objp->pos;
if (aip->targeted_subsys != NULL) {
get_subsystem_pos(&enemy_pos, En_objp, aip->targeted_subsys);
}
} else {
if (aip->targeted_subsys != NULL) {
get_subsystem_pos(&enemy_pos, En_objp, aip->targeted_subsys);
}
vec3d gravity = The_mission.gravity * wip->gravity_const;
vec3d target;
valid_ballistic_trajectory =
physics_lead_ballistic_trajectory(&player_pos, &enemy_pos, &En_objp->phys_info.vel, wip->max_speed, &gravity, &target);
if (valid_ballistic_trajectory) {
enemy_pos = Pl_objp->pos + target * vm_vec_dist(&Pl_objp->pos, &enemy_pos);
predicted_enemy_pos = enemy_pos;
} else {
set_predicted_enemy_pos(&predicted_enemy_pos, Pl_objp, &En_objp->pos, &En_objp->phys_info.vel, aip);
}
}
dist_to_enemy = vm_vec_normalized_dir(&vec_to_enemy, &enemy_pos, &player_pos); // - En_objp->radius;
@@ -1078,7 +1105,7 @@ void ai_big_chase()
// If just acquired target, or target is not in reasonable cone, don't refine believed enemy position.
if ((dot_to_enemy < 0.25f) || (aip->target_time < 1.0f) || (aip->ai_flags[AI::AI_Flags::Seek_lock])) {
update_aspect_lock_information(aip, &vec_to_enemy, dist_to_enemy - En_objp->radius, En_objp->radius);
} else if (aip->targeted_subsys != NULL) {
} else if (aip->targeted_subsys != NULL && !ballistic_aiming) {
Assert(aip->targeted_subsys != NULL);
get_subsystem_pos(&enemy_pos, En_objp, aip->targeted_subsys);
vm_vec_add2(&enemy_pos, &predicted_enemy_pos);
@@ -1110,7 +1137,7 @@ void ai_big_chase()
}
}
if (aip->target_time < 2.0f)
if (!aip->ai_profile_flags[AI::Profile_Flags::No_continuous_turn_on_attack] && aip->target_time < 2.0f)
if ((dot_to_enemy < 0.9f) || (dist_to_enemy > 300.0f)) {
aip->submode = SM_CONTINUOUS_TURN;
aip->submode_start_time = Missiontime - fl2f(2.75f); // This backdated start time allows immediate switchout.
@@ -1318,7 +1345,7 @@ void ai_big_chase()
// I noticed AI ships firing inappropriately when following a path near a big ship.
// TODO: investigate why ships fire (and aren't close to hitting ship) when following a path near
// a big ship
if (aip->mode != AIM_EVADE && aip->path_start == -1 ) {
if (aip->mode != AIM_EVADE && aip->path_start == -1 && (!ballistic_aiming || valid_ballistic_trajectory)) {
ai_big_maybe_fire_weapons(dist_to_enemy, dot_to_enemy);
} else {
if (flFrametime < 1.0f)
+453 -282
View File
File diff suppressed because it is too large. Load diff
+148 -101
View File
@@ -21,7 +21,9 @@
#include "object/objectdock.h"
#include "object/waypoint.h"
#include "parse/sexp.h"
#include "parse/sexp/LuaAISEXP.h"
#include "playerman/player.h"
#include "scripting/global_hooks.h"
#include "scripting/scripting.h"
#include "ship/ship.h"
#include "ship/awacs.h"
@@ -54,7 +56,7 @@ struct ship_registry_entry;
// goals given from the player to other ships in the game are also handled in this
// code
int Ai_goal_signature;
int Ai_goal_signature = 0;
int Num_ai_dock_names = 0;
char Ai_dock_names[MAX_AI_DOCK_NAMES][NAME_LENGTH];
@@ -137,6 +139,41 @@ const char *Ai_goal_text(int goal, int submode)
return nullptr;
}
/**
* Reset all fields to their uninitialized defaults. But if this is being called before adding a new goal, the function will set the correct signature and time.
* Similarly the added mode, submode, and type can be assigned.
*/
void ai_goal_reset(ai_goal *aigp, bool adding_goal, int ai_mode, int ai_submode, int type)
{
if (ai_mode != AI_GOAL_NONE)
Assertion(adding_goal, "If a goal mode is being assigned, the adding_goal parameter must be true so that the signature and mission time can be set");
aigp->signature = adding_goal ? Ai_goal_signature++ : -1;
aigp->ai_mode = ai_mode;
aigp->ai_submode = ai_submode;
aigp->type = type;
aigp->flags.reset(); // must reset the flags since not doing so will screw up goal sorting.
aigp->time = adding_goal ? Missiontime : 0;
aigp->priority = -1;
aigp->target_name = nullptr;
aigp->target_name_index = -1;
aigp->wp_list = nullptr;
aigp->target_instance = -1;
aigp->target_signature = -1;
aigp->int_data = 0;
aigp->float_data = 0.0f;
aigp->docker.name = nullptr;
aigp->dockee.name = nullptr;
aigp->lua_ai_target.target.clear();
aigp->lua_ai_target.arguments.clear();
}
void ai_maybe_add_form_goal(wing* wingp)
{
// Cyborg17 - Changes from the client would just get overridden by the server anyway
@@ -217,6 +254,8 @@ void ai_post_process_mission()
// mission following the orders in the mission file right away instead of waiting N seconds
// before following them. Do both the created list and the object list for safety
for ( objp = GET_FIRST(&obj_used_list); objp != END_OF_LIST(&obj_used_list); objp = GET_NEXT(objp) ) {
if (objp->flags[Object::Object_Flags::Should_be_dead])
continue;
if ( objp->type != OBJ_SHIP )
continue;
ai_process_mission_orders( OBJ_INDEX(objp), &Ai_info[Ships[objp->instance].ai_index] );
@@ -268,17 +307,37 @@ void ai_remove_ship_goal( ai_info *aip, int index )
if (index == aip->active_goal)
{
auto shipp = &Ships[aip->shipnum];
// rearm/repair needs a bit of extra cleanup
if (aip->goals[index].ai_mode == AI_GOAL_REARM_REPAIR)
ai_abort_rearm_request(&Objects[Ships[aip->shipnum].objnum]);
ai_abort_rearm_request(&Objects[shipp->objnum]);
// play dead needs some extra cleanup, too
if (aip->goals[index].ai_mode == AI_GOAL_PLAY_DEAD || aip->goals[index].ai_mode == AI_GOAL_PLAY_DEAD_PERSISTENT)
{
// wookieejedi - there is an early return for the mode AIM_PLAY_DEAD in AI frame, so it needs to be set back to AIM_NONE
if (aip->ai_profile_flags[AI::Profile_Flags::Fixed_removing_play_dead_order])
{
aip->mode = AIM_NONE;
aip->submode_start_time = Missiontime;
}
// Goober5000 - any ship subsystems will start moving now, so their initial velocity should be 0 to match original behavior
for (auto pss = GET_FIRST(&shipp->subsys_list); pss != END_OF_LIST(&shipp->subsys_list); pss = GET_NEXT(pss))
{
if (pss->submodel_instance_1)
{
pss->submodel_instance_1->current_turn_rate = 0.0f;
pss->submodel_instance_1->current_shift_rate = 0.0f;
}
}
}
aip->active_goal = AI_GOAL_NONE;
}
aip->goals[index].ai_mode = AI_GOAL_NONE;
aip->goals[index].signature = -1;
aip->goals[index].priority = -1;
aip->goals[index].flags.reset(); // must reset the flags since not doing so will screw up goal sorting.
ai_goal_reset(&aip->goals[index]);
// mwa -- removed this line 8/5/97. Just because we remove a goal doesn't mean to do the default
// behavior. We will make the call commented out below in a more reasonable location
@@ -304,10 +363,9 @@ void ai_clear_ship_goals( ai_info *aip )
}
// add scripting hook for 'On Goals Cleared' --wookieejedi
if (Script_system.IsActiveAction(CHA_ONGOALSCLEARED)) {
Script_system.SetHookObject("Ship", &Objects[Ships[aip->shipnum].objnum]);
Script_system.RunCondition(CHA_ONGOALSCLEARED, &Objects[Ships[aip->shipnum].objnum]);
Script_system.RemHookVars({"Ship"});
if (scripting::hooks::OnGoalsCleared->isActive()) {
scripting::hooks::OnGoalsCleared->run(scripting::hooks::ShipSourceConditions{ &Ships[aip->shipnum] },
scripting::hook_param_list(scripting::hook_param("Ship", 'o', &Objects[Ships[aip->shipnum].objnum])));
}
}
@@ -326,10 +384,7 @@ void ai_clear_wing_goals( wing *wingp )
// clear out the goals for the wing now
for (i = 0; i < MAX_AI_GOALS; i++) {
wingp->ai_goals[i].ai_mode = AI_GOAL_NONE;
wingp->ai_goals[i].signature = -1;
wingp->ai_goals[i].priority = -1;
wingp->ai_goals[i].flags.reset();
ai_goal_reset(&wingp->ai_goals[i]);
}
}
@@ -384,10 +439,7 @@ void ai_mission_wing_goal_complete( int wingnum, ai_goal *remove_goalp )
continue;
if ( (aigp->ai_mode == mode) && (aigp->ai_submode == submode) && (aigp->priority == priority) && !stricmp(name, aigp->target_name) ) {
wingp->ai_goals[i].ai_mode = AI_GOAL_NONE;
wingp->ai_goals[i].signature = -1;
wingp->ai_goals[i].priority = -1;
wingp->ai_goals[i].flags.reset();
ai_goal_reset(aigp);
break;
}
}
@@ -487,7 +539,7 @@ void ai_goal_purge_invalid_goals( ai_goal *aigp, ai_goal *goal_list, ai_info *ai
// for wings we grab the ship type of the wing leader
if (ai_wingnum >= 0) {
ai_ship_type = Ship_info[Ships[Wings[ai_wingnum].special_ship].ship_info_index].class_type;
ai_ship_type = Ship_info[Wings[ai_wingnum].special_ship_ship_info_index].class_type;
}
// otherwise we simply grab it from the ship itself
else {
@@ -523,6 +575,8 @@ void ai_goal_purge_all_invalid_goals(ai_goal *aigp)
for (sop = GET_FIRST(&Ship_obj_list); sop != END_OF_LIST(&Ship_obj_list); sop = GET_NEXT(sop))
{
if (Objects[sop->objnum].flags[Object::Object_Flags::Should_be_dead])
continue;
ship *shipp = &Ships[Objects[sop->objnum].instance];
ai_goal_purge_invalid_goals(aigp, Ai_info[shipp->ai_index].goals, &Ai_info[shipp->ai_index], -1);
}
@@ -632,7 +686,7 @@ void ai_goal_fixup_dockpoints(ai_info *aip, ai_goal *aigp)
}
}
// look for docking points of the appriopriate type. Use cargo docks for cargo ships.
// look for docking points of the appropriate type. Use cargo docks for cargo ships.
/*
if (Ship_info[Ships[shipnum].ship_info_index].flags[Ship::Info_Flags::Cargo]) {
docker_index = ai_goal_find_dockpoint(aip->shipnum, DOCK_TYPE_CARGO);
@@ -659,37 +713,29 @@ void ai_goal_fixup_dockpoints(ai_info *aip, ai_goal *aigp)
// from the mission goals (i.e. those goals which come from events) in that we don't
// use sexpressions for goals from the player...so we enumerate all the parameters
void ai_add_goal_sub_player(int type, int mode, int submode, char *target_name, ai_goal *aigp, const object_ship_wing_point_team& lua_target )
void ai_add_goal_sub_player(int type, int mode, int submode, char *target_name, ai_goal *aigp, const ai_lua_parameters& lua_target )
{
Assert ( (type == AIG_TYPE_PLAYER_WING) || (type == AIG_TYPE_PLAYER_SHIP) );
aigp->time = Missiontime;
aigp->type = type; // from player for sure -- could be to ship or to wing
aigp->ai_mode = mode; // major mode for this goal
aigp->ai_submode = submode; // could mean different things depending on mode
ai_goal_reset(aigp, true, mode, submode, type);
aigp->lua_ai_target = lua_target;
if ( mode == AI_GOAL_WARP ) {
if (submode >= 0) {
aigp->wp_list = find_waypoint_list_at_index(submode);
Assert(aigp->wp_list != NULL);
} else {
aigp->wp_list = NULL;
}
}
if ( mode == AI_GOAL_CHASE_WEAPON ) {
aigp->target_instance = submode; // submode contains the instance of the weapon
aigp->target_signature = Objects[Weapons[submode].objnum].signature;
} else {
aigp->target_instance = -1;
aigp->target_signature = -1;
}
if ( target_name != NULL )
aigp->target_name = ai_get_goal_target_name( target_name, &aigp->target_name_index );
else
aigp->target_name = NULL;
// special case certain orders from player so that ships continue to do the right thing
@@ -758,29 +804,15 @@ void ai_add_goal_sub_scripting(int type, int mode, int submode, int priority, ch
{
Assert ( (type == AIG_TYPE_PLAYER_WING) || (type == AIG_TYPE_PLAYER_SHIP) );
aigp->time = Missiontime;
aigp->type = type; // from player for sure -- could be to ship or to wing
aigp->ai_mode = mode; // major mode for this goal
aigp->ai_submode = submode; // could mean different things depending on mode
if ( mode == AI_GOAL_WARP )
aigp->wp_list = NULL;
ai_goal_reset(aigp, true, mode, submode, type);
if ( mode == AI_GOAL_CHASE_WEAPON ) {
aigp->target_instance = submode; // submode contains the instance of the weapon
aigp->target_signature = Objects[Weapons[submode].objnum].signature;
}
if ( mode == AI_GOAL_WAYPOINTS_ONCE || mode == AI_GOAL_WAYPOINTS ) {
// should be the same as setting via sexp, see ai_add_goal_sub_sexp
// set to null so the AI code can setup the new waypoint list, see ai_mission_goal_achievable
aigp->wp_list = nullptr;
}
if ( target_name != NULL )
aigp->target_name = ai_get_goal_target_name( target_name, &aigp->target_name_index );
else
aigp->target_name = NULL;
aigp->priority = priority;
}
@@ -792,35 +824,29 @@ void ai_add_ship_goal_scripting(int mode, int submode, int priority, char *shipn
empty_index = ai_goal_find_empty_slot(aip->goals, aip->active_goal);
aigp = &aip->goals[empty_index];
ai_add_goal_sub_scripting(AIG_TYPE_PLAYER_SHIP, mode, submode, priority, shipname, aigp);
//WMC - hack to get docking setup correctly
if ( mode == AI_GOAL_DOCK ) {
aigp->docker.name = Ships[aip->shipnum].ship_name;
aigp->dockee.name = shipname;
aigp->flags.remove(AI::Goal_Flags::Dockee_index_valid);
aigp->flags.remove(AI::Goal_Flags::Docker_index_valid);
}
ai_add_goal_sub_scripting(AIG_TYPE_PLAYER_SHIP, mode, submode, priority, shipname, aigp);
if ( (mode == AI_GOAL_REARM_REPAIR) || ((mode == AI_GOAL_DOCK) && (submode == AIS_DOCK_0)) ) {
if ( (mode == AI_GOAL_REARM_REPAIR) || (mode == AI_GOAL_DOCK) ) {
ai_goal_fixup_dockpoints( aip, aigp );
}
aigp->signature = Ai_goal_signature++;
}
// adds a goal from a player to the given ship's ai_info structure. 'type' tells us if goal
// is issued to ship or wing (from player), mode is AI_GOAL_*. submode is the submode the
// ship should go into. shipname is the object of the action. aip is the ai_info pointer
// of the ship receiving the order
void ai_add_ship_goal_player( int type, int mode, int submode, char *shipname, ai_info *aip, const object_ship_wing_point_team& lua_target)
void ai_add_ship_goal_player( int type, int mode, int submode, char *shipname, ai_info *aip, const ai_lua_parameters& lua_target)
{
int empty_index;
ai_goal *aigp;
empty_index = ai_goal_find_empty_slot( aip->goals, aip->active_goal );
// get a pointer to the goal structure
aigp = &aip->goals[empty_index];
ai_add_goal_sub_player( type, mode, submode, shipname, aigp, lua_target );
@@ -829,17 +855,14 @@ void ai_add_ship_goal_player( int type, int mode, int submode, char *shipname, a
// on both ships. Code is here instead of in ai_add_goal_sub_player() since a dock goal
// should only occur to a specific ship.
if ( (mode == AI_GOAL_REARM_REPAIR) || ((mode == AI_GOAL_DOCK) && (submode == AIS_DOCK_0)) ) {
if ( (mode == AI_GOAL_REARM_REPAIR) || (mode == AI_GOAL_DOCK) ) {
ai_goal_fixup_dockpoints( aip, aigp );
}
aigp->signature = Ai_goal_signature++;
}
// adds a goal from the player to the given wing (which in turn will add it to the proper
// ships in the wing
void ai_add_wing_goal_player( int type, int mode, int submode, char *shipname, int wingnum, const object_ship_wing_point_team& lua_target)
void ai_add_wing_goal_player( int type, int mode, int submode, char *shipname, int wingnum, const ai_lua_parameters& lua_target)
{
int i, empty_index;
wing *wingp = &Wings[wingnum];
@@ -863,7 +886,7 @@ void ai_add_wing_goal_player( int type, int mode, int submode, char *shipname, i
// common routine to add a sexpression mission goal to the appropriate goal structure.
void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name )
void ai_add_goal_sub_sexp( int sexp, int type, ai_info *aip, ai_goal *aigp, char *actor_name )
{
int node, dummy, op;
@@ -871,12 +894,8 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name )
node = Sexp_nodes[sexp].first;
op = get_operator_const( node );
aigp->signature = Ai_goal_signature++;
aigp->target_name = NULL;
aigp->time = Missiontime;
ai_goal_reset(aigp, true);
aigp->type = type;
aigp->flags.reset();
switch (op) {
@@ -889,7 +908,6 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name )
// save the waypoint path name -- the list will get resolved when the goal is checked
// for achievability.
aigp->target_name = ai_get_goal_target_name(CTEXT(CDR(node)), &aigp->target_name_index); // waypoint path name;
aigp->wp_list = NULL;
} else
Int3();
@@ -934,7 +952,6 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name )
case OP_AI_WARP:
aigp->ai_mode = AI_GOAL_WARP;
aigp->target_name = ai_get_goal_target_name(CTEXT(CDR(node)), &aigp->target_name_index); // waypoint path name;
aigp->wp_list = NULL;
aigp->priority = atoi( CTEXT(CDR(CDR(node))) );
break;
@@ -944,13 +961,30 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name )
// Goober5000 - optional undock with something
if (CDR(CDR(node)) != -1)
aigp->target_name = ai_get_goal_target_name( CTEXT(CDR(CDR(node))), &aigp->target_name_index );
else
aigp->target_name = NULL;
aigp->ai_mode = AI_GOAL_UNDOCK;
aigp->ai_submode = AIS_UNDOCK_0;
break;
case OP_AI_REARM_REPAIR:
{
aigp->ai_mode = AI_GOAL_REARM_REPAIR;
aigp->target_name = ai_get_goal_target_name(CTEXT(CDR(node)), &aigp->target_name_index);
aigp->priority = atoi( CTEXT(CDR(CDR(node))) );
// this goal needs some extra setup
// if this doesn't work, the goal will be immediately removed
auto ship_entry = ship_registry_get(aigp->target_name);
if (ship_entry->status == ShipStatus::PRESENT)
{
auto target_aip = &Ai_info[ship_entry->shipp->ai_index];
target_aip->ai_flags.set(AI::AI_Flags::Awaiting_repair);
Assertion(aip != nullptr, "Must provide aip if assigning a rearm goal!");
ai_goal_fixup_dockpoints( aip, aigp );
}
break;
}
case OP_AI_STAY_STILL:
aigp->ai_mode = AI_GOAL_STAY_STILL;
aigp->target_name = ai_get_goal_target_name(CTEXT(CDR(node)), &aigp->target_name_index); // waypoint path name;
@@ -961,8 +995,6 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name )
aigp->target_name = ai_get_goal_target_name( CTEXT(CDR(node)), &aigp->target_name_index );
aigp->docker.name = ai_add_dock_name(CTEXT(CDR(CDR(node))));
aigp->dockee.name = ai_add_dock_name(CTEXT(CDR(CDR(CDR(node)))));
aigp->flags.remove(AI::Goal_Flags::Dockee_index_valid);
aigp->flags.remove(AI::Goal_Flags::Docker_index_valid);
aigp->priority = atoi( CTEXT(CDR(CDR(CDR(CDR(node))))) );
aigp->ai_mode = AI_GOAL_DOCK;
@@ -989,6 +1021,16 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name )
aigp->ai_mode = AI_GOAL_KEEP_SAFE_DISTANCE;
break;
case OP_AI_STAY_NEAR_SHIP:
aigp->target_name = ai_get_goal_target_name( CTEXT(CDR(node)), &aigp->target_name_index );
aigp->priority = atoi( CTEXT(CDDR(node)) );
if ( CDDDR(node) < 0 )
aigp->float_data = 300.0f;
else
aigp->float_data = i2fl(atoi( CTEXT(CDDDR(node)) ));
aigp->ai_mode = AI_GOAL_STAY_NEAR_SHIP;
break;
case OP_AI_FORM_ON_WING:
aigp->priority = 99;
aigp->target_name = ai_get_goal_target_name(CTEXT(CDR(node)), &aigp->target_name_index);
@@ -1001,9 +1043,9 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name )
case OP_AI_GUARD:
case OP_AI_GUARD_WING:
case OP_AI_EVADE_SHIP:
case OP_AI_STAY_NEAR_SHIP:
case OP_AI_IGNORE:
case OP_AI_IGNORE_NEW:
case OP_AI_FLY_TO_SHIP:
aigp->target_name = ai_get_goal_target_name( CTEXT(CDR(node)), &aigp->target_name_index );
aigp->priority = atoi( CTEXT(CDR(CDR(node))) );
@@ -1036,8 +1078,10 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name )
aigp->ai_mode = AI_GOAL_IGNORE;
} else if ( op == OP_AI_IGNORE_NEW ) {
aigp->ai_mode = AI_GOAL_IGNORE_NEW;
} else if ( op == OP_AI_FLY_TO_SHIP ) {
aigp->ai_mode = AI_GOAL_FLY_TO_SHIP;
} else
Int3(); // this is impossible
UNREACHABLE("Coding error: unhandled AI goal in ai_add_goal_sub_sexp!");
break;
@@ -1050,12 +1094,16 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name )
aigp->ai_mode = AI_GOAL_LUA;
aigp->ai_submode = op;
object_ship_wing_point_team target;
if(luaAIMode->needsTarget) {
eval_object_ship_wing_point_team(&aigp->lua_ai_target, localnode);
eval_object_ship_wing_point_team(&target, localnode);
localnode = CDR(localnode);
}
aigp->priority = atoi( CTEXT(localnode) );
aigp->lua_ai_target = { std::move(target), luaAIMode->sexp.getSEXPArgumentList(CDR(localnode)) };
}
else {
UNREACHABLE("Invalid SEXP-OP number %d for an AI goal!", op);
@@ -1081,12 +1129,7 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name )
// don't assign the goal if the actor's goal target is itself
if (aigp->target_name != NULL && !strcmp(aigp->target_name, actor_name))
{
// based on ai_remove_ship_goal, these seem to be the only statements
// necessary to cause this goal to "never have been assigned"
aigp->ai_mode = AI_GOAL_NONE;
aigp->signature = -1;
aigp->priority = -1;
aigp->flags.reset();
ai_goal_reset(aigp);
}
}
@@ -1239,6 +1282,14 @@ int ai_remove_goal_sexp_sub( int sexp, ai_goal* aigp )
priority = 99;
goalmode = AI_GOAL_FORM_ON_WING;
break;
case OP_AI_FLY_TO_SHIP:
priority = ( CDR( CDR(node) ) >= 0 ) ? atoi( CTEXT( CDR( CDR( node ) ) ) ) : -1;
goalmode = AI_GOAL_FLY_TO_SHIP;
break;
case OP_AI_REARM_REPAIR:
priority = ( CDR( CDR(node) ) >= 0 ) ? atoi( CTEXT( CDR( CDR( node ) ) ) ) : -1;
goalmode = AI_GOAL_REARM_REPAIR;
break;
default:
const ai_mode_lua* luaAIMode = ai_lua_find_mode(op);
if(luaAIMode != nullptr){
@@ -1268,10 +1319,7 @@ int ai_remove_goal_sexp_sub( int sexp, ai_goal* aigp )
/* Clear out the contents of the goal. We can't use ai_remove_ship_goal since it needs ai_info and
* we've only got ai_goals */
aigp[goalindex].ai_mode = AI_GOAL_NONE;
aigp[goalindex].signature = -1;
aigp[goalindex].priority = -1;
aigp[goalindex].flags.reset(); // must reset the flags since not doing so will screw up goal sorting.
ai_goal_reset(&aigp[goalindex]);
return goalindex;
}
@@ -1309,7 +1357,7 @@ void ai_add_ship_goal_sexp( int sexp, int type, ai_info *aip )
int gindex;
gindex = ai_goal_find_empty_slot( aip->goals, aip->active_goal );
ai_add_goal_sub_sexp( sexp, type, &aip->goals[gindex], Ships[aip->shipnum].ship_name );
ai_add_goal_sub_sexp( sexp, type, aip, &aip->goals[gindex], Ships[aip->shipnum].ship_name );
}
// code to add ai goals to wings.
@@ -1333,7 +1381,7 @@ void ai_add_wing_goal_sexp(int sexp, int type, wing *wingp)
int gindex;
gindex = ai_goal_find_empty_slot( wingp->ai_goals, -1 );
ai_add_goal_sub_sexp( sexp, type, &wingp->ai_goals[gindex], wingp->name );
ai_add_goal_sub_sexp( sexp, type, nullptr, &wingp->ai_goals[gindex], wingp->name );
}
}
@@ -1364,12 +1412,9 @@ void ai_add_goal_ship_internal( ai_info *aip, int goal_type, char *name, int /*
// find an empty slot to put this goal in.
gindex = ai_goal_find_empty_slot( aip->goals, aip->active_goal );
aigp = &(aip->goals[gindex]);
ai_goal_reset(aigp, true);
aigp->signature = Ai_goal_signature++;
aigp->time = Missiontime;
aigp->type = AIG_TYPE_DYNAMIC;
aigp->flags.reset();
aigp->flags.set(AI::Goal_Flags::Goal_override);
switch ( goal_type ) {
@@ -1453,12 +1498,11 @@ ai_achievability ai_mission_goal_achievable( int objnum, ai_goal *aigp )
{
int status;
ai_achievability return_val;
object *objp;
ai_info *aip;
int index = -1, sindex = -1;
int modelnum = -1;
objp = &Objects[objnum];
auto objp = &Objects[objnum];
Assert( objp->instance != -1 );
aip = &Ai_info[Ships[objp->instance].ai_index];
@@ -1521,8 +1565,11 @@ ai_achievability ai_mission_goal_achievable( int objnum, ai_goal *aigp )
// if not, the status is not known because more ships of that class could arrive in the future
// (c.f. AI_GOAL_CHASE_WING subsequent to the next switch statement)
if ( aigp->ai_mode == AI_GOAL_CHASE_SHIP_CLASS ) {
for (objp = GET_FIRST(&obj_used_list); objp != END_OF_LIST(&obj_used_list); objp = GET_NEXT(objp)) {
if ((objp->type == OBJ_SHIP) && !strcmp(aigp->target_name, Ship_info[Ships[objp->instance].ship_info_index].name)) {
for (auto so: list_range(&Ship_obj_list)) {
auto class_objp = &Objects[so->objnum];
if (class_objp->flags[Object::Object_Flags::Should_be_dead])
continue;
if ((class_objp->type == OBJ_SHIP) && !strcmp(aigp->target_name, Ship_info[Ships[class_objp->instance].ship_info_index].name)) {
return ai_achievability::ACHIEVABLE;
}
}
@@ -2400,13 +2447,14 @@ void ai_process_mission_orders( int objnum, ai_info *aip )
break;
case AI_GOAL_FORM_ON_WING:
// get the ship first, since we're going to wipe it out next
shipnum = ship_name_lookup( current_goal->target_name );
Assert( shipnum >= 0 );
other_obj = &Objects[Ships[shipnum].objnum];
// for form on wing, we need to clear out all goals for this ship, and then call the form
// on wing AI code
// clearing out goals is okay here since we are now what mode to set this AI object to.
ai_clear_ship_goals( aip );
shipnum = ship_name_lookup( current_goal->target_name );
Assert( shipnum >= 0 );
other_obj = &Objects[Ships[shipnum].objnum];
ai_form_on_wing( objp, other_obj );
break;
@@ -2416,8 +2464,7 @@ void ai_process_mission_orders( int objnum, ai_info *aip )
shipnum = ship_name_lookup( current_goal->target_name );
Assert( shipnum >= 0 );
other_obj = &Objects[Ships[shipnum].objnum];
// todo MK: hook to keep support ship near other_obj -- other_obj could be the player object!!!
float dist = 300.0f; // How far away to stay from ship. Should be set in SEXP?
float dist = current_goal->float_data; // How far away to stay from ship. Should be set in SEXP?
ai_do_stay_near(objp, other_obj, dist);
break;
}
+66 -4
View File
@@ -12,16 +12,30 @@
#ifndef _AIGOALS_H
#define _AIGOALS_H
#include "ai/ai_flags.h"
#include "globalincs/globals.h"
#include "globalincs/pstypes.h"
#include "parse/sexp.h"
#include "scripting/lua/LuaTypes.h"
#include "scripting/lua/LuaValue.h"
struct wing;
struct ai_info;
struct ai_goal;
// macros for goals which get set via sexpressions in the mission code
// types of ai goals -- tyese types will help us to determination on which goals should
// have priority over others (i.e. when a player issues a goal to a wing, then a seperate
// goal to a ship in that wing). We would probably use this type in conjunction with
// goal priority to establish which goal to follow
#define AIG_TYPE_EVENT_SHIP 1 // from mission event direct to ship
#define AIG_TYPE_EVENT_WING 2 // from mission event direct to wing
#define AIG_TYPE_PLAYER_SHIP 3 // from player direct to ship
#define AIG_TYPE_PLAYER_WING 4 // from player direct to wing
#define AIG_TYPE_DYNAMIC 5 // created on the fly
#define AI_GOAL_NONE -1
// IMPORTANT! If you add a new AI_GOAL_x define, be sure to update the functions
// ai_update_goal_references() and query_referenced_in_ai_goals() or else risk breaking
// Fred. If the goal you add doesn't have a target (such as chase_any), then you don't have
@@ -86,6 +100,51 @@ struct ai_goal;
enum class ai_achievability { ACHIEVABLE, NOT_ACHIEVABLE, NOT_KNOWN, SATISFIED };
struct ai_lua_parameters {
object_ship_wing_point_team target;
luacpp::LuaValueList arguments;
};
// structure for AI goals
typedef struct ai_goal {
int signature; // Unique identifier. All goals ever created (per mission) have a unique signature.
int ai_mode; // one of the AIM_* modes for this goal
int ai_submode; // maybe need a submode
int type; // one of the AIG_TYPE_* values above
flagset<AI::Goal_Flags> flags; // one of the AIGF_* values above
fix time; // time at which this goal was issued.
int priority; // how important is this goal -- number 0 - 100
const char *target_name; // name of the thing that this goal acts upon
int target_name_index; // index of goal_target_name in Goal_target_names[][]
waypoint_list *wp_list; // waypoints that this ship might fly.
int target_instance; // instance of thing this ship might be chasing (currently only used for weapons; note, not the same as objnum!)
int target_signature; // signature of object this ship might be chasing (currently only used for weapons; paired with above value to confirm target)
// extra goal-specific data
int int_data;
float float_data;
// unions for docking stuff.
// (AIGF_DOCKER_INDEX_VALID and AIGF_DOCKEE_INDEX_VALID tell us to use indexes; otherwise we use names)
// these are the dockpoints used on the docker and dockee ships, not the ships themselves
union {
const char *name;
int index;
} docker;
union {
const char *name;
int index;
} dockee;
ai_lua_parameters lua_ai_target;
} ai_goal;
extern void ai_goal_reset(ai_goal *aigp, bool adding_goal = false, int ai_mode = AI_GOAL_NONE, int ai_submode = -1, int type = -1);
typedef flag_def_list ai_goal_list;
extern ai_goal_list Ai_goal_names[];
@@ -96,6 +155,9 @@ extern char Ai_dock_names[MAX_AI_DOCK_NAMES][NAME_LENGTH];
extern const char *Ai_goal_text(int goal, int submode);
// every goal in a mission gets a unique signature
extern int Ai_goal_signature;
// extern function definitions
extern void ai_post_process_mission();
extern void ai_maybe_add_form_goal( wing *wingp );
@@ -107,14 +169,14 @@ extern int ai_goal_num(ai_goal *goals);
extern void ai_add_ship_goal_scripting(int mode, int submode, int priority, char *shipname, ai_info *aip);
extern void ai_add_ship_goal_sexp( int sexp, int type, ai_info *aip );
extern void ai_add_wing_goal_sexp( int sexp, int type, wing *wingp );
extern void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name);
extern void ai_add_goal_sub_sexp( int sexp, int type, ai_info *aip, ai_goal *aigp, char *actor_name);
extern int ai_remove_goal_sexp_sub( int sexp, ai_goal* aigp );
extern void ai_remove_wing_goal_sexp( int sexp, wing *wingp );
// adds goals to ships/sings through player orders
extern void ai_add_ship_goal_player( int type, int mode, int submode, char *shipname, ai_info *aip, const object_ship_wing_point_team& lua_target = object_ship_wing_point_team());
extern void ai_add_wing_goal_player( int type, int mode, int submode, char *shipname, int wingnum, const object_ship_wing_point_team& lua_target = object_ship_wing_point_team());
extern void ai_add_ship_goal_player(int type, int mode, int submode, char* shipname, ai_info* aip, const ai_lua_parameters& lua_target = { object_ship_wing_point_team(), luacpp::LuaValueList{} });
extern void ai_add_wing_goal_player(int type, int mode, int submode, char* shipname, int wingnum, const ai_lua_parameters& lua_target = { object_ship_wing_point_team(), luacpp::LuaValueList{} });
extern void ai_remove_ship_goal( ai_info *aip, int index );
extern void ai_clear_ship_goals( ai_info *aip );
+65 -71
View File
@@ -58,7 +58,10 @@ void run_ai_lua_action(const luacpp::LuaFunction& action, const ai_mode_lua& lua
luacpp::LuaValueList luaParameters;
luaParameters.push_back(luacpp::LuaValue::createValue(action.getLuaState(), scripting::api::l_AI_Helper.Set(object_h(&Objects[Ships[aip->shipnum].objnum]))));
if (lua_ai.needsTarget) {
luaParameters.push_back(luacpp::LuaValue::createValue(action.getLuaState(), scripting::api::l_OSWPT.Set(aip->lua_ai_target)));
luaParameters.push_back(luacpp::LuaValue::createValue(action.getLuaState(), scripting::api::l_OSWPT.Set(aip->lua_ai_target.target)));
}
for (const auto& additionalParam : aip->lua_ai_target.arguments) {
luaParameters.push_back(additionalParam);
}
auto retVals = action.call(Script_system.GetLuaSession(), luaParameters);
@@ -74,14 +77,10 @@ void ai_lua(ai_info* aip){
const auto& lua_ai = Lua_ai_modes.at(aip->submode);
auto dynamicSEXP = sexp::get_dynamic_sexp(aip->submode);
const auto& lua_ai_sexp = lua_ai.sexp;
const auto& action = lua_ai_sexp.getAction();
if (dynamicSEXP != nullptr && typeid(*dynamicSEXP) == typeid(sexp::LuaAISEXP)) {
auto lua_ai_sexp = static_cast<sexp::LuaAISEXP*>(dynamicSEXP);
const auto& action = lua_ai_sexp->getActionFrame();
run_ai_lua_action(action, lua_ai, aip);
}
run_ai_lua_action(action, lua_ai, aip);
}
void ai_lua_start(ai_goal* aigp, object* objp){
@@ -98,15 +97,10 @@ void ai_lua_start(ai_goal* aigp, object* objp){
const auto& lua_ai = Lua_ai_modes.at(aigp->ai_submode);
auto dynamicSEXP = sexp::get_dynamic_sexp(aigp->ai_submode);
const auto& lua_ai_sexp = lua_ai.sexp;
const auto& action = lua_ai_sexp.getActionEnter();
if (dynamicSEXP != nullptr && typeid(*dynamicSEXP) == typeid(sexp::LuaAISEXP)) {
auto lua_ai_sexp = static_cast<sexp::LuaAISEXP*>(dynamicSEXP);
const auto& action = lua_ai_sexp->getActionEnter();
run_ai_lua_action(action, lua_ai, aip);
}
run_ai_lua_action(action, lua_ai, aip);
}
bool ai_lua_is_valid_target_intrinsic(int sexp_op, int target_objnum, ship* self) {
@@ -139,36 +133,32 @@ bool ai_lua_is_valid_target_intrinsic(int sexp_op, int target_objnum, ship* self
return false;
}
bool ai_lua_is_valid_target_lua(const ai_mode_lua& mode, int sexp_op, int target_objnum, ship* self) {
auto dynamicSEXP = sexp::get_dynamic_sexp(sexp_op);
bool ai_lua_is_valid_target_lua(const ai_mode_lua& mode, int target_objnum, ship* self) {
if (dynamicSEXP != nullptr && typeid(*dynamicSEXP) == typeid(sexp::LuaAISEXP)) {
auto lua_ai_sexp = static_cast<sexp::LuaAISEXP*>(dynamicSEXP);
const auto& action = lua_ai_sexp->getTargetRestrict();
const auto& action = mode.sexp.getTargetRestrict();
if (!action.isValid())
return true;
if (!action.isValid())
return true;
luacpp::LuaValueList luaParameters;
luaParameters.push_back(luacpp::LuaValue::createValue(action.getLuaState(), scripting::api::l_Ship.Set(object_h(&Objects[self->objnum]))));
if (mode.needsTarget) {
luaParameters.push_back(luacpp::LuaValue::createValue(action.getLuaState(), scripting::api::l_OSWPT.Set(object_ship_wing_point_team(&Ships[Objects[target_objnum].instance]))));
}
luacpp::LuaValueList luaParameters;
luaParameters.push_back(luacpp::LuaValue::createValue(action.getLuaState(), scripting::api::l_Ship.Set(object_h(&Objects[self->objnum]))));
if (mode.needsTarget) {
luaParameters.push_back(luacpp::LuaValue::createValue(action.getLuaState(), scripting::api::l_OSWPT.Set(object_ship_wing_point_team(&Ships[Objects[target_objnum].instance]))));
}
auto retVals = action.call(Script_system.GetLuaSession(), luaParameters);
auto retVals = action.call(Script_system.GetLuaSession(), luaParameters);
if (!retVals.empty() && retVals[0].getValueType() == luacpp::ValueType::BOOLEAN) {
return retVals[0].getValue<bool>();
}
else {
Error(LOCATION, "LuaAI target restriction function did not return a valid boolean!");
}
if (!retVals.empty() && retVals[0].getValueType() == luacpp::ValueType::BOOLEAN) {
return retVals[0].getValue<bool>();
}
else {
Error(LOCATION, "LuaAI target restriction function did not return a valid boolean!");
}
return true;
}
bool ai_lua_is_valid_target(int sexp_op, int target_objnum, ship* self) {
bool ai_lua_is_valid_target(int sexp_op, int target_objnum, ship* self, size_t order) {
const ai_mode_lua& mode = *ai_lua_find_mode(sexp_op);
//All targetless AI modes are fine
@@ -184,56 +174,60 @@ bool ai_lua_is_valid_target(int sexp_op, int target_objnum, ship* self) {
if (!ai_lua_is_valid_target_intrinsic(sexp_op, target_objnum, self))
return false;
// check if this order can be issued against the target
ship *shipp = &Ships[Objects[target_objnum].instance];
if (shipp->orders_allowed_against.find(order) == shipp->orders_allowed_against.end()) {
return false;
}
}
//If we haven't bailed yet, query the custom callback
return ai_lua_is_valid_target_lua(mode, sexp_op, target_objnum, self);
return ai_lua_is_valid_target_lua(mode, target_objnum, self);
}
ai_achievability ai_lua_is_achievable(const ai_goal* aigp, int objnum){
const auto& lua_ai = Lua_ai_modes.at(aigp->ai_submode);
auto dynamicSEXP = sexp::get_dynamic_sexp(aigp->ai_submode);
const auto& action = lua_ai.sexp.getAchievable();
if (dynamicSEXP != nullptr && typeid(*dynamicSEXP) == typeid(sexp::LuaAISEXP)) {
auto lua_ai_sexp = static_cast<sexp::LuaAISEXP*>(dynamicSEXP);
const auto& action = lua_ai_sexp->getAchievable();
if (!action.isValid())
return ai_achievability::ACHIEVABLE;
if (!action.isValid())
luacpp::LuaValueList luaParameters;
luaParameters.push_back(luacpp::LuaValue::createValue(action.getLuaState(), scripting::api::l_Ship.Set(object_h(&Objects[objnum]))));
if (lua_ai.needsTarget) {
luaParameters.push_back(luacpp::LuaValue::createValue(action.getLuaState(), scripting::api::l_OSWPT.Set(aigp->lua_ai_target.target)));
}
for (const auto& additionalParam : aigp->lua_ai_target.arguments) {
luaParameters.push_back(additionalParam);
}
auto retVals = action.call(Script_system.GetLuaSession(), luaParameters);
if (!retVals.empty() && retVals[0].getValueType() == luacpp::ValueType::USERDATA) {
scripting::api::enum_h enumData;
retVals[0].getValue(scripting::api::l_Enum.Get(&enumData));
if (!enumData.IsValid()) {
Error(LOCATION, "LuaAI SEXP achievability hook returned an invalid avilability enum.");
return ai_achievability::ACHIEVABLE;
luacpp::LuaValueList luaParameters;
luaParameters.push_back(luacpp::LuaValue::createValue(action.getLuaState(), scripting::api::l_Ship.Set(object_h(&Objects[objnum]))));
if (lua_ai.needsTarget) {
luaParameters.push_back(luacpp::LuaValue::createValue(action.getLuaState(), scripting::api::l_OSWPT.Set(aigp->lua_ai_target)));
}
auto retVals = action.call(Script_system.GetLuaSession(), luaParameters);
if (!retVals.empty() && retVals[0].getValueType() == luacpp::ValueType::USERDATA) {
scripting::api::enum_h enumData;
retVals[0].getValue(scripting::api::l_Enum.Get(&enumData));
if (!enumData.IsValid()) {
Error(LOCATION, "LuaAI SEXP achievability hook returned an invalid avilability enum.");
return ai_achievability::ACHIEVABLE;
}
switch (enumData.index) {
case scripting::api::LE_LUAAI_ACHIEVABLE:
return ai_achievability::ACHIEVABLE;
case scripting::api::LE_LUAAI_NOT_YET_ACHIEVABLE:
return ai_achievability::NOT_KNOWN;
case scripting::api::LE_LUAAI_UNACHIEVABLE:
return ai_achievability::NOT_ACHIEVABLE;
default:
Error(LOCATION, "LuaAI SEXP achievability hook returned an invalid avilability enum.");
return ai_achievability::ACHIEVABLE;
}
}
else {
Error(LOCATION, "LuaAI SEXP achievability hook did not return any avilability enum!");
switch (enumData.index) {
case scripting::api::LE_LUAAI_ACHIEVABLE:
return ai_achievability::ACHIEVABLE;
case scripting::api::LE_LUAAI_NOT_YET_ACHIEVABLE:
return ai_achievability::NOT_KNOWN;
case scripting::api::LE_LUAAI_UNACHIEVABLE:
return ai_achievability::NOT_ACHIEVABLE;
default:
Error(LOCATION, "LuaAI SEXP achievability hook returned an invalid avilability enum.");
return ai_achievability::ACHIEVABLE;
}
}
else {
Error(LOCATION, "LuaAI SEXP achievability hook did not return any avilability enum!");
}
return ai_achievability::ACHIEVABLE;
}
+6 -1
View File
@@ -4,9 +4,13 @@
#include "ai/aigoals.h"
#include "mission/missionmessage.h"
#include "ship/ship.h"
#include "parse/sexp.h"
#include "globalincs/globals.h"
namespace sexp { class LuaAISEXP; }
struct ai_mode_lua {
const sexp::LuaAISEXP& sexp;
bool needsTarget;
const char* hudText;
};
@@ -18,6 +22,7 @@ struct player_order_lua {
enum class target_restrictions : int { TARGET_ALLIES, TARGET_ALL, TARGET_OWN, TARGET_ENEMIES, TARGET_SAME_WING, TARGET_PLAYER_WING, TARGET_ALL_CAPS, TARGET_ALLIED_CAPS, TARGET_ENEMY_CAPS, TARGET_NOT_SELF } targetRestrictions = target_restrictions::TARGET_ALL;
};
void ai_lua_add_mode(int sexp_op, const ai_mode_lua& mode);
bool ai_lua_add_order(int sexp_op, player_order_lua order);
bool ai_lua_has_mode(int sexp_op);
@@ -25,5 +30,5 @@ const ai_mode_lua* ai_lua_find_mode(int sexp_op);
const player_order_lua* ai_lua_find_player_order(int sexp_op);
void ai_lua(ai_info* aip);
void ai_lua_start(ai_goal* aigp, object* objp);
bool ai_lua_is_valid_target(int sexp_op, int target_objnum, ship* self);
bool ai_lua_is_valid_target(int sexp_op, int target_objnum, ship* self, size_t order);
ai_achievability ai_lua_is_achievable(const ai_goal* aigp, int objnum);
+119 -44
View File
@@ -14,6 +14,7 @@
#include "network/multi.h"
#include "network/multimsgs.h"
#include "object/objectdock.h"
#include "scripting/global_hooks.h"
#include "scripting/scripting.h"
#include "render/3d.h"
#include "ship/ship.h"
@@ -765,7 +766,6 @@ int get_nearest_turret_objnum(int turret_parent_objnum, ship_subsys *turret_subs
{
//float weapon_travel_dist;
int weapon_system_ok;
object *objp;
eval_enemy_obj_struct eeo;
ship_weapon *swp = &turret_subsys->weapons;
@@ -862,9 +862,10 @@ int get_nearest_turret_objnum(int turret_parent_objnum, ship_subsys *turret_subs
int n_w_classes = (int)tt->weapon_class.size();
bool found_something;
object *ptr = GET_FIRST(&obj_used_list);
while (ptr != END_OF_LIST(&obj_used_list)) {
for (auto ptr: list_range(&obj_used_list)) {
if (ptr->flags[Object::Object_Flags::Should_be_dead])
continue;
found_something = false;
if(tt->obj_type > -1 && (ptr->type == tt->obj_type)) {
@@ -915,15 +916,10 @@ int get_nearest_turret_objnum(int turret_parent_objnum, ship_subsys *turret_subs
if(!(found_something)) {
//we didnt find this object within this priority group
//skip to next without evaluating the object as target
ptr = GET_NEXT(ptr);
continue;
}
evaluate_obj_as_target(ptr, &eeo);
ptr = GET_NEXT(ptr);
}
//homing weapon entry...
@@ -994,8 +990,10 @@ int get_nearest_turret_objnum(int turret_parent_objnum, ship_subsys *turret_subs
{
// Missile_obj_list
for( mo = GET_FIRST(&Missile_obj_list); mo != END_OF_LIST(&Missile_obj_list); mo = GET_NEXT(mo) ) {
objp = &Objects[mo->objnum];
auto objp = &Objects[mo->objnum];
if (objp->flags[Object::Object_Flags::Should_be_dead])
continue;
Assert(objp->type == OBJ_WEAPON);
if ((Weapon_info[Weapons[objp->instance].weapon_info_index].wi_flags[Weapon::Info_Flags::Bomb]) || (Weapon_info[Weapons[objp->instance].weapon_info_index].wi_flags[Weapon::Info_Flags::Turret_Interceptable]))
{
@@ -1015,7 +1013,9 @@ int get_nearest_turret_objnum(int turret_parent_objnum, ship_subsys *turret_subs
//Return if a ship is found
// Ship_used_list
for ( so = GET_FIRST(&Ship_obj_list); so != END_OF_LIST(&Ship_obj_list); so = GET_NEXT(so) ) {
objp = &Objects[so->objnum];
auto objp = &Objects[so->objnum];
if (objp->flags[Object::Object_Flags::Should_be_dead])
continue;
evaluate_obj_as_target(objp, &eeo);
}
@@ -1043,7 +1043,9 @@ int get_nearest_turret_objnum(int turret_parent_objnum, ship_subsys *turret_subs
if ( !all_turret_weapons_have_flags(swp, tmp_flagset) ) {
// Asteroid_obj_list
for ( ao = GET_FIRST(&Asteroid_obj_list); ao != END_OF_LIST(&Asteroid_obj_list); ao = GET_NEXT(ao) ) {
objp = &Objects[ao->objnum];
auto objp = &Objects[ao->objnum];
if (objp->flags[Object::Object_Flags::Should_be_dead])
continue;
evaluate_obj_as_target(objp, &eeo);
}
@@ -1319,7 +1321,7 @@ int aifft_rotate_turret(object *objp, ship *shipp, ship_subsys *ss, object *lep,
if (ss->turret_enemy_objnum != -1) {
model_subsystem *tp = ss->system_info;
vec3d gun_pos, gun_vec, target_moving_direction;
vec3d gun_pos, gun_vec, target_vel;
//float weapon_speed;
float weapon_system_strength;
//HACK HACK HACK -WMC
@@ -1357,14 +1359,33 @@ int aifft_rotate_turret(object *objp, ship *shipp, ship_subsys *ss, object *lep,
}
}
target_moving_direction = ss->last_aim_enemy_vel;
target_vel = ss->last_aim_enemy_vel;
//Try to guess where the enemy will be, and store that spot in predicted_enemy_pos
if (The_mission.ai_profile->flags[AI::Profile_Flags::Use_additive_weapon_velocity]) {
vm_vec_scale_sub2(&target_moving_direction, &objp->phys_info.vel, wip->vel_inherit_amount);
vm_vec_scale_sub2(&target_vel, &objp->phys_info.vel, wip->vel_inherit_amount);
}
set_predicted_enemy_pos_turret(predicted_enemy_pos, &gun_pos, objp, &enemy_point, &target_moving_direction, wip->max_speed, ss->turret_time_enemy_in_range * (weapon_system_strength + 1.0f)/2.0f);
if (tp->flags[Model::Subsystem_Flags::Turret_distant_firepoint] || Always_use_distant_firepoints) {
//The firing point of this turret is so far away from the its center that we should consider this for firing calculations
//This will do the enemy position prediction based on their relative position and speed to the firing point, not the turret center.
vec3d temp;
ship_get_global_turret_gun_info(objp, ss, &gun_pos, &temp, 1, nullptr);
}
if (IS_VEC_NULL(&The_mission.gravity) || wip->gravity_const == 0.0f)
set_predicted_enemy_pos_turret(predicted_enemy_pos, &gun_pos, objp, &enemy_point, &target_vel, wip->max_speed, ss->turret_time_enemy_in_range * (weapon_system_strength + 1.0f)/2.0f);
else {
vec3d shoot_vec;
if (physics_lead_ballistic_trajectory(&gun_pos, &enemy_point, &target_vel, wip->max_speed, &The_mission.gravity, &shoot_vec)) {
*predicted_enemy_pos = gun_pos + shoot_vec * 1000.0f;
} else {
if ((ss->system_info->flags[Model::Subsystem_Flags::Turret_reset_idle]) && (timestamp_elapsed(ss->rotation_timestamp))) {
ret_val = model_rotate_gun(objp, pm, pmi, ss, predicted_enemy_pos, true);
}
return ret_val;
}
}
//Mess with the turret's accuracy if the weapon system is damaged.
if (weapon_system_strength < Weapon_SS_Threshold_Turret_Inaccuracy) {
@@ -1643,11 +1664,21 @@ void turret_set_next_fire_timestamp(int weapon_num, weapon_info *wip, ship_subsy
if (wip->wi_flags[Weapon::Info_Flags::Flak]) {
wait *= aip->ai_ship_fire_delay_scale_friendly * 0.5f;
if (aip->ai_class_autoscale)
wait += (Num_ai_classes - aip->ai_class - 1) * 40.0f;
{
if (The_mission.ai_profile->flags[AI::Profile_Flags::Adjusted_AI_class_autoscale])
wait += (ai_get_autoscale_index(Num_ai_classes) - ai_get_autoscale_index(aip->ai_class) - 1) * 40.0f;
else
wait += (Num_ai_classes - aip->ai_class - 1) * 40.0f;
}
} else {
wait *= aip->ai_ship_fire_delay_scale_friendly;
if (aip->ai_class_autoscale)
wait += (Num_ai_classes - aip->ai_class - 1) * 100.0f;
{
if (The_mission.ai_profile->flags[AI::Profile_Flags::Adjusted_AI_class_autoscale])
wait += (ai_get_autoscale_index(Num_ai_classes) - ai_get_autoscale_index(aip->ai_class) - 1) * 100.0f;
else
wait += (Num_ai_classes - aip->ai_class - 1) * 100.0f;
}
}
} else {
// flak guns need to fire more rapidly
@@ -1658,13 +1689,23 @@ void turret_set_next_fire_timestamp(int weapon_num, weapon_info *wip, ship_subsy
wait *= aip->ai_ship_fire_delay_scale_hostile * 0.5f;
}
if (aip->ai_class_autoscale)
wait += (Num_ai_classes - aip->ai_class - 1) * 40.0f;
{
if (The_mission.ai_profile->flags[AI::Profile_Flags::Adjusted_AI_class_autoscale])
wait += (ai_get_autoscale_index(Num_ai_classes) - ai_get_autoscale_index(aip->ai_class) - 1) * 40.0f;
else
wait += (Num_ai_classes - aip->ai_class - 1) * 40.0f;
}
} else if (wip->wi_flags[Weapon::Info_Flags::Huge]) {
// make huge weapons fire independently of team
wait *= aip->ai_ship_fire_delay_scale_friendly;
if (aip->ai_class_autoscale)
wait += (Num_ai_classes - aip->ai_class - 1) * 100.0f;
{
if (The_mission.ai_profile->flags[AI::Profile_Flags::Adjusted_AI_class_autoscale])
wait += (ai_get_autoscale_index(Num_ai_classes) - ai_get_autoscale_index(aip->ai_class) - 1) * 100.0f;
else
wait += (Num_ai_classes - aip->ai_class - 1) * 100.0f;
}
} else {
// give team friendly an advantage
if (Ships[aip->shipnum].team == Player_ship->team) {
@@ -1673,7 +1714,12 @@ void turret_set_next_fire_timestamp(int weapon_num, weapon_info *wip, ship_subsy
wait *= aip->ai_ship_fire_delay_scale_hostile;
}
if (aip->ai_class_autoscale)
wait += (Num_ai_classes - aip->ai_class - 1) * 100.0f;
{
if (The_mission.ai_profile->flags[AI::Profile_Flags::Adjusted_AI_class_autoscale])
wait += (ai_get_autoscale_index(Num_ai_classes) - ai_get_autoscale_index(aip->ai_class) - 1) * 100.0f;
else
wait += (Num_ai_classes - aip->ai_class - 1) * 100.0f;
}
}
}
// vary wait time +/- 10%
@@ -1842,10 +1888,13 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
parent_ship->last_fired_turret = turret;
turret->last_fired_weapon_info_index = turret_weapon_class;
if (Script_system.IsActiveAction(CHA_ONTURRETFIRED)) {
Script_system.SetHookObjects(4, "Ship", &Objects[parent_objnum], "Weapon", nullptr, "Beam", objp, "Target", turret_enemy_objp);
Script_system.RunCondition(CHA_ONTURRETFIRED, &Objects[parent_objnum], objp);
Script_system.RemHookVars({"Ship", "Weapon", "Beam", "Target"});
if (scripting::hooks::OnTurretFired->isActive()) {
scripting::hooks::OnTurretFired->run(scripting::hooks::WeaponUsedConditions{ parent_ship , turret_enemy_objp, turret_weapon_class, true },
scripting::hook_param_list(
scripting::hook_param("Ship", 'o', &Objects[parent_objnum]),
scripting::hook_param("Beam", 'o', objp),
scripting::hook_param("Target", 'o', turret_enemy_objp)
));
}
}
@@ -1985,10 +2034,13 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
// AL 1-6-97: Store pointer to turret subsystem
wp->turret_subsys = turret;
if (Script_system.IsActiveAction(CHA_ONTURRETFIRED)) {
Script_system.SetHookObjects(4, "Ship", &Objects[parent_objnum], "Weapon", objp, "Beam", nullptr, "Target", turret_enemy_objp);
Script_system.RunCondition(CHA_ONTURRETFIRED, &Objects[parent_objnum], objp);
Script_system.RemHookVars({"Ship", "Weapon", "Beam", "Target"});
if (scripting::hooks::OnTurretFired->isActive()) {
scripting::hooks::OnTurretFired->run(scripting::hooks::WeaponUsedConditions{ parent_ship , turret_enemy_objp, turret_weapon_class, wip->subtype == WP_LASER },
scripting::hook_param_list(
scripting::hook_param("Ship", 'o', &Objects[parent_objnum]),
scripting::hook_param("Weapon", 'o', objp),
scripting::hook_param("Target", 'o', turret_enemy_objp)
));
}
// if the gun is a flak gun
@@ -2052,7 +2104,8 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
turret->flags.set(Ship::Subsystem_Flags::Has_fired); //set has fired flag for scriptng - nuke
//Fire animation stuff
Ship_info[parent_ship->ship_info_index].animations.start(model_get_instance(parent_ship->model_instance_num), animation::ModelAnimationTriggerType::TurretFired, animation::anim_name_from_subsys(turret->system_info), animation::ModelAnimationDirection::FWD, true);
Ship_info[parent_ship->ship_info_index].animations.get(model_get_instance(parent_ship->model_instance_num), animation::ModelAnimationTriggerType::TurretFired, animation::anim_name_from_subsys(turret->system_info))
.start(animation::ModelAnimationDirection::FWD, true);
return true;
}
@@ -2103,10 +2156,17 @@ void turret_swarm_fire_from_turret(turret_swarm_info *tsi)
Ships[Objects[tsi->parent_objnum].instance].last_fired_turret = tsi->turret;
tsi->turret->last_fired_weapon_info_index = tsi->weapon_class;
if (Script_system.IsActiveAction(CHA_ONTURRETFIRED)) {
Script_system.SetHookObjects(4, "Ship", &Objects[tsi->parent_objnum], "Weapon", &Objects[weapon_objnum], "Beam", nullptr, "Target", &Objects[tsi->turret->turret_enemy_objnum]);
Script_system.RunCondition(CHA_ONTURRETFIRED, &Objects[tsi->parent_objnum], &Objects[weapon_objnum]);
Script_system.RemHookVars({"Ship", "Weapon", "Beam", "Target"});
if (scripting::hooks::OnTurretFired->isActive()) {
scripting::hooks::OnTurretFired->run(scripting::hooks::WeaponUsedConditions{
&Ships[Objects[tsi->parent_objnum].instance],
&Objects[tsi->turret->turret_enemy_objnum],
tsi->weapon_class, Weapon_info[tsi->weapon_class].subtype == WP_LASER
},
scripting::hook_param_list(
scripting::hook_param("Ship", 'o', &Objects[tsi->parent_objnum]),
scripting::hook_param("Weapon", 'o', &Objects[weapon_objnum]),
scripting::hook_param("Target", 'o', &Objects[tsi->turret->turret_enemy_objnum])
));
}
// muzzle flash?
@@ -2234,6 +2294,12 @@ void ai_turret_execute_behavior(ship *shipp, ship_subsys *ss)
// Rotate the turret even if time hasn't elapsed, since it needs to turn to face its target.
int use_angles = aifft_rotate_turret(objp, shipp, ss, lep, &predicted_enemy_pos, &gvec);
// Multiplayer clients are now able to try to track their targets and also reset to their idle positions.
// But everything after this point is turret firing, so we need to bail here.
if (MULTIPLAYER_CLIENT) {
return;
}
if ((tp->flags[Model::Subsystem_Flags::Fire_on_target]) && (ss->points_to_target >= 0.0f))
{
// value probably needs tweaking... could perhaps be made into table option?
@@ -2338,6 +2404,15 @@ void ai_turret_execute_behavior(ship *shipp, ship_subsys *ss)
}
}
// If the barrel of this turret is long, we shouldn't try to fire if the enemy is under the gun.
// Note that this isn't the same thing as min_range, which is unrelated to barrel length.
if (tp->flags[Model::Subsystem_Flags::Turret_distant_firepoint] || Always_use_distant_firepoints) {
vec3d fpoint, fvec;
ship_get_global_turret_gun_info(objp, ss, &fpoint, &fvec, use_angles, &predicted_enemy_pos);
auto barrel_length = vm_vec_dist(&fpoint, &gpos);
if (dist_to_enemy < barrel_length) continue;
}
// Don't try to fire beyond weapon_limit_range (or within min range)
if (dist_to_enemy < weapon_min_range || dist_to_enemy > weapon_firing_range) {
// it's possible another weapon is in range, but if not,
@@ -2526,7 +2601,9 @@ void ai_turret_execute_behavior(ship *shipp, ship_subsys *ss)
bool in_fov = turret_fov_test(ss, &gvec, &v2e);
bool something_was_ok_to_fire = false;
if (in_fov) {
// the only reason predicted_enemy_pos might be zero, while everything else is valid is if
// its a ballistic trajectory with no valid path
if (in_fov && num_valid && predicted_enemy_pos != vmd_zero_vector) {
// Do salvo thing separately - to prevent messing up things
int number_of_firings;
@@ -2669,15 +2746,13 @@ void ai_turret_execute_behavior(ship *shipp, ship_subsys *ss)
{
// starting animation checks
if (ss->turret_animation_position == MA_POS_NOT_SET) {
bool started = false;
//For legacy animations using subtype for turret number
started |= Ship_info[shipp->ship_info_index].animations.startAll(model_get_instance(shipp->model_instance_num), animation::ModelAnimationTriggerType::TurretFiring, animation::ModelAnimationDirection::FWD, false, false, false, ss->system_info->subobj_num, true);
auto animList = Ship_info[shipp->ship_info_index].animations.getAll(model_get_instance(shipp->model_instance_num), animation::ModelAnimationTriggerType::TurretFiring, ss->system_info->subobj_num, true);
//For modern animations using proper triggered-by-subsys name
started |= Ship_info[shipp->ship_info_index].animations.start(model_get_instance(shipp->model_instance_num), animation::ModelAnimationTriggerType::TurretFiring, animation::anim_name_from_subsys(ss->system_info), animation::ModelAnimationDirection::FWD);
if (started) {
int duration = Ship_info[shipp->ship_info_index].animations.getTimeAll(model_get_instance(shipp->model_instance_num), animation::ModelAnimationTriggerType::TurretFiring, ss->system_info->subobj_num, true);
int duration2 = Ship_info[shipp->ship_info_index].animations.getTime(model_get_instance(shipp->model_instance_num), animation::ModelAnimationTriggerType::TurretFiring, animation::anim_name_from_subsys(ss->system_info));
ss->turret_animation_done_time = timestamp(duration > duration2 ? duration : duration2);
animList += Ship_info[shipp->ship_info_index].animations.get(model_get_instance(shipp->model_instance_num), animation::ModelAnimationTriggerType::TurretFiring, animation::anim_name_from_subsys(ss->system_info));
if (animList.start(animation::ModelAnimationDirection::FWD)) {
ss->turret_animation_done_time = timestamp(animList.getTime());
ss->turret_animation_position = MA_POS_SET;
}
}
@@ -2814,7 +2889,7 @@ bool turret_adv_fov_test(ship_subsys *ss, vec3d *gvec, vec3d *v2e, float size_mo
bool turret_fov_test(ship_subsys *ss, vec3d *gvec, vec3d *v2e, float size_mod)
{
bool in_fov = false;
if (ss->system_info->flags[Model::Subsystem_Flags::Turret_restricted_fov])
if (ss->system_info->flags[Model::Subsystem_Flags::Turret_base_restricted_fov])
in_fov = turret_adv_fov_test(ss, gvec, v2e, size_mod);
else
in_fov = turret_std_fov_test(ss, gvec, v2e, size_mod);
+1 -1
View File
@@ -643,7 +643,7 @@ void anim_read_header(anim *ptr, CFILE *fp)
if (diff != 0) {
if (ptr->height > 16) {
mprintf(("ANI %s with size %dx%d (%.1f%% wasted)\n", ptr->name, ptr->width, ptr->height, waste));
nprintf(("ANI","ANI %s with size %dx%d (%.1f%% wasted)\n", ptr->name, ptr->width, ptr->height, waste));
}
}
#endif
+589 -220
View File
File diff suppressed because it is too large. Load diff
+31 -27
View File
@@ -14,34 +14,29 @@
#include "globalincs/globals.h" // for NAME_LENGTH
#include "globalincs/pstypes.h"
#include "io/timer.h"
class object;
class polymodel;
struct collision_info_struct;
class model_draw_list;
#define MAX_ASTEROIDS 512
#define MAX_ASTEROIDS 2000 //Increased from 512 to 2000 in 2022
#define NUM_DEBRIS_SIZES 3
#define NUM_DEBRIS_POFS 3 // Number of POFs per debris size
#define NUM_ASTEROID_SIZES 3
#define NUM_ASTEROID_POFS 3 // Number of POFs per debris size
#define ASTEROID_TYPE_DEBRIS -1
#define ASTEROID_TYPE_SMALL 0
#define ASTEROID_TYPE_MEDIUM 1
#define ASTEROID_TYPE_LARGE 2
// these should always be equal for the benefit of generic asteroids (c.f. asteroid_page_in)
#define MAX_ACTIVE_DEBRIS_TYPES NUM_DEBRIS_SIZES
#define MAX_ACTIVE_DEBRIS_TYPES NUM_ASTEROID_SIZES
// Goober5000 - currently same as MAX_SHIP_DETAIL_LEVELS (put here to avoid an #include)
#define MAX_ASTEROID_DETAIL_LEVELS 5
// whether to do retail behavior, just throw at the first big ship in the field
// must be explicitly opted out of by the mission
extern bool Default_asteroid_throwing_behavior;
extern SCP_vector<SCP_string> Asteroid_target_ships;
// Data structure to track the active asteroids
typedef struct asteroid_obj {
asteroid_obj *next, *prev;
@@ -53,16 +48,18 @@ extern asteroid_obj Asteroid_obj_list;
// Data structure for determining a type and amount of other asteroids an
// asteroid will split to when destroyed.
typedef struct asteroid_split_info {
int asteroid_type;
int min;
int max;
int asteroid_type; //index position
char name[NAME_LENGTH]; //asteroid name
int min; //minimum asteroids to spawn
int max; //maximum asteroids to spawn
} asteroid_split_info;
class asteroid_info
{
public:
char name[NAME_LENGTH]; // name for the asteroid
char pof_files[NUM_DEBRIS_POFS][MAX_FILENAME_LEN]; // POF files to load/associate with ship
int type; // type of asteroid, 0 = small, 1 = medium, 2 = large, -1 = debris
char pof_files[NUM_ASTEROID_POFS][MAX_FILENAME_LEN]; // POF files to load/associate with ship
int num_detail_levels; // number of detail levels for this ship
int detail_distance[MAX_ASTEROID_DETAIL_LEVELS]; // distance to change detail levels at
float max_speed; // cap on speed for asteroid
@@ -74,27 +71,29 @@ public:
float blast; // maximum blast impulse from area effect explosion
float initial_asteroid_strength; // starting strength of asteroid
SCP_vector< asteroid_split_info > split_info;
polymodel *modelp[NUM_DEBRIS_POFS];
int model_num[NUM_DEBRIS_POFS];
polymodel *modelp[NUM_ASTEROID_POFS];
int model_num[NUM_ASTEROID_POFS];
SCP_vector<int> explosion_bitmap_anims;
float fireball_radius_multiplier; // the model radius is multiplied by this to determine the fireball size
SCP_string display_name; // only used for hud targeting display and for 'ship' asteroids
float spawn_weight; // ship asteroids only, relative proportion to spawn compared to other types in its asteroid field
float gravity_const; // multiplier for mission gravity
asteroid_info( )
: num_detail_levels( 0 ), max_speed( 0 ), damage_type_idx( 0 ),
: type(ASTEROID_TYPE_DEBRIS), num_detail_levels(0), max_speed(0), damage_type_idx(0),
damage_type_idx_sav( -1 ), inner_rad( 0 ), outer_rad( 0 ),
damage( 0 ), blast( 0 ), initial_asteroid_strength( 0 ),
fireball_radius_multiplier( -1 )
fireball_radius_multiplier( -1 ), spawn_weight( 1 ), gravity_const( 0 )
{
name[ 0 ] = 0;
display_name = "";
memset( detail_distance, 0, sizeof( detail_distance ) );
for (int i = 0; i < NUM_DEBRIS_POFS; i++)
for (int i = 0; i < NUM_ASTEROID_POFS; i++)
{
modelp[i] = NULL;
model_num[i] = -1;
pof_files[i][0] = 0;
pof_files[i][0] = '\0';
}
}
};
@@ -108,9 +107,9 @@ typedef struct asteroid {
int model_instance_num;
int asteroid_type; // 0..MAX_DEBRIS_TYPES
int asteroid_subtype; // Index in asteroid_info for modelnum and modelp
int check_for_wrap; // timestamp to check for asteroid wrapping around field
int check_for_collide; // timestamp to check for asteroid colliding with escort ships
int final_death_time; // timestamp to swap in new models after explosion starts
TIMESTAMP check_for_wrap; // timestamp to check for asteroid wrapping around field
TIMESTAMP check_for_collide; // timestamp to check for asteroid colliding with escort ships
TIMESTAMP final_death_time; // timestamp to swap in new models after explosion starts
int collide_objnum; // set to objnum that asteroid will be impacting soon
int collide_objsig; // object signature corresponding to collide_objnum
vec3d death_hit_pos; // hit pos that caused death
@@ -121,7 +120,7 @@ typedef struct asteroid {
// TYPEDEF FOR DEBRIS TYPE
typedef enum {
DG_ASTEROID,
DG_SHIP
DG_DEBRIS
} debris_genre_t;
// TYPEDEF FOR FIELD TYPE
@@ -134,7 +133,7 @@ typedef struct asteroid_field {
vec3d min_bound; // Minimum range of field.
vec3d max_bound; // Maximum range of field.
float bound_rad;
int has_inner_bound;
bool has_inner_bound;
vec3d inner_min_bound;
vec3d inner_max_bound;
vec3d vel; // Average asteroid moves at this velocity.
@@ -144,6 +143,8 @@ typedef struct asteroid_field {
debris_genre_t debris_genre; // type of debris (ship or asteroid) [generic type]
int field_debris_type[MAX_ACTIVE_DEBRIS_TYPES]; // one of the debris type defines above
int num_used_field_debris_types; // how many of the above are used
SCP_vector<SCP_string> target_names; // default retail behavior is to just throw at the first big ship in the field
} asteroid_field;
extern SCP_vector< asteroid_info > Asteroid_info;
@@ -160,7 +161,9 @@ void asteroid_init();
void asteroid_level_init();
void asteroid_level_close();
void asteroid_create_all();
void asteroid_render(object * obj, model_draw_list *scene);
void asteroid_create_asteroid_field(int num_asteroids, int field_type, int asteroid_speed, bool brown, bool blue, bool orange, vec3d o_min, vec3d o_max, bool inner_box, vec3d i_min, vec3d i_max, SCP_vector<SCP_string> targets);
void asteroid_create_debris_field(int num_asteroids, int asteroid_speed, int debris1, int debris2, int debris3, vec3d o_min, vec3d o_max);
void asteroid_render(object* obj, model_draw_list* scene);
void asteroid_delete( object *asteroid_objp );
void asteroid_process_pre( object *asteroid_objp );
void asteroid_process_post( object *asteroid_objp);
@@ -172,6 +175,7 @@ float asteroid_time_to_impact(object *asteroid_objp);
void asteroid_show_brackets();
void asteroid_target_closest_danger();
void asteroid_add_target(object* objp);
int get_asteroid_position(const char* name);
// need to extern for multiplayer
void asteroid_sub_create(object *parent_objp, int asteroid_type, vec3d *relvec);
+18 -24
View File
@@ -47,10 +47,9 @@ NavMessage NavMsgs[NP_NUM_MESSAGES];
int audio_handle;
int NavLinkDistance;
// time offsets for autonav events
int LockAPConv;
int EndAPCinematic;
int MoveCamera;
int camMovingTime;
TIMESTAMP LockAPConv;
TIMESTAMP EndAPCinematic;
TIMESTAMP MoveCamera;
//float CameraSpeed;
bool CinematicStarted, CameraMoving;
vec3d cameraPos, cameraTarget;
@@ -151,6 +150,9 @@ bool CanAutopilot(const vec3d *targetPos, bool send_msg)
for (ship_obj *so = GET_FIRST(&Ship_obj_list); so != END_OF_LIST(&Ship_obj_list); so = GET_NEXT(so))
{
object *other_objp = &Objects[so->objnum];
if (other_objp->flags[Object::Object_Flags::Should_be_dead])
continue;
// attacks player?
if (iff_x_attacks_y(obj_team(other_objp), obj_team(Player_obj))
&& !(Ship_info[Ships[other_objp->instance].ship_info_index].flags[Ship::Info_Flags::Cargo])) // ignore cargo
@@ -206,8 +208,9 @@ bool StartAutopilot()
{
// Check for support ship and dismiss it if it is not doing anything.
// If the support ship is doing something then tell the user such.
for ( object *objp = GET_FIRST(&obj_used_list); objp !=END_OF_LIST(&obj_used_list); objp = GET_NEXT(objp) )
for (auto so: list_range(&Ship_obj_list))
{
auto objp = &Objects[so->objnum];
if ((objp->type == OBJ_SHIP) && !(objp->flags[Object::Object_Flags::Should_be_dead]))
{
Assertion((objp->instance >= 0) && (objp->instance < MAX_SHIPS),
@@ -262,9 +265,9 @@ bool StartAutopilot()
}
if (The_mission.flags[Mission::Mission_Flags::Use_ap_cinematics])
LockAPConv = timestamp(); // lock convergence instantly
LockAPConv = _timestamp(); // lock convergence instantly
else
LockAPConv = timestamp(3000); // 3 seconds before we lock convergence
LockAPConv = _timestamp(3 * MILLISECONDS_PER_SECOND); // 3 seconds before we lock convergence
Player_use_ai = 1;
set_time_compression(1);
lock_time_compression(true);
@@ -402,7 +405,7 @@ bool StartAutopilot()
&& Autopilot_flight_leader != &Objects[Ships[i].objnum]) //only if not flight leader's object
{
ai_info *aip = &Ai_info[Ships[i].ai_index];
int wingnum = aip->wing, wing_index = get_wing_index(&Objects[Ships[i].objnum], wingnum);
int wingnum = Ships[i].wingnum, wing_index = get_wing_index(&Objects[Ships[i].objnum], wingnum);
vec3d goal_point;
object *leader_objp = get_wing_leader(wingnum);
@@ -828,9 +831,8 @@ bool StartAutopilot()
//CameraMoving = false;
EndAPCinematic = timestamp((10000*tc_factor)+NPS_TICKRATE); // 10 objective seconds before end of cinematic
MoveCamera = timestamp((5500*tc_factor)+NPS_TICKRATE);
camMovingTime = int(4.5*float(tc_factor));
EndAPCinematic = _timestamp((10 * MILLISECONDS_PER_SECOND * tc_factor) + NPS_TICKRATE); // 10 objective seconds before end of cinematic
MoveCamera = _timestamp(fl2i(5.5 * MILLISECONDS_PER_SECOND * tc_factor) + NPS_TICKRATE);
set_time_compression((float)tc_factor);
}
@@ -923,10 +925,7 @@ void EndAutoPilot()
if ( ((aigp->target_name != NULL) && !stricmp(aigp->target_name, goal_name))
&& (aigp->ai_mode == goal) )
{
aigp->ai_mode = AI_GOAL_NONE;
aigp->signature = -1;
aigp->priority = -1;
aigp->flags.reset();
ai_goal_reset(aigp);
}
}
}
@@ -947,10 +946,7 @@ void EndAutoPilot()
if ( ((aigp->target_name != NULL) && !stricmp(aigp->target_name, goal_name))
&& (aigp->ai_mode == goal) )
{
aigp->ai_mode = AI_GOAL_NONE;
aigp->signature = -1;
aigp->priority = -1;
aigp->flags.reset();
ai_goal_reset(aigp);
}
}
}
@@ -1053,15 +1049,13 @@ void NavSystem_Do()
if(cam != NULL)
cam->set_rotation_facing(&Player_obj->pos);
if (timestamp() >= MoveCamera && !CameraMoving && vm_vec_mag(&cameraTarget) > 0.0f)
if (timestamp_elapsed(MoveCamera) && !CameraMoving && vm_vec_mag(&cameraTarget) > 0.0f)
{
//Free_camera->set_position(&cameraTarget, float(camMovingTime), float(camMovingTime)/2.0f);
//Free_camera->set_translation_velocity(&cameraTarget);
CameraMoving = true;
}
if (timestamp() >= EndAPCinematic || !CanAutopilot())
if (timestamp_elapsed(EndAPCinematic) || !CanAutopilot())
{
nav_warp();
EndAutoPilot();
@@ -1218,7 +1212,7 @@ void send_autopilot_msg(const char *msg, const char *snd)
}
if (msg[0] != '\0' && strcmp(msg, "none") != 0)
message_training_queue("autopilot builtin message", timestamp(0), 5); // display message for five seconds
message_training_queue("autopilot builtin message", TIMESTAMP::immediate(), 5); // display message for five seconds
}
// ********************************************************************************************
+8 -7
View File
@@ -29,16 +29,17 @@
class NavPoint
{
public:
char m_NavName[32];
int flags;
ubyte normal_color[3];
ubyte visited_color[3];
char m_NavName[32] = { 0 };
int flags = 0;
ubyte normal_color[3] = { 0x80, 0x80, 0xFF };
ubyte visited_color[3] = { 0xFF, 0xFF, 0x00 };
const void *target_obj;
int waypoint_num; //only used when flags & NP_WAYPOINT
const void *target_obj = nullptr;
int waypoint_num = -1; //only used when flags & NP_WAYPOINT
const vec3d *GetPosition();
// these assignments should match the initialization
void clear()
{
m_NavName[0] = 0;
@@ -78,7 +79,7 @@ extern bool AutoPilotEngaged;
extern int CurrentNav;
extern NavPoint Navs[MAX_NAVPOINTS];
extern NavMessage NavMsgs[NP_NUM_MESSAGES];
extern int LockAPConv;
extern TIMESTAMP LockAPConv;
extern SCP_map<int,int> autopilot_wings;
// Cycles through the NavPoint List
+5 -4
View File
@@ -53,6 +53,7 @@ MONITOR(SizeBitmapPage)
// --------------------------------------------------------------------------------------------------------------------
// Definition of public variables (declared as extern in bmpman.h).
int ENVMAP = -1;
int IRRMAP = -1;
size_t bm_texture_ram = 0;
int Bm_paging = 0;
@@ -1530,7 +1531,7 @@ int bm_load_animation(const char *real_filename, int *nframes, int *fps, int *ke
cfclose(img_cfp);
return -1;
} else {
mprintf(("BMPMAN: Found EFF (%s) with %d frames at %d fps.\n", filename, anim_frames, anim_fps));
nprintf(("BmpMan","BMPMAN: Found EFF (%s) with %d frames at %d fps.\n", filename, anim_frames, anim_fps));
}
if (anim_fps == 0) {
Error(LOCATION, "animation (%s) has invalid fps of 0, fix this!", filename);
@@ -1599,7 +1600,7 @@ int bm_load_animation(const char *real_filename, int *nframes, int *fps, int *ke
throw e;
}
else {
mprintf(("Failed to load apng: %s\n", e.what()));
nprintf(("apng","Failed to load apng: %s\n", e.what()));
return -1;
}
}
@@ -1834,7 +1835,7 @@ int bm_load_sub_fast(const char *real_filename, int *handle, int dir_type, bool
}
int bm_load_sub_slow(const char *real_filename, const int num_ext, const char **ext_list, CFILE **img_cfp, int dir_type) {
auto res = cf_find_file_location_ext(real_filename, num_ext, ext_list, dir_type, false);
auto res = cf_find_file_location_ext(real_filename, num_ext, ext_list, dir_type);
// could not be found, or is invalid for some reason
if (!res.found)
@@ -2622,7 +2623,7 @@ void bm_page_in_stop() {
}
}
mprintf(("Bmpman: %d/%d bitmap slots in use.\n", total_bitmaps, total_slots));
nprintf(("BmpMan","BMPMAN: %d/%d bitmap slots in use.\n", total_bitmaps, total_slots));
#endif
Bm_paging = 0;
+1 -1
View File
@@ -116,6 +116,7 @@ extern const char *bm_ani_ext_list[]; //!< List of extensions for those types
extern const int BM_ANI_NUM_TYPES; //!< Calculated number of bitmap animation types
extern int ENVMAP; //!< References a map that is for environment mapping -Bobboau
extern int IRRMAP; //!< References a filtered envmap for diffuse environment lighting - qazwsxal
/**
* @brief Initilizes the bitmap manager
@@ -546,7 +547,6 @@ void bm_set_components_argb_32_tex(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, u
*/
void bm_get_components(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a);
extern int ENVMAP; //this holds a reference to a map that is for environment mapping -Bobboau
/**
* @brief Returns the compression type of the bitmap indexed by handle
+6
View File
@@ -831,7 +831,10 @@ void subtitle::do_frame(float frametime)
auto sizing_mode = do_screen_scaling ? GR_RESIZE_FULL : GR_RESIZE_NONE;
if (do_screen_scaling)
{
gr_set_screen_scale(Show_subtitle_screen_adjusted_res[0], Show_subtitle_screen_adjusted_res[1]);
gr_set_clip(0, 0, Show_subtitle_screen_adjusted_res[0], Show_subtitle_screen_adjusted_res[1]);
}
// do the actual drawing ---------------------
@@ -879,7 +882,10 @@ void subtitle::do_frame(float frametime)
// finished the actual drawing ---------------
if (do_screen_scaling)
{
gr_reset_screen_scale();
gr_reset_clip();
}
// restore old font
if (old_fontnum >= 0)
+78 -57
View File
@@ -59,8 +59,6 @@ cf_pathtype Pathtypes[CF_MAX_PATH_TYPES] = {
{ CF_TYPE_MODELS, "data" DIR_SEPARATOR_STR "models", ".pof", CF_TYPE_DATA },
{ CF_TYPE_TABLES, "data" DIR_SEPARATOR_STR "tables", ".tbl .tbm .lua", CF_TYPE_DATA },
{ CF_TYPE_SOUNDS, "data" DIR_SEPARATOR_STR "sounds", ".wav .ogg", CF_TYPE_DATA },
{ CF_TYPE_SOUNDS_8B22K, "data" DIR_SEPARATOR_STR "sounds" DIR_SEPARATOR_STR "8b22k", ".wav .ogg", CF_TYPE_SOUNDS },
{ CF_TYPE_SOUNDS_16B11K, "data" DIR_SEPARATOR_STR "sounds" DIR_SEPARATOR_STR "16b11k", ".wav .ogg", CF_TYPE_SOUNDS },
{ CF_TYPE_VOICE, "data" DIR_SEPARATOR_STR "voice", "", CF_TYPE_DATA },
{ CF_TYPE_VOICE_BRIEFINGS, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "briefing", ".wav .ogg", CF_TYPE_VOICE },
{ CF_TYPE_VOICE_CMD_BRIEF, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "command_briefings", ".wav .ogg", CF_TYPE_VOICE },
@@ -70,7 +68,7 @@ cf_pathtype Pathtypes[CF_MAX_PATH_TYPES] = {
{ CF_TYPE_VOICE_TRAINING, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "training", ".wav .ogg", CF_TYPE_VOICE },
{ CF_TYPE_MUSIC, "data" DIR_SEPARATOR_STR "music", ".wav .ogg", CF_TYPE_DATA },
{ CF_TYPE_MOVIES, "data" DIR_SEPARATOR_STR "movies", ".mve .msb .ogg .mp4 .srt .webm .png",CF_TYPE_DATA },
{ CF_TYPE_INTERFACE, "data" DIR_SEPARATOR_STR "interface", ".pcx .ani .dds .tga .eff .png .jpg", CF_TYPE_DATA },
{ CF_TYPE_INTERFACE, "data" DIR_SEPARATOR_STR "interface", ".pcx .ani .dds .tga .eff .png .jpg .rml .rcss", CF_TYPE_DATA },
{ CF_TYPE_FONT, "data" DIR_SEPARATOR_STR "fonts", ".vf .ttf .otf", CF_TYPE_DATA },
{ CF_TYPE_EFFECTS, "data" DIR_SEPARATOR_STR "effects", ".ani .eff .pcx .neb .tga .jpg .png .dds .sdr", CF_TYPE_DATA },
{ CF_TYPE_HUD, "data" DIR_SEPARATOR_STR "hud", ".pcx .ani .eff .tga .jpg .png .dds", CF_TYPE_DATA },
@@ -79,6 +77,7 @@ cf_pathtype Pathtypes[CF_MAX_PATH_TYPES] = {
{ CF_TYPE_SQUAD_IMAGES, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "squads", ".pcx .png .dds", CF_TYPE_PLAYERS },
{ CF_TYPE_SINGLE_PLAYERS, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "single", ".pl2 .cs2 .plr .csg .css .json", CF_TYPE_PLAYERS },
{ CF_TYPE_MULTI_PLAYERS, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "multi", ".plr .json", CF_TYPE_PLAYERS },
{ CF_TYPE_PLAYER_BINDS, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "presets", ".json", CF_TYPE_PLAYERS },
{ CF_TYPE_CACHE, "data" DIR_SEPARATOR_STR "cache", ".clr .tmp .bx", CF_TYPE_DATA }, //clr=cached color
{ CF_TYPE_MULTI_CACHE, "data" DIR_SEPARATOR_STR "multidata", ".pcx .png .jpg .dds .fs2 .txt", CF_TYPE_DATA },
{ CF_TYPE_MISSIONS, "data" DIR_SEPARATOR_STR "missions", ".fs2 .fc2 .ntl .ssv", CF_TYPE_DATA },
@@ -88,10 +87,7 @@ cf_pathtype Pathtypes[CF_MAX_PATH_TYPES] = {
{ CF_TYPE_INTEL_ANIMS, "data" DIR_SEPARATOR_STR "intelanims", ".pcx .ani .eff .tga .jpg .png .dds", CF_TYPE_DATA },
{ CF_TYPE_SCRIPTS, "data" DIR_SEPARATOR_STR "scripts", ".lua .lc .fnl", CF_TYPE_DATA },
{ CF_TYPE_FICTION, "data" DIR_SEPARATOR_STR "fiction", ".txt", CF_TYPE_DATA },
{ CF_TYPE_FREDDOCS, "data" DIR_SEPARATOR_STR "freddocs", ".html", CF_TYPE_DATA },
{ CF_TYPE_INTERFACE_MARKUP, "data" DIR_SEPARATOR_STR "interface" DIR_SEPARATOR_STR "markup", ".rml", CF_TYPE_INTERFACE },
{ CF_TYPE_INTERFACE_CSS, "data" DIR_SEPARATOR_STR "interface" DIR_SEPARATOR_STR "css", ".rcss", CF_TYPE_INTERFACE },
{ CF_TYPE_PLAYER_BINDS, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "presets", ".json", CF_TYPE_PLAYERS },
{ CF_TYPE_FREDDOCS, "data" DIR_SEPARATOR_STR "freddocs", ".html", CF_TYPE_DATA }
};
// clang-format on
@@ -329,7 +325,7 @@ static int _cfile_chdir(const char *new_dir, const char *cur_dir __UNUSED)
*/
int cfile_push_chdir(int type)
{
char dir[CFILE_ROOT_DIRECTORY_LEN];
SCP_string dir;
char OriginalDirectory[CFILE_ROOT_DIRECTORY_LEN];
_getcwd(OriginalDirectory, CFILE_ROOT_DIRECTORY_LEN - 1);
@@ -342,9 +338,9 @@ int cfile_push_chdir(int type)
strcpy_s(Cfile_stack[Cfile_stack_pos++], OriginalDirectory);
cf_create_default_path_string(dir, sizeof(dir) - 1, type, NULL);
cf_create_default_path_string(dir, type, NULL);
return _cfile_chdir(dir, OriginalDirectory);
return _cfile_chdir(dir.c_str(), OriginalDirectory);
}
/**
@@ -469,26 +465,26 @@ char *cf_add_ext(const char *filename, const char *ext)
*/
int cf_delete(const char *filename, int path_type, uint32_t location_flags)
{
char longname[MAX_PATH_LEN];
SCP_string longname;
Assert(CF_TYPE_SPECIFIED(path_type));
cf_create_default_path_string(longname, sizeof(longname) - 1, path_type, filename, false, location_flags);
cf_create_default_path_string(longname, path_type, filename, location_flags);
return (_unlink(longname) != -1);
return (_unlink(longname.c_str()) != -1);
}
// Same as _access function to read a file's access bits
int cf_access(const char *filename, int dir_type, int mode)
{
char longname[MAX_PATH_LEN];
SCP_string longname;
Assert( CF_TYPE_SPECIFIED(dir_type) );
cf_create_default_path_string( longname, sizeof(longname)-1, dir_type, filename );
cf_create_default_path_string(longname, dir_type, filename);
return access(longname,mode);
return access(longname.c_str(), mode);
}
@@ -533,18 +529,18 @@ int cf_exists_full_ext(const char *filename, int dir_type, const int num_ext, co
#ifdef _WIN32
void cf_attrib(const char *filename, int set, int clear, int dir_type)
{
char longname[MAX_PATH_LEN];
SCP_string longname;
Assert( CF_TYPE_SPECIFIED(dir_type) );
cf_create_default_path_string( longname, sizeof(longname)-1, dir_type, filename );
cf_create_default_path_string(longname, dir_type, filename);
FILE *fp = fopen(longname, "rb");
FILE *fp = fopen(longname.c_str(), "rb");
if (fp) {
fclose(fp);
DWORD z = GetFileAttributes(longname);
SetFileAttributes(longname, z | (set & ~clear));
DWORD z = GetFileAttributes(longname.c_str());
SetFileAttributes(longname.c_str(), z | (set & ~clear));
}
}
@@ -555,13 +551,13 @@ int cf_rename(const char *old_name, const char *name, int dir_type)
Assert( CF_TYPE_SPECIFIED(dir_type) );
int ret_code;
char old_longname[_MAX_PATH];
char new_longname[_MAX_PATH];
SCP_string old_longname;
SCP_string new_longname;
cf_create_default_path_string( old_longname, sizeof(old_longname)-1, dir_type, old_name );
cf_create_default_path_string( new_longname, sizeof(old_longname)-1, dir_type, name );
cf_create_default_path_string(old_longname, dir_type, old_name);
cf_create_default_path_string(new_longname, dir_type, name);
ret_code = rename(old_longname, new_longname );
ret_code = rename(old_longname.c_str(), new_longname.c_str());
if(ret_code != 0){
switch(errno){
case EACCES :
@@ -605,7 +601,7 @@ void cf_create_directory(int dir_type, uint32_t location_flags)
{
int num_dirs = 0;
int dir_tree[CF_MAX_PATH_TYPES];
char longname[MAX_PATH_LEN];
SCP_string longname;
struct stat statbuf;
Assertion( CF_TYPE_SPECIFIED(dir_type), "Invalid dir_type passed to cf_create_directory." );
@@ -623,10 +619,10 @@ void cf_create_directory(int dir_type, uint32_t location_flags)
int i;
for (i=num_dirs-1; i>=0; i-- ) {
cf_create_default_path_string(longname, sizeof(longname) - 1, dir_tree[i], nullptr, false, location_flags);
if (stat(longname, &statbuf) != 0) {
mprintf(( "CFILE: Creating new directory '%s'\n", longname ));
mkdir_recursive(longname);
cf_create_default_path_string(longname, dir_tree[i], nullptr, location_flags);
if (stat(longname.c_str(), &statbuf) != 0) {
mprintf(( "CFILE: Creating new directory '%s'\n", longname.c_str() ));
mkdir_recursive(longname.c_str());
}
}
}
@@ -648,7 +644,7 @@ void cf_create_directory(int dir_type, uint32_t location_flags)
//
CFILE* _cfopen(const char* source, int line, const char* file_path, const char* mode, int type, int dir_type,
bool localize, uint32_t location_flags)
bool /* localize */, uint32_t location_flags)
{
/* Bobboau, what is this doing here? 31 is way too short... - Goober5000
if( strlen(file_path) > 31 )
@@ -675,13 +671,13 @@ CFILE* _cfopen(const char* source, int line, const char* file_path, const char*
// the harddisk. No fancy packfile stuff here!
if ( strchr(mode,'w') || strchr(mode,'+') || strchr(mode,'a') ) {
char longname[_MAX_PATH];
SCP_string longname;
auto last_separator = strrchr(file_path, DIR_SEPARATOR_CHAR);
// For write-only files, require a full path or a path type
if ( last_separator ) {
// Full path given?
strcpy_s(longname, file_path );
longname = file_path;
} else {
// Path type given?
Assert( dir_type != CF_TYPE_ANY );
@@ -689,7 +685,7 @@ CFILE* _cfopen(const char* source, int line, const char* file_path, const char*
// Create the directory if necessary
cf_create_directory(dir_type, location_flags);
cf_create_default_path_string(longname, sizeof(longname) - 1, dir_type, file_path, false, location_flags);
cf_create_default_path_string(longname, dir_type, file_path, location_flags);
}
Assert( !(type & CFILE_MEMORY_MAPPED) );
@@ -728,7 +724,7 @@ CFILE* _cfopen(const char* source, int line, const char* file_path, const char*
strcpy_s(happy_mode, mode);
}
FILE *fp = fopen(longname, happy_mode);
FILE *fp = fopen(longname.c_str(), happy_mode);
if (fp) {
return cf_open_fill_cfblock(source, line, last_separator ? (last_separator + 1) : file_path, fp, dir_type);
}
@@ -739,10 +735,8 @@ CFILE* _cfopen(const char* source, int line, const char* file_path, const char*
//================================================
// Search for file on disk, on cdrom, or in a packfile
char copy_file_path[MAX_PATH_LEN]; // FIX change in memory from cf_find_file_location
strcpy_s(copy_file_path, file_path);
auto find_res = cf_find_file_location(file_path, dir_type, location_flags);
auto find_res = cf_find_file_location( copy_file_path, dir_type, localize, location_flags );
if ( find_res.found ) {
// Fount it, now create a cfile out of it
@@ -1239,15 +1233,17 @@ void cfread_string(char *buf, int n, CFILE *file)
} while (c != 0 );
}
void cfread_string_len(char *buf,int n, CFILE *file)
void cfread_string_len(char *buf, int buffer_size, CFILE *file)
{
int len;
len = cfread_int(file);
Assertion( (len < n), "len: %i, n: %i", len, n );
if (len)
Assertion( (len <= buffer_size), "String cannot fit in buffer, len: %i, buffer: %i", len, buffer_size);
if (len) {
cfread(buf, len, 1, file);
Assertion(len != buffer_size || buf[len - 1] == 0, "Unterminated string does not fit in buffer");
}
buf[len] = 0;
buf[MIN(len, buffer_size - 1)] = 0;
}
SCP_string cfread_string_len(CFILE *file)
@@ -1846,28 +1842,53 @@ int cfile_get_path_type(const SCP_string& dir)
{
SCP_string buf = dir;
// Remove trailing slashes; avoid buffer overflow on 1-char strings
while (buf.size() > 0 && (buf[buf.size() - 1] == '\\' || buf[buf.size() - 1] == '/')) {
buf.resize(buf.size() - 1);
// remove leading and trailing slashes
if ( !buf.empty() ) {
auto start = buf.find_first_not_of("\\/");
auto end = buf.find_last_not_of("\\/");
if (start == SCP_string::npos) {
buf = "";
} else if ( (start > 0) || (end < buf.length()-1) ) {
buf = buf.substr(start, end-start+1);
}
}
// Remove leading slashes
while (buf.size() > 0 && (buf[0] == '\\' || buf[0] == '/')) {
buf = buf.substr(1);
if (buf.empty()) {
return CF_TYPE_ROOT;
}
// Use official DIR_SEPARATOR_CHAR
for (char& c : buf) {
if (c == '\\' || c == '/') {
c = DIR_SEPARATOR_CHAR;
}
}
extern void normalize_directory_separators(SCP_string &str);
normalize_directory_separators(buf);
// identify path type
auto best_match = CF_TYPE_INVALID;
for (auto& Pathtype : Pathtypes) {
if (Pathtype.path != nullptr && buf == Pathtype.path) {
return Pathtype.index;
if ( !Pathtype.path ) {
continue;
}
// skip root, it should have been detected before getting here
if (Pathtype.index == CF_TYPE_ROOT) {
continue;
}
// don't allow unknown subdirs directly under data
if (Pathtype.index == CF_TYPE_DATA) {
if (buf == Pathtype.path) {
best_match = CF_TYPE_DATA;
}
continue;
}
// for everything else just find closest match, allowing for unknown subdirectories
if ( !strnicmp(buf.c_str(), Pathtype.path, strlen(Pathtype.path)) ) {
best_match = Pathtype.index;
}
}
return CF_TYPE_INVALID;
return best_match;
}
+37 -40
View File
@@ -49,42 +49,38 @@ typedef struct {
#define CF_TYPE_MODELS 5
#define CF_TYPE_TABLES 6
#define CF_TYPE_SOUNDS 7
#define CF_TYPE_SOUNDS_8B22K 8
#define CF_TYPE_SOUNDS_16B11K 9
#define CF_TYPE_VOICE 10
#define CF_TYPE_VOICE_BRIEFINGS 11
#define CF_TYPE_VOICE_CMD_BRIEF 12
#define CF_TYPE_VOICE_DEBRIEFINGS 13
#define CF_TYPE_VOICE_PERSONAS 14
#define CF_TYPE_VOICE_SPECIAL 15
#define CF_TYPE_VOICE_TRAINING 16
#define CF_TYPE_MUSIC 17
#define CF_TYPE_MOVIES 18
#define CF_TYPE_INTERFACE 19
#define CF_TYPE_FONT 20
#define CF_TYPE_EFFECTS 21
#define CF_TYPE_HUD 22
#define CF_TYPE_PLAYERS 23
#define CF_TYPE_PLAYER_IMAGES 24
#define CF_TYPE_SQUAD_IMAGES 25
#define CF_TYPE_SINGLE_PLAYERS 26
#define CF_TYPE_MULTI_PLAYERS 27
#define CF_TYPE_CACHE 28
#define CF_TYPE_MULTI_CACHE 29
#define CF_TYPE_MISSIONS 30
#define CF_TYPE_CONFIG 31
#define CF_TYPE_DEMOS 32
#define CF_TYPE_CBANIMS 33
#define CF_TYPE_INTEL_ANIMS 34
#define CF_TYPE_SCRIPTS 35
#define CF_TYPE_FICTION 36
#define CF_TYPE_FREDDOCS 37
#define CF_TYPE_INTERFACE_MARKUP 38
#define CF_TYPE_INTERFACE_CSS 39
#define CF_TYPE_PLAYER_BINDS 40
#define CF_TYPE_VOICE 8
#define CF_TYPE_VOICE_BRIEFINGS 9
#define CF_TYPE_VOICE_CMD_BRIEF 10
#define CF_TYPE_VOICE_DEBRIEFINGS 11
#define CF_TYPE_VOICE_PERSONAS 12
#define CF_TYPE_VOICE_SPECIAL 13
#define CF_TYPE_VOICE_TRAINING 14
#define CF_TYPE_MUSIC 15
#define CF_TYPE_MOVIES 16
#define CF_TYPE_INTERFACE 17
#define CF_TYPE_FONT 18
#define CF_TYPE_EFFECTS 19
#define CF_TYPE_HUD 20
#define CF_TYPE_PLAYERS 21
#define CF_TYPE_PLAYER_IMAGES 22
#define CF_TYPE_SQUAD_IMAGES 23
#define CF_TYPE_SINGLE_PLAYERS 24
#define CF_TYPE_MULTI_PLAYERS 25
#define CF_TYPE_PLAYER_BINDS 26
#define CF_TYPE_CACHE 27
#define CF_TYPE_MULTI_CACHE 28
#define CF_TYPE_MISSIONS 29
#define CF_TYPE_CONFIG 30
#define CF_TYPE_DEMOS 31
#define CF_TYPE_CBANIMS 32
#define CF_TYPE_INTEL_ANIMS 33
#define CF_TYPE_SCRIPTS 34
#define CF_TYPE_FICTION 35
#define CF_TYPE_FREDDOCS 36
#define CF_MAX_PATH_TYPES \
41 // Can be as high as you'd like //DTP; yeah but beware alot of things uses CF_MAX_PATH_TYPES
37 // Can be as high as you'd like //DTP; yeah but beware alot of things uses CF_MAX_PATH_TYPES
// TRUE if type is specified and valid
#define CF_TYPE_SPECIFIED(path_type) (((path_type)>CF_TYPE_INVALID) && ((path_type)<CF_MAX_PATH_TYPES))
@@ -326,15 +322,17 @@ void cfread_vector(vec3d* vec, CFILE* file, vec3d* deflt = nullptr);
// to n characters.
void cfread_string(char *buf,int n, CFILE *file);
/**
* @brief Read a fixed length string that is not null-terminated, with the length stored in file
* @brief Read a fixed length string that is not null-terminated, with the length stored in file.
*
* If it is not null-terminated, the length of the string *must* be less than the size of the buffer (to make room for one)
*
* @param buf Pre-allocated array to store string
* @param n Size of pre-allocated array
* @param buffer_size Size of pre-allocated array
* @param file File to read from
*
* @note Appends NULL character to string (buf)
*/
void cfread_string_len(char *buf,int n, CFILE *file);
void cfread_string_len(char *buf,int buffer_size, CFILE *file);
/**
* @brief Read a string from the file where the length is stored in the file
@@ -393,7 +391,7 @@ struct CFileLocation {
// size - File size
// offset - Offset into pack file. 0 if not a packfile.
// Returns: If not found returns 0.
CFileLocation cf_find_file_location(const char* filespec, int pathtype, bool localize = false,
CFileLocation cf_find_file_location(const char* filespec, int pathtype,
uint32_t location_flags = CF_LOCATION_ALL);
struct CFileLocationExt : public CFileLocation {
@@ -417,8 +415,7 @@ struct CFileLocationExt : public CFileLocation {
// offset - Offset into pack file. 0 if not a packfile.
// Returns: If not found returns -1, else returns offset into ext_list.
// (NOTE: This function is exponentially slow, so don't use it unless truely needed!!)
CFileLocationExt cf_find_file_location_ext(const char* filename, const int ext_num, const char** ext_list, int pathtype,
bool localize = false);
CFileLocationExt cf_find_file_location_ext(const char* filename, const int ext_num, const char** ext_list, int pathtype);
// Functions to change directories
int cfile_chdir(const char *dir);
+618 -338
View File
File diff suppressed because it is too large. Load diff
+2 -2
View File
@@ -42,8 +42,8 @@ bool cf_check_location_flags(uint32_t check_flags, uint32_t desired_flags);
// Output: path - Fully qualified pathname.
//Returns 0 if result would be too long (invalid result)
int cf_create_default_path_string(char* path, uint path_max, int pathtype, const char* filename = nullptr,
bool localize = false, uint32_t location_flags = CF_LOCATION_ALL);
int cf_create_default_path_string(SCP_string& path, int pathtype, const char* filename = nullptr, bool localize = false,
uint32_t location_flags = CF_LOCATION_ALL);
int cf_create_default_path_string(SCP_string& path, int pathtype, const char* filename = nullptr,
uint32_t location_flags = CF_LOCATION_ALL);
#endif //_CFILESYSTEM_H
+181
View File
@@ -0,0 +1,181 @@
#include "cheats_table.h"
#include "parse/parselo.h"
void cheat_table_init() {
customCheats.clear();
if (cf_exists_full("cheats.tbl", CF_TYPE_TABLES)) {
parse_cheat_table("cheats.tbl");
}
parse_modular_table("*-cht.tbm", parse_cheat_table);
}
bool CustomCheat::canUseCheat() {
return !requireCheatsEnabled || Cheats_enabled;
}
void CustomCheat::runCheat() {
if (!canUseCheat()) return;
HUD_printf("%s", cheatMsg.c_str());
scripting::hooks::OnCheat->run(scripting::hook_param_list(scripting::hook_param("Cheat", 's', cheatCode)));
CheatUsed = cheatCode;
}
void SpawnShipCheat::runCheat() {
CustomCheat::runCheat();
if (canUseCheat() && (Game_mode & GM_IN_MISSION) && Player_obj != nullptr) {
extern void prevent_spawning_collision(object *new_obj);
ship_subsys *ptr;
char name[NAME_LENGTH];
int ship_idx, ship_class;
// if not found, then don't create it :(
ship_class = ship_info_lookup(shipClassName.c_str());
if (ship_class < 0)
return;
vec3d pos = Player_obj->pos;
matrix orient = Player_obj->orient;
pos.xyz.x += frand_range(-700.0f, 700.0f);
pos.xyz.y += frand_range(-700.0f, 700.0f);
pos.xyz.z += frand_range(-700.0f, 700.0f);
int objnum = ship_create(&orient, &pos, ship_class);
if (objnum < 0)
return;
ship *shipp = &Ships[Objects[objnum].instance];
shipp->ship_name[0] = '\0';
shipp->display_name.clear();
for (size_t j = 0; j < Player_orders.size(); j++)
shipp->orders_accepted.insert(j);
// Goober5000 - stolen from support ship creation
// create a name for the ship with a number. look for collisions until one isn't found anymore
ship_idx = 1;
do {
sprintf(name, "%s %d", shipName.c_str(), ship_idx);
if ( (ship_name_lookup(name) == -1) && (ship_find_exited_ship_by_name(name) == -1) )
{
strcpy_s(shipp->ship_name, name);
break;
}
ship_idx++;
} while(1);
shipp->flags.set(Ship::Ship_Flags::Escort);
shipp->escort_priority = 1000 - ship_idx;
// now make sure we're not colliding with anyone
prevent_spawning_collision(&Objects[objnum]);
// Goober5000 - beam free
for (ptr = GET_FIRST(&shipp->subsys_list); ptr != END_OF_LIST(&shipp->subsys_list); ptr = GET_NEXT(ptr))
{
// mark all turrets as beam free
if (ptr->system_info->type == SUBSYSTEM_TURRET)
{
ptr->weapons.flags.set(Ship::Weapon_Flags::Beam_Free);
ptr->turret_next_fire_stamp = timestamp((int)frand_range(50.0f, 4000.0f));
}
}
// Cyborg17 to prevent a nullptr...
ship_set_warp_effects(&Objects[objnum]);
// warpin
shipfx_warpin_start(&Objects[objnum]);
}
}
void parse_cheat_table(const char* filename) {
try {
read_file_text(filename, CF_TYPE_TABLES);
reset_parse();
optional_string("#CUSTOM CHEATS");
while (optional_string("$Cheat:")) {
SCP_string code, msg, shipClass, shipName;
bool requireCheats = false;
bool shipSpawn = false;
required_string("+Code:");
stuff_string(code, F_RAW);
//We are limited to the buffer size used for the traditional cheats. We can still use short cheats, though.
if (code.length() > CHEAT_BUFFER_LEN) {
Warning(LOCATION, "Cheat code %s is too long. It will be cut off to maximum length (%i characters).", code.c_str(), CHEAT_BUFFER_LEN);
code = code.substr(0, CHEAT_BUFFER_LEN);
}
required_string("+Message:");
stuff_string(msg, F_MESSAGE);
if (optional_string("+RequireCheats:")) {
stuff_boolean(&requireCheats);
}
if (optional_string("+SpawnShip:")) {
shipSpawn = true;
required_string("+Name:");
stuff_string(shipName, F_NAME);
required_string("+Class:");
stuff_string(shipClass, F_NAME);
int shipClassInfo = ship_info_lookup(shipClass.c_str());
if (shipClassInfo < 0) {
shipSpawn = false;
Warning(LOCATION, "There is no ship class named '%s'. The '%s' cheat won't summon a ship.", shipClass.c_str(), code.c_str());
}
}
if (shipSpawn) {
std::unique_ptr<CustomCheat> shipCheat(new SpawnShipCheat(code, msg, requireCheats, shipClass, shipName));
if(customCheats.count(code) == 1) {
Warning(LOCATION, "A cheat for code '%s' already exists. It will be replaced.", code.c_str());
customCheats[code] = std::move(shipCheat);
} else {
customCheats.emplace(code, std::move(shipCheat));
}
} else {
std::unique_ptr<CustomCheat> cheat(new CustomCheat(code, msg, requireCheats));
if(customCheats.count(code) == 1) {
Warning(LOCATION, "A cheat for code '%s' already exists. It will be replaced.", code.c_str());
customCheats[code] = std::move(cheat);
} else {
customCheats.emplace(code, std::move(cheat));
}
}
}
required_string("#END");
}
catch (const parse::ParseException& e) {
mprintf(("TABLES: Unable to parse '%s'! Error message = %s.\n", filename, e.what()));
return;
}
}
bool checkForCustomCheats(const char* buffer, int buffer_length) {
const char* check_buffer = buffer;
for (int i = 0; i < buffer_length; i++) {
if (*check_buffer == '\0') {
check_buffer++;
}
else {
break;
}
}
// Loop through our map of custom cheats and check if the code is within the buffer.
// We don't just check for equality, as the player may have typed other characters before the cheat.
for (auto &ccheat : customCheats) {
auto found = std::strstr(check_buffer, ccheat.first.c_str());
if (found != nullptr) {
ccheat.second->runCheat();
return true;
}
}
return false;
}
+49
View File
@@ -0,0 +1,49 @@
#include "globalincs/globals.h"
#include "globalincs/pstypes.h"
#include "globalincs/systemvars.h"
#include "io/key.h"
#include "hud/hudmessage.h"
#include "hud/hudsquadmsg.h"
#include "scripting/global_hooks.h"
#include "scripting/hook_api.h"
#include "ship/ship.h"
#include "ship/shipfx.h"
#define CHEAT_BUFFER_LEN 17
class CustomCheat {
public:
SCP_string cheatCode;
SCP_string cheatMsg;
bool requireCheatsEnabled;
CustomCheat(SCP_string cheat_code, SCP_string cheat_msg, bool require_cheats_enabled) :
cheatCode(std::move(cheat_code)),
cheatMsg(std::move(cheat_msg)),
requireCheatsEnabled(require_cheats_enabled) { }
virtual ~CustomCheat() = default;
virtual void runCheat();
bool canUseCheat();
};
class SpawnShipCheat : public CustomCheat {
protected:
SCP_string shipClassName;
SCP_string shipName;
public:
SpawnShipCheat(SCP_string cheat_code, SCP_string cheat_msg, bool require_cheats_enabled, SCP_string class_name, SCP_string ship_name) : CustomCheat(cheat_code, cheat_msg, require_cheats_enabled),
shipClassName(std::move(class_name)),
shipName(std::move(ship_name)) { }
void runCheat() override;
};
static SCP_map<SCP_string, std::unique_ptr<CustomCheat>> customCheats;
void cheat_table_init();
void parse_cheat_table(const char* filename);
bool checkForCustomCheats(const char* converted_buffer, int buffer_length);
+79 -47
View File
@@ -22,6 +22,7 @@
#include "network/multi_log.h"
#include "options/OptionsManager.h"
#include "osapi/osapi.h"
#include "osapi/dialogs.h"
#include "parse/sexp.h"
#include "scripting/scripting.h"
#include "sound/openal.h"
@@ -170,6 +171,7 @@ Flag exe_params[] =
{ "-fb_thrusters", "Enable Framebuffer Thrusters", true, EASY_ALL_ON, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-fb_thrusters", },
{ "-no_deferred", "Disable Deferred Lighting", true, EASY_DEFAULT | EASY_HI_MEM_OFF, EASY_ALL_ON | EASY_HI_MEM_ON, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_deferred"},
{ "-enable_shadows", "Enable Shadows", true, EASY_ALL_ON | EASY_HI_MEM_ON, EASY_DEFAULT | EASY_HI_MEM_OFF, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-enable_shadows"},
{ "-deferred_cockpit", "Enable Deferred Lighting for Cockpits", true, EASY_ALL_ON | EASY_HI_MEM_ON, EASY_DEFAULT | EASY_HI_MEM_OFF, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-deferred_cockpit"},
{ "-no_vsync", "Disable vertical sync", true, 0, EASY_DEFAULT, "Game Speed", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_vsync", },
@@ -185,8 +187,6 @@ Flag exe_params[] =
{ "-stretch_menu", "Stretch interface to fill screen", true, 0, EASY_DEFAULT, "Gameplay", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-stretch_menu", },
{ "-noscalevid", "Disable scale-to-window for movies", true, 0, EASY_DEFAULT, "Gameplay", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-noscalevid", },
{ "-nomotiondebris", "Disable motion debris", true, 0, EASY_DEFAULT, "Gameplay", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-nomotiondebris",},
{ "-ship_choice_3d", "Use 3D models for ship selection", true, 0, EASY_DEFAULT, "Gameplay", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-ship_choice_3d", },
{ "-weapon_choice_3d", "Use 3D models for weapon selection", true, 0, EASY_DEFAULT, "Gameplay", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-weapon_choice_3d", },
{ "-3dwarp", "Enable 3D warp", true, 0, EASY_DEFAULT, "Gameplay", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-3dwarp", },
{ "-warp_flash", "Enable flash upon warp", true, 0, EASY_DEFAULT, "Gameplay", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-warp_flash", },
{ "-no_ap_interrupt", "Disable interrupting autopilot", true, 0, EASY_DEFAULT, "Gameplay", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_ap_interrupt", },
@@ -207,6 +207,7 @@ Flag exe_params[] =
{ "-clientdamage", "", false, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-clientdamage", },
{ "-mpnoreturn", "Disable flight deck option", true, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-mpnoreturn", },
{ "-gateway_ip", "Set gateway IP address", false, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-gateway_ip", },
{ "-ingame_join", "Disable in-game joining", true, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-ingame_join", },
{ "-no_set_gamma", "Disable setting of gamma", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_set_gamma", },
{ "-nomovies", "Disable video playback", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-nomovies", },
@@ -230,7 +231,6 @@ Flag exe_params[] =
{ "-fix_registry", "Use a different registry path", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-fix_registry", },
#endif
{ "-ingame_join", "Allow in-game joining", true, 0, EASY_DEFAULT, "Experimental", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-ingame_join", },
{ "-voicer", "Enable voice recognition", true, 0, EASY_DEFAULT, "Experimental", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-voicer", },
{ "-bmpmanusage", "Show how many BMPMAN slots are in use", false, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-bmpmanusage", },
@@ -260,6 +260,7 @@ Flag exe_params[] =
{ "-gr_debug", "Output graphics debug information", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-gr_debug", },
{ "-stdout_log", "Output log file to stdout", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-stdout_log", },
{ "-slow_frames_ok", "Don't adjust timestamps for slow frames", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-slow_frames_ok", },
{ "-imgui_debug", "Show imgui debug/demo window in the lab", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-imgui_debug", },
};
// clang-format on
@@ -317,16 +318,15 @@ int Cmdline_use_last_pilot = 0;
cmdline_parm fov_arg("-fov", "Vertical field-of-view factor", AT_FLOAT); // Cmdline_fov -- comand line FOV -Bobboau
cmdline_parm fov_cockpit_arg("-fov_cockpit", "Vertical field-of-view factor for Cockpits", AT_FLOAT);
cmdline_parm clip_dist_arg("-clipdist", "Changes the distance from the viewpoint for the near-clipping plane", AT_FLOAT); // Cmdline_clip_dist
cmdline_parm spec_static_arg("-spec_static", "Adjusts suns contribution to specular highlights", AT_FLOAT);
cmdline_parm spec_point_arg("-spec_point", "Adjusts laser weapons contribution to specular highlights", AT_FLOAT);
cmdline_parm spec_tube_arg("-spec_tube", "Adjusts beam weapons contribution to specular highlights", AT_FLOAT);
cmdline_parm ambient_factor_arg("-ambient_factor", "Adjusts ambient light applied to all parts of a ship", AT_INT); // Cmdline_ambient_factor
cmdline_parm ambient_power_arg("-ambient", "Multiplies the brightness of all ambient light", AT_FLOAT);
cmdline_parm light_power_arg("-light", "Multiplies the brightness of all light", AT_FLOAT);
cmdline_parm emissive_power_arg("-emissive", "Multiplies the brightness of all ambient light", AT_FLOAT);
cmdline_parm emissive_arg("-emissive_light", "Enable emissive light from ships", AT_NONE); // semi-deprecated but still functional
cmdline_parm env("-noenv", NULL, AT_NONE); // Cmdline_env
cmdline_parm glow_arg("-noglow", NULL, AT_NONE); // Cmdline_glow -- use Bobs glow code
cmdline_parm nomotiondebris_arg("-nomotiondebris", NULL, AT_NONE); // Cmdline_nomotiondebris -- Removes those ugly floating rocks -C
cmdline_parm noscalevid_arg("-noscalevid", NULL, AT_NONE); // Cmdline_noscalevid -- disable video scaling that fits to window
cmdline_parm spec_arg("-nospec", NULL, AT_NONE); // Cmdline_spec --
cmdline_parm emissive_arg("-emissive_light", "Enable emissive light from ships", AT_NONE); // Cmdline_no_emissive -- don't use emissive light in OGL
cmdline_parm normal_arg("-nonormal", NULL, AT_NONE); // Cmdline_normal -- disable normal mapping
cmdline_parm height_arg("-noheight", NULL, AT_NONE); // Cmdline_height -- enable support for parallax mapping
cmdline_parm enable_3d_shockwave_arg("-3dshockwave", NULL, AT_NONE);
@@ -345,10 +345,13 @@ cmdline_parm flightshaftsoff_arg("-nolightshafts", NULL, AT_NONE);
cmdline_parm shadow_quality_arg("-shadow_quality", NULL, AT_INT);
cmdline_parm enable_shadows_arg("-enable_shadows", NULL, AT_NONE);
cmdline_parm no_deferred_lighting_arg("-no_deferred", NULL, AT_NONE); // Cmdline_no_deferred
cmdline_parm deferred_lighting_cockpit_arg("-deferred_cockpit", nullptr, AT_NONE);
cmdline_parm anisotropy_level_arg("-anisotropic_filter", NULL, AT_INT);
float Cmdline_clip_dist = Default_min_draw_distance;
int Cmdline_ambient_factor = 128;
float Cmdline_ambient_power = 1.0f;
float Cmdline_emissive_power = 0.0f;
float Cmdline_light_power = 1.0f;
int Cmdline_env = 1;
int Cmdline_mipmap = 0;
int Cmdline_glow = 1;
@@ -362,6 +365,7 @@ int Cmdline_softparticles = 0;
int Cmdline_bloom_intensity = 25;
bool Cmdline_force_lightshaft_off = false;
int Cmdline_no_deferred_lighting = 0;
bool Cmdline_deferred_lighting_cockpit = false;
int Cmdline_aniso_level = 0;
// Game Speed related
@@ -373,21 +377,18 @@ int Cmdline_no_vsync = 0;
// HUD related
cmdline_parm ballistic_gauge("-ballistic_gauge", NULL, AT_NONE); // Cmdline_ballistic_gauge
cmdline_parm dualscanlines_arg("-dualscanlines", NULL, AT_NONE); // Cmdline_dualscanlines -- Change to phreaks options including new targeting code
cmdline_parm dualscanlines_arg("-dualscanlines", NULL, AT_NONE); // Cmdline_dualscanlines -- Change to phreaks options including new targeting code; semi-deprecated but still functional
cmdline_parm orb_radar("-orbradar", NULL, AT_NONE); // Cmdline_orb_radar
cmdline_parm rearm_timer_arg("-rearm_timer", NULL, AT_NONE); // Cmdline_rearm_timer
cmdline_parm targetinfo_arg("-targetinfo", NULL, AT_NONE); // Cmdline_targetinfo -- Adds ship name/class to right of target box -C
cmdline_parm rearm_timer_arg("-rearm_timer", NULL, AT_NONE); // Cmdline_rearm_timer; semi-deprecated but still functional-Mjn
cmdline_parm targetinfo_arg("-targetinfo", NULL, AT_NONE); // Cmdline_targetinfo -- Adds ship name/class to right of target box -C; semi-deprecated but still functional-Mjn
int Cmdline_ballistic_gauge = 0; // WMCoolmon's gauge thingy
int Cmdline_dualscanlines = 0;
int Cmdline_orb_radar = 0;
int Cmdline_rearm_timer = 0;
int Cmdline_targetinfo = 0;
// Gameplay related
cmdline_parm use_3dwarp("-3dwarp", nullptr, AT_NONE); // Is now Fireball_use_3d_warp
cmdline_parm ship_choice_3d_arg("-ship_choice_3d", nullptr, AT_NONE); // Cmdline_ship_choice_3d
cmdline_parm weapon_choice_3d_arg("-weapon_choice_3d", nullptr, AT_NONE); // Cmdline_weapon_choice_3d
cmdline_parm use_warp_flash("-warp_flash", nullptr, AT_NONE); // Cmdline_warp_flash
cmdline_parm allow_autpilot_interrupt("-no_ap_interrupt", nullptr, AT_NONE);
cmdline_parm stretch_menu("-stretch_menu", nullptr, AT_NONE); // Cmdline_stretch_menu
@@ -397,7 +398,6 @@ cmdline_parm deadzone("-deadzone",
int Cmdline_ship_choice_3d = 0;
int Cmdline_weapon_choice_3d = 0;
int Cmdline_warp_flash = 0;
int Cmdline_autopilot_interruptable = 1;
int Cmdline_stretch_menu = 0;
int Cmdline_no_screenshake = 0;
@@ -421,8 +421,8 @@ cmdline_parm mpnoreturn_arg("-mpnoreturn", NULL, AT_NONE); // Cmdline_mpnoreturn
cmdline_parm objupd_arg("-cap_object_update", "Multiplayer object update cap (0-3)", AT_INT);
cmdline_parm gateway_ip_arg("-gateway_ip", "Set gateway IP address", AT_STRING);
char *Cmdline_almission = NULL; //DTP for autoload multi mission.
int Cmdline_ingamejoin = 0;
char *Cmdline_almission = nullptr; //DTP for autoload multi mission.
int Cmdline_ingamejoin = 1;
int Cmdline_mpnoreturn = 0;
int Cmdline_objupd = 3; // client object updates on LAN by default
char *Cmdline_gateway_ip = nullptr;
@@ -476,6 +476,8 @@ bool Cmdline_dump_packet_type = false;
#ifdef WIN32
bool Cmdline_alternate_registry_path = false;
#endif
uint Cmdline_rng_seed = 0;
bool Cmdline_reuse_rng_seed = false;
// Developer/Testing related
cmdline_parm start_mission_arg("-start_mission", "Skip mainhall and run this mission", AT_STRING); // Cmdline_start_mission
@@ -507,7 +509,10 @@ cmdline_parm debug_window_arg("-debug_window", NULL, AT_NONE); // Cmdline_debug_
cmdline_parm graphics_debug_output_arg("-gr_debug", nullptr, AT_NONE); // Cmdline_graphics_debug_output
cmdline_parm log_to_stdout_arg("-stdout_log", nullptr, AT_NONE); // Cmdline_log_to_stdout
cmdline_parm slow_frames_ok_arg("-slow_frames_ok", nullptr, AT_NONE); // Cmdline_slow_frames_ok
cmdline_parm fixed_seed_rand("-seed", nullptr, AT_INT); // Cmdline_rng_seed,Cmdline_reuse_rng_seed;
cmdline_parm luadev_arg("-luadev", nullptr, AT_NONE); // Cmdline_lua_devmode
cmdline_parm override_arg("-override_data", nullptr, AT_NONE); // Cmdline_override_data
cmdline_parm imgui_debug_arg("-imgui_debug", nullptr, AT_NONE);
char *Cmdline_start_mission = NULL;
int Cmdline_dis_collisions = 0;
@@ -540,6 +545,9 @@ bool Cmdline_debug_window = false;
bool Cmdline_graphics_debug_output = false;
bool Cmdline_log_to_stdout = false;
bool Cmdline_slow_frames_ok = false;
bool Cmdline_lua_devmode = false;
bool Cmdline_override_data = false;
bool Cmdline_show_imgui_debug = false;
// Other
cmdline_parm get_flags_arg(GET_FLAGS_STRING, "Output the launcher flags file", AT_STRING);
@@ -562,6 +570,12 @@ cmdline_parm deprecated_missile_lighting_arg("-missile_lighting", "Deprecated",
cmdline_parm deprecated_cache_bitmaps_arg("-cache_bitmaps", "Deprecated", AT_NONE);
cmdline_parm deprecated_no_emissive_arg("-no_emissive_light", "Deprecated", AT_NONE);
cmdline_parm deprecated_postprocess_arg("-post_process", "Deprecated", AT_NONE);
cmdline_parm deprecated_spec_static_arg("-spec_static", "Deprecated", AT_NONE);
cmdline_parm deprecated_spec_point_arg("-spec_point", "Deprecated", AT_NONE);
cmdline_parm deprecated_spec_tube_arg("-spec_tube", "Deprecated", AT_NONE);
cmdline_parm deprecated_ambient_factor_arg("-ambient_factor", "Deprecated", AT_NONE); //
cmdline_parm deprecated_ship_choice_3d_arg("-ship_choice_3d", "Deprecated", AT_NONE);
cmdline_parm deprecated_weapon_choice_3d_arg("-weapon_choice_3d", "Deprecated", AT_NONE);
#ifndef NDEBUG
// NOTE: this assumes that os_init() has already been called but isn't a fatal error if it hasn't
@@ -1716,7 +1730,7 @@ bool SetCmdlineParams()
if(targetinfo_arg.found())
{
Cmdline_targetinfo = 1;
Extra_target_info = true;
}
if(nomovies_arg.found() ) {
@@ -1823,7 +1837,7 @@ bool SetCmdlineParams()
}
if ( use_warp_flash.found() ) {
Cmdline_warp_flash = 1;
Fireball_warp_flash = true;
}
if ( allow_autpilot_interrupt.found() ) {
@@ -1841,22 +1855,21 @@ bool SetCmdlineParams()
if ( stretch_menu.found() ) {
Cmdline_stretch_menu = 1;
}
// new lighting lines
if ( ambient_power_arg.found() )
Cmdline_ambient_power = ambient_power_arg.get_float();
// specular comand lines
if ( spec_point_arg.found() ) {
static_point_factor = spec_point_arg.get_float();
if (emissive_power_arg.found() && emissive_power_arg.has_param()) {
Cmdline_emissive_power = emissive_power_arg.get_float();
} else if (emissive_arg.found() || emissive_power_arg.found()) {
// for legacy support no argument param defaults to the old emissive value
Cmdline_emissive_power = 0.30f;
}
if ( spec_static_arg.found() ) {
static_light_factor = spec_static_arg.get_float();
}
if (light_power_arg.found())
Cmdline_light_power = light_power_arg.get_float();
if ( spec_tube_arg.found() ) {
static_tube_factor = spec_tube_arg.get_float();
}
if ( spec_arg.found() )
{
if (spec_arg.found()) {
Cmdline_spec = 0;
}
@@ -1911,22 +1924,13 @@ bool SetCmdlineParams()
if ( glow_arg.found() )
Cmdline_glow = 0;
if ( ship_choice_3d_arg.found() )
Cmdline_ship_choice_3d = 1;
if ( weapon_choice_3d_arg.found() )
Cmdline_weapon_choice_3d = 1;
if (ingamejoin_arg.found() )
Cmdline_ingamejoin = 1;
Cmdline_ingamejoin = 0;
if ( start_mission_arg.found() ) {
Cmdline_start_mission = start_mission_arg.str();
}
if ( ambient_factor_arg.found() )
Cmdline_ambient_factor = ambient_factor_arg.get_int();
if ( output_scripting_arg.found() )
Output_scripting_meta = true;
@@ -2009,10 +2013,6 @@ bool SetCmdlineParams()
Cmdline_no_fbo = 1;
}
if ( emissive_arg.found() ) {
Cmdline_emissive = 1;
}
if ( rearm_timer_arg.found() )
Cmdline_rearm_timer = 1;
@@ -2072,11 +2072,17 @@ bool SetCmdlineParams()
if( enable_shadows_arg.found() )
{
// if only using `enable_shadows` then default quality level can be overriden in mod_settings.tbl --wookieejedi
Shadow_quality_uses_mod_option = true;
Shadow_quality = ShadowQuality::Medium;
}
if( shadow_quality_arg.found() )
{
// set that we are not using default shadow quality level --wookieejedi
Shadow_quality_uses_mod_option = false;
switch (shadow_quality_arg.get_int()) {
case 0:
Shadow_quality = ShadowQuality::Disabled;
@@ -2105,6 +2111,11 @@ bool SetCmdlineParams()
Cmdline_no_deferred_lighting = 1;
}
if( deferred_lighting_cockpit_arg.found() )
{
Cmdline_deferred_lighting_cockpit = true;
}
if (anisotropy_level_arg.found())
{
Cmdline_aniso_level = anisotropy_level_arg.get_int();
@@ -2160,6 +2171,17 @@ bool SetCmdlineParams()
if (slow_frames_ok_arg.found()) {
Cmdline_slow_frames_ok = true;
}
if ( luadev_arg.found()) {
Cmdline_lua_devmode = true;
}
if ( override_arg.found()) {
Cmdline_override_data = true;
}
if (imgui_debug_arg.found()) {
Cmdline_show_imgui_debug = true;
}
if (show_video_info.found())
{
@@ -2230,6 +2252,16 @@ bool SetCmdlineParams()
Cmdline_dump_packet_type = true;
}
if (fixed_seed_rand.found()) {
Cmdline_rng_seed = abs(fixed_seed_rand.get_int());
if (Cmdline_rng_seed>0) {
Cmdline_reuse_rng_seed = true;
}
else {
Warning(LOCATION,"-seed must be an integer greater than 0. Invalid input seed will be disregarded.");
}
}
return true;
}
+7 -6
View File
@@ -53,10 +53,9 @@ extern char *Cmdline_center_res;
// Graphics related
extern float Cmdline_clip_dist;
extern float static_light_factor;
extern float static_point_factor;
extern float static_tube_factor;
extern int Cmdline_ambient_factor;
extern float Cmdline_ambient_power;
extern float Cmdline_emissive_power;
extern float Cmdline_light_power;
extern int Cmdline_env;
extern int Cmdline_glow;
extern int Cmdline_noscalevid; // disables fit-to-window for movies - taylor
@@ -68,6 +67,7 @@ extern int Cmdline_softparticles;
extern int Cmdline_bloom_intensity;
extern bool Cmdline_force_lightshaft_off;
extern int Cmdline_no_deferred_lighting;
extern bool Cmdline_deferred_lighting_cockpit;
extern int Cmdline_emissive;
extern int Cmdline_aniso_level;
@@ -80,12 +80,10 @@ extern int Cmdline_ballistic_gauge;
extern int Cmdline_dualscanlines;
extern int Cmdline_orb_radar;
extern int Cmdline_rearm_timer;
extern int Cmdline_targetinfo;
// Gameplay related
extern int Cmdline_ship_choice_3d;
extern int Cmdline_weapon_choice_3d;
extern int Cmdline_warp_flash;
extern int Cmdline_autopilot_interruptable;
extern int Cmdline_stretch_menu;
extern int Cmdline_no_screenshake;
@@ -155,6 +153,9 @@ extern bool Cmdline_debug_window;
extern bool Cmdline_graphics_debug_output;
extern bool Cmdline_log_to_stdout;
extern bool Cmdline_slow_frames_ok;
extern bool Cmdline_lua_devmode;
extern bool Cmdline_override_data;
extern bool Cmdline_show_imgui_debug;
enum class WeaponSpewType { NONE = 0, STANDARD, ALL };
extern WeaponSpewType Cmdline_spew_weapon_stats;
+23 -15
View File
@@ -30,6 +30,7 @@
#include "network/multi_pmsg.h"
#include "network/multiutil.h"
#include "scripting/scripting.h"
#include "scripting/global_hooks.h"
#include "playerman/player.h"
#include "pilotfile/pilotfile.h"
#include "popup/popup.h"
@@ -174,7 +175,7 @@ int Control_check_count = 0;
static int Tab; // which tab we are currently in
static int Binding_mode = 0; // are we waiting for a key to bind it?
static int Bind_time = 0;
static UI_TIMESTAMP Bind_time = UI_TIMESTAMP::invalid();
static int Search_mode = 0; // are we waiting for a key to bind it?
static int Last_key = -1;
static int Selected_line = 0; // line that is currently selected for binding
@@ -1173,7 +1174,7 @@ void control_config_do_bind()
control_config_detect_axis_reset();
Binding_mode = 1;
Bind_time = timer_get_milliseconds();
Bind_time = ui_timestamp();
Search_mode = 0;
Last_key = -1;
Axis_override.clear();
@@ -1970,7 +1971,7 @@ void control_config_do_frame(float frametime)
}
// Debounce timer to allow mouse double-click (maybe?)
if (!done && (Bind_time + 375 < timer_get_milliseconds())) {
if (!done && (ui_timestamp_since(Bind_time) > 375)) {
for (i=0; i<NUM_BUTTONS; i++){
if ( (CC_Buttons[gr_screen.res][i].button.is_mouse_on()) && (CC_Buttons[gr_screen.res][i].button.enabled()) ){
break;
@@ -2635,10 +2636,11 @@ int check_control(int id, int key)
// If we reach this point, then it means this is a continuous control
// which has just been released
if (Script_system.IsActiveAction(CHA_ONACTIONSTOPPED)) {
Script_system.SetHookVar("Action", 's', Control_config[id].text);
Script_system.RunCondition(CHA_ONACTIONSTOPPED, nullptr, nullptr, id);
Script_system.RemHookVar("Action");
if (scripting::hooks::OnActionStopped->isActive()) {
scripting::hooks::OnActionStopped->run(scripting::hooks::ControlActionConditions{ id },
scripting::hook_param_list(
scripting::hook_param("Action", 's', Control_config[id].text)
));
}
Control_config[id].continuous_ongoing = false;
@@ -2794,7 +2796,7 @@ void control_get_axes_readings(int *axis_v, float frame_time)
switch (item.type) {
case CC_TYPE_AXIS_ABS:
axis_v[action] = item.used;
axis_v[action] = item.analog_value;
break;
case CC_TYPE_AXIS_REL:
axis_v[action] = 0;
@@ -2803,12 +2805,13 @@ void control_get_axes_readings(int *axis_v, float frame_time)
case CC_TYPE_AXIS_BTN_POS:
default:
//This should never happen, especially with the above Assertion. This is required as incomplete switches on an enum generate warnings
UNREACHABLE("Unhandled control item type");
break;
}
}
//Store values for possible lua override
item.used = axis_v[action];
item.analog_value = axis_v[action];
}
}
@@ -2821,24 +2824,29 @@ void control_used(int id)
// This check needs to be done because the control code might call this function more than once per frame,
// and we don't want to run the hooks more than once per frame
if (Control_config[id].used < Last_frame_timestamp) {
if (!Control_config[id].digital_used.isValid() || timestamp_compare(Control_config[id].digital_used, Last_frame_timestamp) < 0) {
if (!Control_config[id].continuous_ongoing) {
Script_system.SetHookVar("Action", 's', Control_config[id].text);
Script_system.RunCondition(CHA_ONACTION, nullptr, nullptr, id);
Script_system.RemHookVar("Action");
if (scripting::hooks::OnAction->isActive()) {
scripting::hooks::OnAction->run(scripting::hooks::ControlActionConditions{ id },
scripting::hook_param_list(
scripting::hook_param("Action", 's', Control_config[id].text)
));
}
if (Control_config[id].type == CC_TYPE_CONTINUOUS)
Control_config[id].continuous_ongoing = true;
}
Control_config[id].used = timestamp();
Control_config[id].digital_used = Last_frame_timestamp;
}
}
void control_config_clear_used_status()
{
// note: this is only for digital controls like button presses,
// so we don't need to clear the analog value
for (auto &item : Control_config) {
item.used = 0;
item.digital_used = TIMESTAMP::invalid();
}
}
+5 -1
View File
@@ -294,6 +294,8 @@ enum IoActionId : int {
JOY_ABS_THROTTLE_AXIS = 127,
JOY_REL_THROTTLE_AXIS = 128,
TOGGLE_HUD_SHADOWS,
/*!
* This must always be below the last defined item
*/
@@ -565,7 +567,9 @@ public:
CC_type type; //!< manner control should be checked in
// Items used during gameplay
int used; //!< has control been used yet in mission? If so, this is the timestamp. For axes, this denotes the last frame's value
TIMESTAMP digital_used; //!< has control been used yet in mission? If so, this is the timestamp.
// Note this is not a UI timestamp because this is purely for mission timing purposes.
int analog_value; // For axes, this denotes the last frame's value
bool disabled = true; //!< whether this action should be available at all
bool locked = false; //!< whether this action will be triggered by the respectively bound key
bool scriptEnabledByDefault = false; //!< whether this binding will execute it's registered hooks if triggered. Resets each mission
+7 -2
View File
@@ -258,6 +258,7 @@ void control_config_common_init_bindings() {
// HUD
(TOGGLE_HUD, KEY_SHIFTED | KEY_O, -1, COMPUTER_TAB, 1, "Toggle HUD", CC_TYPE_TRIGGER)
(TOGGLE_HUD_CONTRAST, KEY_L, -1, COMPUTER_TAB, 1, "Toggle High HUD Contrast", CC_TYPE_TRIGGER)
(TOGGLE_HUD_SHADOWS, KEY_ALTED | KEY_L, -1, COMPUTER_TAB, 0, "Toggle HUD Drop Shadows", CC_TYPE_TRIGGER)
(HUD_TARGETBOX_TOGGLE_WIREFRAME, KEY_ALTED | KEY_SHIFTED | KEY_Q, -1, COMPUTER_TAB, 1, "Toggle HUD Wireframe Target View", CC_TYPE_TRIGGER)
// Custom Controls
@@ -409,6 +410,7 @@ SCP_unordered_map<SCP_string, IoActionId> old_text = {
{"Increase Time Compression", TIME_SPEED_UP},
{"Decrease Time Compression", TIME_SLOW_DOWN},
{"Toggle High HUD Contrast", TOGGLE_HUD_CONTRAST},
{"Toggle HUD Drop Shadows", TOGGLE_HUD_SHADOWS},
{"(Multiplayer) Toggle Network Info", MULTI_TOGGLE_NETINFO},
{"(Multiplayer) Self Destruct", MULTI_SELF_DESTRUCT},
@@ -736,7 +738,8 @@ void control_config_common_init()
}
for (int i = 0; i < Action::NUM_VALUES; i++) {
Control_config[i + JOY_AXIS_BEGIN].used = JOY_AXIS_CENTER;
Control_config[i + JOY_AXIS_BEGIN].analog_value = JOY_AXIS_CENTER;
Control_config[i + JOY_AXIS_BEGIN].digital_used = TIMESTAMP::invalid();
}
// TODO It's not memory efficient to keep the presets loaded into memory all the time, but we do need to know which
@@ -1122,6 +1125,7 @@ void LoadEnumsIntoActionMap() {
ADD_ENUM_TO_ACTION_MAP(TIME_SLOW_DOWN)
ADD_ENUM_TO_ACTION_MAP(TOGGLE_HUD_CONTRAST)
ADD_ENUM_TO_ACTION_MAP(TOGGLE_HUD_SHADOWS)
ADD_ENUM_TO_ACTION_MAP(MULTI_TOGGLE_NETINFO)
@@ -2756,7 +2760,8 @@ CCI& CCI::operator=(const CCI& A) {
indexXSTR = A.indexXSTR;
text = A.text;
type = A.type;
used = A.used;
analog_value = A.analog_value;
digital_used = A.digital_used;
disabled = A.disabled;
locked = A.locked;
scriptEnabledByDefault = A.scriptEnabledByDefault;
+19 -3
View File
@@ -95,7 +95,7 @@ void VideoPresenter::uploadVideoFrame(const VideoFramePtr& frame) {
}
}
void VideoPresenter::displayFrame(float x1, float y1, float x2, float y2) {
void VideoPresenter::displayFrame(float x1, float y1, float x2, float y2, float alpha) {
GR_DEBUG_SCOPE("Draw video frame");
movie_vertex vertex_data[4];
@@ -127,10 +127,26 @@ void VideoPresenter::displayFrame(float x1, float y1, float x2, float y2) {
layout.add_vertex_component(vertex_format_data::POSITION2, sizeof(vertex_data[0]), offsetof(movie_vertex, pos));
layout.add_vertex_component(vertex_format_data::TEX_COORD2, sizeof(vertex_data[0]), offsetof(movie_vertex, uv));
if (_properties.pixelFormat == FramePixelFormat::YUV420) {
switch (_properties.pixelFormat) {
case FramePixelFormat::YUV420:
material_set_movie(&_movie_material,
_planeTextureHandles[0],
_planeTextureHandles[1],
_planeTextureHandles[2],
alpha);
gr_render_movie(&_movie_material, PRIM_TYPE_TRISTRIP, &layout, 4, gr_immediate_buffer_handle, offset);
} else {
break;
case FramePixelFormat::BGR:
material_set_unlit(&_rgb_material, _planeTextureHandles[0], alpha, false, false);
gr_render_primitives(&_rgb_material, PRIM_TYPE_TRISTRIP, &layout, 0, 4, gr_immediate_buffer_handle, offset);
break;
case FramePixelFormat::BGRA:
material_set_unlit(&_rgb_material, _planeTextureHandles[0], alpha, true, false);
gr_render_primitives(&_rgb_material, PRIM_TYPE_TRISTRIP, &layout, 0, 4, gr_immediate_buffer_handle, offset);
break;
default:
UNREACHABLE("Unhandled enum value!");
break;
}
}
+1 -1
View File
@@ -30,7 +30,7 @@ class VideoPresenter {
void uploadVideoFrame(const VideoFramePtr& frame);
void displayFrame(float x1, float y1, float x2, float y2);
void displayFrame(float x1, float y1, float x2, float y2, float alpha = 1.0f);
};
}
}
+100 -23
View File
@@ -48,38 +48,101 @@ void cutscene_close()
}
}
// initialization stuff for cutscenes
void cutscene_init()
static cutscene_info *get_cutscene_pointer(char *cutscene_filename)
{
atexit(cutscene_close);
for (int i = 0; i < (int)Cutscenes.size(); i++) {
if (!stricmp(cutscene_filename, Cutscenes[i].filename)) {
return &Cutscenes[i];
}
}
// Didn't find anything.
return NULL;
}
static void cutscene_info_init(cutscene_info *csni)
{
csni->filename[0] = '\0';
csni->name[0] = '\0';
csni->description = NULL;
csni->flags = {};
}
// initialization stuff for cutscenes
void parse_cutscene_table(const char* filename)
{
char buf[MULTITEXT_LENGTH];
cutscene_info cutinfo;
cutscene_info csnt;
cutscene_info_init(&csnt);
cutscene_info *csnp;
bool create_if_not_found = true;
try
{
read_file_text("cutscenes.tbl", CF_TYPE_TABLES);
read_file_text(filename, CF_TYPE_TABLES);
reset_parse();
// parse in all the cutscenes
Cutscenes.clear();
skip_to_string("#Cutscenes");
ignore_white_space();
bool isFirstCutscene = true;
while (required_string_either("#End", "$Filename:"))
{
bool csn_new = false;
required_string("$Filename:");
stuff_string(cutinfo.filename, F_PATHNAME, MAX_FILENAME_LEN);
stuff_string(csnt.filename, F_PATHNAME, MAX_FILENAME_LEN);
required_string("$Name:");
stuff_string(cutinfo.name, F_NAME, NAME_LENGTH);
if (optional_string("+nocreate")) {
if (!Parsing_modular_table) {
Warning(LOCATION, "+nocreate flag used for cutscene in non-modular table\n");
}
create_if_not_found = false;
}
required_string("$Description:");
stuff_string(buf, F_MULTITEXT, sizeof(buf));
drop_white_space(buf);
compact_multitext_string(buf);
cutinfo.description = vm_strdup(buf);
// Does this cutscene exist already?
// If so, load this new info into it
csnp = get_cutscene_pointer(csnt.filename);
if (csnp != NULL) {
if (!Parsing_modular_table) {
error_display(1,
"Error: Cutscene %s already exists. All cutscene names must be unique.",
csnt.filename);
}
} else {
// Don't create cutscene if it has +nocreate and is in a modular table.
if (!create_if_not_found && Parsing_modular_table) {
if (!skip_to_start_of_string_either("$Filename:", "#End")) {
error_display(1, "Missing [#End] or [$Filename] after cutscene %s", csnt.filename);
}
continue;
}
Cutscenes.push_back(csnt);
csn_new = true;
csnp = &Cutscenes[Cutscenes.size() -1];
}
//If $Name is not found use the $Filename instead because this field needs data
//but only do this if if we're parsing the tbl and not a tbm
if (optional_string("$Name:")) {
stuff_string(csnp->name, F_NAME, NAME_LENGTH);
mprintf(("Adding cutscene %s\n", csnp->name));
} else if (strlen(csnp->name) == 0) {
strcpy_s(csnp->name, csnt.filename);
mprintf(("Missing $Name: in cutscene.tbl. Using filename %s instead.\n", csnt.filename));
}
//If $Description is not found we can leave it blank
if (optional_string("$Description:")) {
stuff_string(buf, F_MULTITEXT, sizeof(buf));
drop_white_space(buf);
compact_multitext_string(buf);
csnp->description = vm_strdup(buf);
}
if (optional_string("$cd:"))
{
@@ -88,13 +151,14 @@ void cutscene_init()
stuff_int(&junk);
}
cutinfo.flags.reset();
if (csn_new) {
csnp->flags.reset();
}
if (isFirstCutscene)
if (Cutscenes.empty())
{
isFirstCutscene = false;
// The original code assumes the first movie is the intro, so make it viewable
cutinfo.flags.set(Cutscene::Cutscene_Flags::Viewable);
csnp->flags.set(Cutscene::Cutscene_Flags::Viewable);
}
if (optional_string("$Always Viewable:"))
@@ -102,17 +166,16 @@ void cutscene_init()
bool flag;
stuff_boolean(&flag);
if (flag)
cutinfo.flags.set(Cutscene::Cutscene_Flags::Always_viewable);
csnp->flags.set(Cutscene::Cutscene_Flags::Always_viewable);
}
if (optional_string("$Never Viewable:"))
{
bool flag;
stuff_boolean(&flag);
if (flag)
cutinfo.flags.set(Cutscene::Cutscene_Flags::Never_viewable);
csnp->flags.set(Cutscene::Cutscene_Flags::Never_viewable);
}
Cutscenes.push_back(cutinfo);
}
required_string("#End");
@@ -124,6 +187,20 @@ void cutscene_init()
}
}
void cutscene_init()
{
atexit(cutscene_close);
Cutscenes.clear();
// first parse the default table
parse_cutscene_table("cutscenes.tbl");
// parse any modular tables
parse_modular_table("*-csn.tbm", parse_cutscene_table);
}
// marks a cutscene as viewable
void cutscene_mark_viewable(const char* filename)
{
+4 -3
View File
@@ -355,7 +355,8 @@ void Player::stopPlayback() {
audioPlaybackClose(&m_state);
videoPlaybackClose(&m_state);
m_decoderThread->join();
if(m_decoderThread->joinable())
m_decoderThread->join();
}
void Player::decoderThread() {
@@ -385,13 +386,13 @@ const PlayerState& Player::getInternalState() const {
const MovieProperties& Player::getMovieProperties() const {
return m_state.props;
}
void Player::draw(float x1, float y1, float x2, float y2) {
void Player::draw(float x1, float y1, float x2, float y2, float alpha) {
if (!m_state.currentFrame) {
return;
}
if (m_state.videoPresenter) {
m_state.videoPresenter->displayFrame(x1, y1, x2, y2);
m_state.videoPresenter->displayFrame(x1, y1, x2, y2, alpha);
}
}
SCP_string Player::getCurrentSubtitle() {
+1 -1
View File
@@ -110,7 +110,7 @@ class Player {
* @param x2 The X coordinate of the bottom right corner
* @param y2 The Y coordinate of the bottom right corner
*/
void draw(float x1, float y1, float x2, float y2);
void draw(float x1, float y1, float x2, float y2, float alpha = 1.0f);
/**
* @brief Gets the subtitle text that should be displayed now
+226 -136
View File
@@ -25,8 +25,10 @@
#include "radar/radar.h"
#include "radar/radarsetup.h"
#include "render/3d.h"
#include "scripting/global_hooks.h"
#include "scripting/hook_api.h"
#include "scripting/scripting.h"
#include "scripting/api/objs/vecmath.h"
#include "ship/ship.h"
#include "ship/shipfx.h"
#include "species_defs/species_defs.h"
@@ -34,8 +36,8 @@
#include "utils/Random.h"
#include "weapon/weapon.h"
#define MIN_RADIUS_FOR_PERSISTANT_DEBRIS 50 // ship radius at which debris from it becomes persistant
#define DEBRIS_SOUND_DELAY 2000 // time to start debris sound after created
constexpr int MIN_RADIUS_FOR_PERSISTENT_DEBRIS = 50; // ship radius at which debris from it becomes persistant
constexpr int DEBRIS_SOUND_DELAY = 2000; // time to start debris sound after created
int Num_hull_pieces; // number of hull pieces in existence
// we now maintain a kind of "virtual" Hull_debris_list,
@@ -54,18 +56,11 @@ int Debris_num_submodels = 0;
#define DEBRIS_INDEX(dp) (int)(dp-Debris.data())
const auto OnDebrisCreatedHook = scripting::Hook::Factory(
"On Debris Created",
"Invoked when a piece of debris is created.",
{
{"Debris", "debris", "The newly created debris object"},
{"Source", "object", "The object (probably a ship) from which this debris piece was spawned."},
});
/**
* Start the sequence of a piece of debris writhing in unholy agony!!!
*/
static void debris_start_death_roll(object *debris_obj, debris *debris_p)
static void debris_start_death_roll(object *debris_obj, debris *debris_p, vec3d *hitpos = nullptr)
{
if (debris_p->is_hull) {
// tell everyone else to blow up the piece of debris
@@ -87,6 +82,15 @@ static void debris_start_death_roll(object *debris_obj, debris *debris_p)
}
}
if (scripting::hooks::OnDebrisDeath->isActive()) {
scripting::hooks::OnDebrisDeath->run(scripting::hook_param_list(
scripting::hook_param("Debris", 'o', debris_obj),
scripting::hook_param("Hitpos",
'o',
scripting::api::l_Vector.Set(hitpos ? *hitpos : vmd_zero_vector),
hitpos != nullptr)));
}
debris_obj->flags.set(Object::Object_Flags::Should_be_dead);
}
@@ -185,7 +189,9 @@ void debris_delete( object * obj )
db = &Debris[num];
model_delete_instance(db->model_instance_num);
if (db->model_instance_num >= 0) {
model_delete_instance(db->model_instance_num);
}
if ( db->is_hull ) {
debris_remove_from_hull_list(db);
@@ -218,7 +224,7 @@ void debris_process_post(object * obj, float frame_time)
if ( timestamp_elapsed(db->sound_delay) ) {
obj_snd_assign(objnum, db->ambient_sound, &vmd_zero_vector);
db->sound_delay = 0;
db->sound_delay = TIMESTAMP::invalid();
}
}
@@ -238,7 +244,7 @@ void debris_process_post(object * obj, float frame_time)
if ( !timestamp_elapsed(db->fire_timeout) && timestamp_elapsed(db->next_fireball)) {
db->next_fireball = timestamp_rand(db->arc_frequency,db->arc_frequency*2 );
db->next_fireball = _timestamp_rand(db->arc_frequency,db->arc_frequency*2 );
db->arc_frequency += 100;
if (db->is_hull) {
@@ -256,9 +262,9 @@ void debris_process_post(object * obj, float frame_time)
// Create the spark effects
for (int i=0; i<MAX_DEBRIS_ARCS; ++i) {
if ( !timestamp_valid( db->arc_timestamp[i] ) ) {
if ( !db->arc_timestamp[i].isValid() ) {
db->arc_timestamp[i] = timestamp(lifetime); // live up to a second
db->arc_timestamp[i] = _timestamp(lifetime); // live up to a second
switch( n ) {
case 0:
@@ -313,10 +319,10 @@ void debris_process_post(object * obj, float frame_time)
}
for (int i=0; i<MAX_DEBRIS_ARCS; ++i) {
if ( timestamp_valid( db->arc_timestamp[i] ) ) {
if ( db->arc_timestamp[i].isValid() ) {
if ( timestamp_elapsed( db->arc_timestamp[i] ) ) {
// Kill off the spark
db->arc_timestamp[i] = timestamp(-1);
db->arc_timestamp[i] = TIMESTAMP::invalid();
} else {
// Maybe move a vertex.... 20% of the time maybe?
int mr = Random::next();
@@ -368,30 +374,44 @@ MONITOR(NumHullDebris)
* @param source_obj Source object
* @param model_num Model number
* @param submodel_num Sub-model number
* @param pos Position in vector space
* @param exp_center Explosion center in vector space
* @param hull_flag Hull flag settings
* @param pos Position in global coordinates
* @param exp_center Explosion center in global coordinates
* @param hull_flag Whether this debris is a chunk of a ship's hull (as opposed to shrapnel)
* @param exp_force Explosion force, used to assign velocity to pieces. 1.0f assigns velocity like before. 2.0f assigns twice as much to non-inherited part of velocity
*/
object *debris_create(object *source_obj, int model_num, int submodel_num, vec3d *pos, vec3d *exp_center, int hull_flag, float exp_force)
object *debris_create(object *source_obj, int model_num, int submodel_num, vec3d *pos, vec3d *exp_center, bool hull_flag, float exp_force)
{
int objnum, parent_objnum;
object *obj;
ship *shipp;
debris *db;
polymodel *pm;
int vaporize;
physics_info *pi = NULL;
ship_info *sip = NULL;
int parent_objnum;
object *obj;
ship *shipp;
bool vaporize;
parent_objnum = OBJ_INDEX(source_obj);
Assert( (source_obj->type == OBJ_SHIP ) || (source_obj->type == OBJ_GHOST));
Assert( source_obj->instance >= 0 && source_obj->instance < MAX_SHIPS );
shipp = &Ships[source_obj->instance];
sip = &Ship_info[shipp->ship_info_index];
vaporize = (shipp->flags[Ship::Ship_Flags::Vaporize]);
obj = debris_create_only(parent_objnum, shipp->ship_info_index, shipp->alt_type_index, shipp->team, -1.0f, -1, model_num, submodel_num, pos, nullptr, hull_flag, vaporize, shipp->debris_damage_type_idx);
if (obj != nullptr)
{
debris_create_set_velocity(&Debris[obj->instance], shipp, exp_center, exp_force);
debris_create_fire_hook(obj, source_obj);
}
return obj;
}
object *debris_create_only(int parent_objnum, int parent_ship_class, int alt_type_index, int team, float hull_strength, int spark_timeout, int model_num, int submodel_num, vec3d *pos, matrix *orient, bool hull_flag, bool vaporize, int damage_type_idx)
{
int objnum;
object *obj;
debris *db;
ship_info *sip;
matrix orient_buf;
// try to maintain our soft limit
if (hull_flag && (Num_hull_pieces >= SOFT_LIMIT_DEBRIS_PIECES)) {
// cause oldest hull debris chunk to blow up
@@ -414,10 +434,73 @@ object *debris_create(object *source_obj, int model_num, int submodel_num, vec3d
db = &Debris[n];
// validate or deduce some parameters
if ( pos == nullptr ) {
if (parent_objnum >= 0) {
pos = &Objects[parent_objnum].pos;
} else {
pos = &vmd_zero_vector;
}
}
if ( orient == nullptr ) {
if (parent_objnum >= 0 && hull_flag) {
orient = &Objects[parent_objnum].orient;
} else {
// non-hull debris has no relation to its parent orientation
vec3d rand;
vm_vec_rand_vec(&rand);
vm_vector_2_matrix(&orient_buf, &rand);
orient = &orient_buf;
}
}
sip = (parent_ship_class < 0) ? nullptr : &Ship_info[parent_ship_class];
if (hull_flag && !sip)
{
Warning(LOCATION, "Cannot create hull debris without a ship class!");
return nullptr;
}
if (hull_strength < 0.0f)
{
if (parent_objnum >= 0 && Objects[parent_objnum].type == OBJ_SHIP)
hull_strength = Ships[Objects[parent_objnum].instance].ship_max_hull_strength / 8.0f;
else
hull_strength = 10.0f;
}
if (hull_flag && (model_num < 0 || submodel_num < 0))
{
Warning(LOCATION, "Model and submodel numbers must be specified for hull debris!");
return nullptr;
}
if (team < 0 && hull_flag)
{
if (parent_objnum >= 0 && Objects[parent_objnum].type == OBJ_SHIP)
team = Ships[Objects[parent_objnum].instance].team;
else if (Player_ship)
team = Player_ship->team;
else
team = 0;
}
if (damage_type_idx < 0)
{
if (parent_objnum >= 0 && Objects[parent_objnum].type == OBJ_SHIP)
damage_type_idx = Ships[Objects[parent_objnum].instance].debris_damage_type_idx;
}
// done validation
if (!hull_flag) {
if (model_num >= 0) {
db->model_num = model_num;
db->submodel_num = Random::next(sip->generic_debris_num_submodels);
db->submodel_num = (sip == nullptr || sip->generic_debris_num_submodels <= 0) ? 0 : Random::next(sip->generic_debris_num_submodels);
}
else if (vaporize) {
db->model_num = Debris_vaporize_model;
@@ -447,25 +530,18 @@ object *debris_create(object *source_obj, int model_num, int submodel_num, vec3d
}
}
if(hull_flag && sip->debris_min_lifetime >= 0.0f && sip->debris_max_lifetime >= 0.0f)
{
db->lifeleft = (( sip->debris_max_lifetime - sip->debris_min_lifetime ) * frand()) + sip->debris_min_lifetime;
}
else
{
// Create Debris piece n!
if ( hull_flag ) {
if (Random::next() < (Random::MAX_VALUE/6)) // Make some pieces blow up shortly after explosion.
db->lifeleft = 2.0f * (frand()) + 0.5f;
else {
db->flags.set(Debris_Flags::DoNotExpire);
db->lifeleft = -1.0f; // large hull pieces stay around forever
}
} else {
// small non-hull pieces should stick around longer the larger they are
// sqrtf should make sure its never too crazy long
db->lifeleft = (frand() * 2.0f + 0.1f) * sqrtf(radius);
// Create Debris piece n!
if ( hull_flag ) {
if (Random::next() < (Random::MAX_VALUE/6)) // Make some pieces blow up shortly after explosion.
db->lifeleft = 2.0f * (frand()) + 0.5f;
else {
db->flags.set(Debris_Flags::DoNotExpire);
db->lifeleft = -1.0f; // large hull pieces stay around forever
}
} else {
// small non-hull pieces should stick around longer the larger they are
// sqrtf should make sure its never too crazy long
db->lifeleft = (frand() * 2.0f + 0.1f) * sqrtf(radius);
}
//WMC - Oh noes, we may need to change lifeleft
@@ -494,18 +570,18 @@ object *debris_create(object *source_obj, int model_num, int submodel_num, vec3d
db->flags.set(Debris_Flags::Used);
db->is_hull = hull_flag;
db->source_objnum = parent_objnum;
db->damage_type_idx = shipp->debris_damage_type_idx;
db->ship_info_index = shipp->ship_info_index;
db->team = shipp->team;
db->ambient_sound = sip->debris_ambient_sound;
db->fire_timeout = 0; // if not changed, timestamp_elapsed() will return false
db->damage_type_idx = damage_type_idx;
db->ship_info_index = parent_ship_class;
db->team = team;
db->ambient_sound = (sip == nullptr) ? gamesnd_id(-1) : sip->debris_ambient_sound;
db->fire_timeout = TIMESTAMP::never(); // if not changed, timestamp_elapsed() will return false
db->time_started = Missiontime;
db->species = Ship_info[shipp->ship_info_index].species;
db->parent_alt_name = shipp->alt_type_index;
db->species = (sip == nullptr) ? -1 : sip->species;
db->parent_alt_name = alt_type_index;
db->damage_mult = 1.0f;
for (int i=0; i<MAX_DEBRIS_ARCS; ++i) { // NOLINT
db->arc_timestamp[i] = timestamp(-1);
db->arc_timestamp[i] = TIMESTAMP::invalid();
}
if ( db->is_hull ) {
@@ -519,36 +595,23 @@ object *debris_create(object *source_obj, int model_num, int submodel_num, vec3d
db->arc_frequency = 0;
}
db->next_fireball = timestamp_rand(500,2000); //start one 1/2 - 2 secs later
db->next_fireball = _timestamp_rand(500,2000); //start one 1/2 - 2 secs later
if ( pos == nullptr )
pos = &source_obj->pos;
flagset<Object::Object_Flags> default_flags;
default_flags.set(Object::Object_Flags::Renders);
default_flags.set(Object::Object_Flags::Physics);
default_flags.set(Object::Object_Flags::Collides, hull_flag != 0);
flagset<Object::Object_Flags> default_flags;
default_flags.set(Object::Object_Flags::Renders);
default_flags.set(Object::Object_Flags::Physics);
default_flags.set(Object::Object_Flags::Collides, hull_flag != 0);
matrix orient = source_obj->orient;
if (!db->is_hull) {
// non-hull debris has no relation to its parent orientation
vec3d rand;
vm_vec_rand_vec(&rand);
vm_vector_2_matrix(&orient, &rand);
}
objnum = obj_create(OBJ_DEBRIS, parent_objnum, n, &orient, pos, radius, default_flags, false);
objnum = obj_create(OBJ_DEBRIS, parent_objnum, n, orient, pos, radius, default_flags, false);
if ( objnum == -1 ) {
mprintf(("Couldn't create debris object -- out of object slots\n"));
return nullptr;
}
db->objnum = objnum;
obj = &Objects[objnum];
pi = &obj->phys_info;
db->model_instance_num = model_create_instance(objnum, db->model_num);
db->model_instance_num = hull_flag ? model_create_instance(objnum, db->model_num) : -1;
// assign the network signature. The signature will be 0 for non-hull pieces, but since that
// is our invalid signature, it should be okay.
@@ -558,10 +621,7 @@ object *debris_create(object *source_obj, int model_num, int submodel_num, vec3d
obj->net_signature = multi_get_next_network_signature( MULTI_SIG_DEBRIS );
}
if (source_obj->type == OBJ_SHIP) {
obj->hull_strength = Ships[source_obj->instance].ship_max_hull_strength/8.0f;
} else
obj->hull_strength = 10.0f;
obj->hull_strength = hull_strength;
if (hull_flag) {
if(sip->debris_min_hitpoints >= 0.0f && sip->debris_max_hitpoints >= 0.0f)
@@ -579,40 +639,58 @@ object *debris_create(object *source_obj, int model_num, int submodel_num, vec3d
obj->hull_strength = sip->debris_max_hitpoints;
}
db->damage_mult = sip->debris_damage_mult;
db->sound_delay = _timestamp(DEBRIS_SOUND_DELAY);
// limit the amount of time that fireballs appear
// let fireball length be linked to radius of ship. Range is .33 radius => 3.33 radius seconds.
if (spark_timeout >= 0) {
db->fire_timeout = _timestamp(spark_timeout);
} else if (parent_objnum >= 0) {
float t = 1000*Objects[parent_objnum].radius/3 + Random::next(fl2i(1000*3*Objects[parent_objnum].radius));
db->fire_timeout = _timestamp(fl2i(t)); // fireballs last from 5 - 30 seconds
} else {
db->fire_timeout = TIMESTAMP::immediate();
}
if (parent_objnum >= 0 && Objects[parent_objnum].radius >= MIN_RADIUS_FOR_PERSISTENT_DEBRIS) {
db->flags.set(Debris_Flags::DoNotExpire);
} else {
debris_add_to_hull_list(db);
}
}
if (hull_flag) {
MONITOR_INC(NumHullDebris,1);
} else {
MONITOR_INC(NumSmallDebris,1);
}
return obj;
}
void debris_create_set_velocity(debris *db, ship *source_shipp, vec3d *exp_center, float exp_force)
{
auto obj = &Objects[db->objnum];
auto source_obj = (source_shipp == nullptr) ? nullptr : &Objects[source_shipp->objnum];
physics_info *pi = &obj->phys_info;
vec3d rotvel, radial_vel, to_center;
if ( exp_center )
vm_vec_sub( &to_center,pos, exp_center );
vm_vec_sub( &to_center, &obj->pos, exp_center );
else
vm_vec_zero(&to_center);
float scale;
if ( hull_flag ) {
float t;
if ( db->is_hull ) {
scale = exp_force * i2fl(Random::next(10, 29)); // for radial_vel away from location of blast center
db->sound_delay = timestamp(DEBRIS_SOUND_DELAY);
// set up physics mass and I_inv for hull debris pieces
pm = model_get(model_num);
auto pm = model_get(db->model_num);
vec3d *min, *max;
min = &pm->submodel[submodel_num].min;
max = &pm->submodel[submodel_num].max;
min = &pm->submodel[db->submodel_num].min;
max = &pm->submodel[db->submodel_num].max;
calc_debris_physics_properties( &obj->phys_info, min, max );
// limit the amount of time that fireballs appear
// let fireball length be linked to radius of ship. Range is .33 radius => 3.33 radius seconds.
t = 1000*Objects[db->source_objnum].radius/3 + Random::next(fl2i(1000*3*Objects[db->source_objnum].radius));
db->fire_timeout = timestamp(fl2i(t)); // fireballs last from 5 - 30 seconds
if ( Objects[db->source_objnum].radius < MIN_RADIUS_FOR_PERSISTANT_DEBRIS ) {
debris_add_to_hull_list(db);
} else {
db->flags.set(Debris_Flags::DoNotExpire);
nprintf(("Alan","A forever chunk of debris was created from ship with radius %f\n",Objects[db->source_objnum].radius));
}
}
else {
scale = exp_force * i2fl(Random::next(10, 29)); // for radial_vel away from blast center (non-hull)
@@ -627,15 +705,21 @@ object *debris_create(object *source_obj, int model_num, int submodel_num, vec3d
vm_vec_copy_scale(&radial_vel, &to_center, scale );
}
// DA: here we need to vel_from_rot = w x to_center, where w is world is unrotated to world coords and offset is the
// displacement fromt the center of the parent object to the center of the debris piece
vec3d world_rotvel, vel_from_rotvel;
vm_vec_unrotate ( &world_rotvel, &source_obj->phys_info.rotvel, &source_obj->orient );
vm_vec_cross ( &vel_from_rotvel, &world_rotvel, &to_center );
vm_vec_scale ( &vel_from_rotvel, DEBRIS_ROTVEL_SCALE);
if (source_obj)
{
// DA: here we need to vel_from_rot = w x to_center, where w is world is unrotated to world coords and offset is the
// displacement fromt the center of the parent object to the center of the debris piece
vec3d world_rotvel, vel_from_rotvel;
vm_vec_unrotate ( &world_rotvel, &source_obj->phys_info.rotvel, &source_obj->orient );
vm_vec_cross ( &vel_from_rotvel, &world_rotvel, &to_center );
vm_vec_scale ( &vel_from_rotvel, DEBRIS_ROTVEL_SCALE);
vm_vec_add (&obj->phys_info.vel, &radial_vel, &source_obj->phys_info.vel);
vm_vec_add2(&obj->phys_info.vel, &vel_from_rotvel);
vm_vec_add (&obj->phys_info.vel, &radial_vel, &source_obj->phys_info.vel);
vm_vec_add2(&obj->phys_info.vel, &vel_from_rotvel);
}
float radius = submodel_get_radius(db->model_num, db->submodel_num);
// make sure rotational velocity does not get too high
if (radius < 1.0) {
@@ -647,40 +731,42 @@ object *debris_create(object *source_obj, int model_num, int submodel_num, vec3d
vm_vec_rand_vec_quick(&rotvel);
vm_vec_scale(&rotvel, scale);
pi->flags |= PF_DEAD_DAMP;
pi->rotvel = rotvel;
pi->flags |= (PF_DEAD_DAMP | PF_BALLISTIC);
check_rotvel_limit( &obj->phys_info );
// check that debris is not created with too high a velocity
if (hull_flag)
if (db->is_hull)
{
shipfx_debris_limit_speed(db, shipp);
shipfx_debris_limit_speed(db, source_shipp);
}
// blow out his reverse thrusters. Or drag, same thing.
pi->rotdamp = 10000.0f;
pi->side_slip_time_const = 10000.0f;
pi->flags |= (PF_REDUCED_DAMP | PF_DEAD_DAMP); // set damping equal for all axis and not changable
if (source_shipp != nullptr) {
pi->gravity_const = Ship_info[source_shipp->ship_info_index].debris_gravity_const;
} else {
pi->gravity_const = 1.0f;
}
vm_vec_zero(&pi->max_vel); // make so he can't turn on his own VOLITION anymore.
vm_vec_zero(&pi->max_rotvel); // make so he can't change speed on his own VOLITION anymore.
// ensure vel is valid
Assert( !vm_is_vec_nan(&obj->phys_info.vel) );
}
if (OnDebrisCreatedHook->isActive()) {
OnDebrisCreatedHook->run(scripting::hook_param_list(
scripting::hook_param("Debris", 'o', obj),
scripting::hook_param("Source", 'o', source_obj)));
void debris_create_fire_hook(object *obj, object *source_obj)
{
if (scripting::hooks::OnDebrisCreated->isActive()) {
scripting::hooks::ShipSourceConditions conditions;
conditions.source_shipp = (source_obj != nullptr && source_obj->type == OBJ_SHIP) ? &Ships[source_obj->instance] : nullptr;
scripting::hooks::OnDebrisCreated->run(std::move(conditions),
scripting::hook_param_list(
scripting::hook_param("Debris", 'o', obj),
scripting::hook_param("Source", 'o', source_obj)));
}
if (db->is_hull) {
MONITOR_INC(NumHullDebris,1);
} else {
MONITOR_INC(NumSmallDebris,1);
}
return obj;
}
/**
@@ -730,7 +816,7 @@ void debris_hit(object *debris_obj, object * /*other_obj*/, vec3d *hitpos, float
debris_obj->hull_strength -= damage;
if (debris_obj->hull_strength < 0.0f) {
debris_start_death_roll(debris_obj, debris_p );
debris_start_death_roll(debris_obj, debris_p, hitpos);
} else {
// otherwise, give all the other players an update on the debris
if(MULTIPLAYER_MASTER){
@@ -1071,11 +1157,8 @@ void debris_render(object * obj, model_draw_list *scene)
texture_info *tbase = nullptr;
auto pmi = model_get_instance(db->model_instance_num);
auto pm = model_get(pmi->model_num);
auto pm = model_get(db->model_num);
model_clear_instance( db->model_num );
model_instance_clear_arcs(pm, pmi);
// Swap in a different texture depending on the species
if (db->species >= 0)
@@ -1088,11 +1171,18 @@ void debris_render(object * obj, model_draw_list *scene)
}
}
// Only render electrical arcs if within 500m of the eye (for a 10m piece)
if ( vm_vec_dist_quick( &obj->pos, &Eye_position ) < obj->radius*50.0f ) {
for (i=0; i<MAX_DEBRIS_ARCS; i++ ) {
if ( timestamp_valid( db->arc_timestamp[i] ) ) {
model_instance_add_arc( pm, pmi, db->submodel_num, &db->arc_pts[i][0], &db->arc_pts[i][1], MARC_TYPE_DAMAGED );
polymodel_instance *pmi = nullptr;
if (db->model_instance_num >= 0)
{
pmi = model_get_instance(db->model_instance_num);
model_instance_clear_arcs(pm, pmi);
// Only render electrical arcs if within 500m of the eye (for a 10m piece)
if ( vm_vec_dist_quick( &obj->pos, &Eye_position ) < obj->radius*50.0f ) {
for (i=0; i<MAX_DEBRIS_ARCS; i++ ) {
if ( db->arc_timestamp[i].isValid() ) {
model_instance_add_arc( pm, pmi, db->submodel_num, &db->arc_pts[i][0], &db->arc_pts[i][1], MARC_TYPE_DAMAGED );
}
}
}
}
+18 -6
View File
@@ -43,15 +43,15 @@ typedef struct debris {
int model_num; // What model this uses
int model_instance_num; // What model instance this uses - needed for arcs
int submodel_num; // What submodel this uses
int next_fireball; // When to start a fireball
int is_hull; // indicates whether this is a collideable, destructable piece of debris from the model, or just a generic debris fragment
TIMESTAMP next_fireball; // When to start a fireball
bool is_hull; // indicates whether this is a collideable, destructable piece of debris from the model, or just a generic debris fragment
int species; // What species this is from. -1 if don't care.
int fire_timeout; // timestamp that holds time for fireballs to stop appearing
int sound_delay; // timestamp to signal when sound should start
TIMESTAMP fire_timeout; // timestamp that holds time for fireballs to stop appearing
TIMESTAMP sound_delay; // timestamp to signal when sound should start
fix time_started; // time when debris was created
vec3d arc_pts[MAX_DEBRIS_ARCS][2]; // The endpoints of each arc
int arc_timestamp[MAX_DEBRIS_ARCS]; // When this times out, the spark goes away. -1 is not used
TIMESTAMP arc_timestamp[MAX_DEBRIS_ARCS]; // When this times out, the spark goes away. Invalid is not used
int arc_frequency; // Starts at 1000, gets bigger
int parent_alt_name;
@@ -69,7 +69,19 @@ void debris_init();
void debris_render(object * obj, model_draw_list *scene);
void debris_delete( object * obj );
void debris_process_post( object * obj, float frame_time);
object *debris_create( object * source_obj, int model_num, int submodel_num, vec3d *pos, vec3d *exp_center, int hull_flag, float exp_force );
// Create debris, set velocity, and fire scripting hook
object *debris_create( object *source_obj, int model_num, int submodel_num, vec3d *pos, vec3d *exp_center, bool hull_flag, float exp_force );
// Create debris but don't do anything else
object *debris_create_only(int parent_objnum, int parent_ship_class, int alt_type_index, int team, float hull_strength, int spark_timeout, int model_num, int submodel_num, vec3d *pos, matrix *orient, bool hull_flag, bool vaporize, int damage_type_idx);
// Set velocity after debris creation
void debris_create_set_velocity(debris *db, ship *source_shipp, vec3d *exp_center, float exp_force);
// Fire scripting hook after debris creation
void debris_create_fire_hook(object *obj, object *source_obj);
int debris_check_collision( object * obj, object * other_obj, vec3d * hitpos, collision_info_struct *debris_hit_info=NULL, vec3d* hitnormal = NULL );
void debris_hit( object * debris_obj, object * other_obj, vec3d * hitpos, float damage );
int debris_get_team(object *objp);
+37 -25
View File
@@ -161,6 +161,7 @@ SCP_vector<DecalDefinition> DecalDefinitions;
// Variable to indicate if the system is able to work correctly on the current system
bool Decal_system_active = true;
bool Decal_option_active = true;
void parse_decals_table(const char* filename) {
try {
@@ -186,7 +187,7 @@ void parse_decals_table(const char* filename) {
}
if (!gr_is_capable(CAPABILITY_DEFERRED_LIGHTING)) {
// we need deferred lighting
// We need deferred lighting
Decal_system_active = false;
mprintf(("Note: Decal system has been disabled due to lack of deferred lighting.\n"));
}
@@ -196,7 +197,7 @@ void parse_decals_table(const char* filename) {
mprintf(("Note: Decal system has been disabled due to lack of normal mapping.\n"));
}
if (!gr_is_capable(CAPABILITY_SEPARATE_BLEND_FUNCTIONS)) {
// WWe need separate blending functions for different color buffers
// We need separate blending functions for different color buffers
Decal_system_active = false;
mprintf(("Note: Decal system has been disabled due to lack of separate color buffer blend functions.\n"));
}
@@ -327,20 +328,18 @@ void parseDecalReference(creation_info& dest_info, bool is_new_entry) {
SCP_string name;
stuff_string(name, F_NAME);
auto decalRef = findDecalDefinition(name);
// decals are not initialized in FRED, so no decal definitions are known
if (!Fred_running) {
auto decalRef = findDecalDefinition(name);
if (decalRef < 0) {
error_display(0, "Decal definition '%s' is unknown!", name.c_str());
if (decalRef < 0) {
error_display(0, "Decal definition '%s' is unknown!", name.c_str());
}
dest_info.definition_handle = decalRef;
}
dest_info.definition_handle = decalRef;
if (required_string_if_new("+Radius:", is_new_entry)) {
stuff_float(&dest_info.radius);
if (dest_info.radius <= 0.0f) {
error_display(0, "Invalid radius of %f! Must be a positive number.", dest_info.radius);
dest_info.radius = 1.0f;
}
dest_info.radius = util::parseUniformRange(0.0001f);
}
if (required_string_if_new("+Lifetime:", is_new_entry)) {
@@ -351,10 +350,14 @@ void parseDecalReference(creation_info& dest_info, bool is_new_entry) {
dest_info.lifetime = util::parseUniformRange(0.0001f);
}
}
if (optional_string("+Use Random Rotation:")) {
stuff_boolean(&dest_info.random_rotation);
}
}
void loadBitmaps(const creation_info& info) {
if (!Decal_system_active) {
if (!Decal_system_active || !Decal_option_active) {
return;
}
// Silently ignore invalid definition handle since weapons use the default values if the decal option is not present
@@ -371,7 +374,7 @@ void loadBitmaps(const creation_info& info) {
}
void pageInDecal(const creation_info& info) {
if (!Decal_system_active) {
if (!Decal_system_active || !Decal_option_active) {
return;
}
// Silently ignore invalid definition handle since weapons use the default values if the decal option is not present
@@ -413,9 +416,12 @@ matrix4 getDecalTransform(Decal& decal) {
// this will lead to a situation where we would look at the decal texture "from behind" causing the texture to
// appear flipped. We fix that here for the graphics transform by inverting the Z scaling.
// ALSO for some reason the uvec needs to be flipped as well, otherwise the decals render upside-down. Without
// being sure of the root cause, this at least makes it appear correct for modders.
// Apply scaling
vm_vec_scale(&worldOrient.vec.rvec, decal.scale.xyz.x);
vm_vec_scale(&worldOrient.vec.uvec, decal.scale.xyz.y);
vm_vec_scale(&worldOrient.vec.uvec, -decal.scale.xyz.y);
vm_vec_scale(&worldOrient.vec.fvec, -decal.scale.xyz.z);
matrix4 mat4;
@@ -425,12 +431,12 @@ matrix4 getDecalTransform(Decal& decal) {
}
void renderAll() {
if (!Decal_system_active) {
if (!Decal_system_active || !Decal_option_active) {
return;
}
// Clear out any invalid decals
for (auto iter = active_decals.begin(); iter != active_decals.end(); ++iter) {
for (auto iter = active_decals.begin(); iter != active_decals.end();) {
if (!iter->isValid()) {
// if we're sitting on the very last element, popping-back will invalidate the iterator!
if (iter + 1 == active_decals.end()) {
@@ -442,6 +448,10 @@ void renderAll() {
active_decals.pop_back();
continue;
}
// next decal, only increment the iterator if we found a valid value so nothing gets skipped
// otherwise we may skip a decal which can then get through to the draw_list loop while being invalid
++iter;
}
if (active_decals.empty()) {
@@ -452,14 +462,15 @@ void renderAll() {
graphics::decal_draw_list draw_list(active_decals.size());
for (auto& decal : active_decals) {
Assertion(decal.definition_handle >= 0 && decal.definition_handle < (int)DecalDefinitions.size(),
"Invalid decal handle detected!");
auto& decalDef = DecalDefinitions[decal.definition_handle];
int diffuse_bm = -1;
int glow_bm = -1;
int normal_bm = -1;
Assertion(decal.definition_handle >= 0 && decal.definition_handle < (int) DecalDefinitions.size(),
"Invalid decal handle detected!");
auto& decalDef = DecalDefinitions[decal.definition_handle];
auto decal_time = mission_time - decal.creation_time;
auto progress = decal_time / decal.lifetime;
@@ -491,7 +502,7 @@ void renderAll() {
}
void addDecal(creation_info& info, object* host, int submodel, const vec3d& local_pos, const matrix& local_orient) {
if (!Decal_system_active) {
if (!Decal_system_active || !Decal_option_active) {
return;
}
// Silently ignore invalid definition handle since weapons use the default values if the decal option is not present
@@ -519,9 +530,10 @@ void addDecal(creation_info& info, object* host, int submodel, const vec3d& loca
newDecal.position = local_pos;
newDecal.orientation = local_orient;
if (info.width < 0.0f || info.height < 0.0f) {
newDecal.scale.xyz.x = info.radius;
newDecal.scale.xyz.y = info.radius;
newDecal.scale.xyz.z = info.radius;
float radius = info.radius.next();
newDecal.scale.xyz.x = radius;
newDecal.scale.xyz.y = radius;
newDecal.scale.xyz.z = radius;
} else {
newDecal.scale.xyz.x = info.width;
newDecal.scale.xyz.y = info.height;
+3 -1
View File
@@ -52,6 +52,7 @@ class DecalDefinition {
extern SCP_vector<DecalDefinition> DecalDefinitions;
extern bool Decal_system_active;
extern bool Decal_option_active;
/**
@@ -64,10 +65,11 @@ typedef int DecalReference;
*/
struct creation_info {
DecalReference definition_handle = -1;
float radius = -1.0f;
util::UniformFloatRange radius = ::util::UniformFloatRange(-1.0f);
float width = -1.0f;
float height = -1.0f;
util::UniformFloatRange lifetime = ::util::UniformFloatRange(-1.0f);
bool random_rotation = false;
};
/**
+2 -2
View File
@@ -118,7 +118,7 @@ void main() {
vec3 normal = getPixelNormal(frag_position, gl_FragCoord.xy, alpha, binormal, tangent);
vec4 diffuse_out = vec4(0.0);
vec4 emissive_out = vec4(0.0, 0.0, 0.0, 0.0);
vec4 emissive_out = vec4(0.0);
vec3 normal_out = vec3(0.0);
if (diffuse_index >= 0) {
@@ -147,7 +147,7 @@ void main() {
}
if (glow_index >= 0) {
// We have a valid diffuse map
// We have a valid glow map
vec4 color = texture(glowMap, vec3(tex_coord, float(glow_index)));
color.rgb = srgb_to_linear(color.rgb) * GLOW_MAP_SRGB_MULTIPLIER;
+94 -35
View File
@@ -1,7 +1,7 @@
//? #version 150
#include "lighting.sdr" //! #include "lighting.sdr"
#include "lighting.sdr"
#include "shadows.sdr"
#include "shadows.sdr" //! #include "shadows.sdr"
in vec3 beamVec;
in vec3 lightPosition;
@@ -32,7 +32,7 @@ layout (std140) uniform lightData {
vec3 diffuseLightColor;
float coneAngle;
vec3 specLightColor;
vec3 lightDir;
float coneInnerAngle;
vec3 coneDir;
@@ -41,49 +41,105 @@ layout (std140) uniform lightData {
vec3 scale;
float lightRadius;
vec3 lightDir;
int lightType;
bool enable_shadows;
float sourceRadius;
};
void GetLightInfo(vec3 position, out vec3 lightDir, out float attenuation)
// Nearest point sphere and tube light calculations taken from
// "Real Shading in Unreal Engine 4" by Brian Karis, Epic Games
// Part of SIGGRAPH 2013 Course: Physically Based Shading in Theory and Practice
vec3 ExpandLightSize(in vec3 lightDir, in vec3 reflectDir) {
// There's an extra max(...,sourceRadius) call here vs the version in the paper.
// This prevents the centerToRay calculation from choosing a point behind
// the reflection ray's origin (i.e. underneath the surface).
// this is necessary for situations where the fragment being shaded lies inside
// the sourceRadius of the light.
// Instead, we choose a point suffciently far away from the reflection origin (hence max(...,sourceRadius))
// so that we have a gradual transition as the shaded fragments along the surface
// shift from being inside to outside the light.
vec3 centerToRay = max(dot(lightDir, reflectDir),sourceRadius) * reflectDir - lightDir;
return lightDir + centerToRay * clamp(sourceRadius/length(centerToRay), 0.0, 1.0);
}
void GetLightInfo(vec3 position, in float alpha, in vec3 reflectDir, out vec3 lightDir, out float attenuation, out float area_normalisation)
{
if (lightType == LT_DIRECTIONAL) {
lightDir = normalize(lightPosition);
attenuation = 1.0;
area_normalisation = 1.0;
} else {
// Positional light source
lightDir = lightPosition - position.xyz;
float dist = length(lightDir);
attenuation = 1.0 - clamp(sqrt(dist / lightRadius), 0.0, 1.0);
if (lightType == LT_POINT) {
lightDir = lightPosition - position.xyz;
float dist = length(lightDir);
if(dist > lightRadius && lightType != LT_TUBE) {
discard;
}
if (lightType == LT_TUBE) { // Tube light
float beamLength = length(beamVec);
vec3 beamDir = beamVec / beamLength;
//The actual 'lighting element' is shorter than the light volume cylinder
//To compensate the light is moved forward along the beam one radius and the length shortened
//this allows room for clean falloff of the light past the ends of beams.
vec3 adjustedLightPos = lightPosition - (beamDir * lightRadius);
beamLength = beamLength - (lightRadius * 2.0);
//adjustments having been made, lightdir needs recalculating
lightDir = adjustedLightPos - position.xyz;
// Get nearest point on line
float neardist = clamp(dot(lightDir, beamDir), 0.0, beamLength);
// Move back from the endpoint of the beam along the beam by the distance we calculated
vec3 nearest = adjustedLightPos - beamDir * neardist;
lightDir = nearest - position.xyz;
// this chunk is unneccessary if sourceRadius= 0.0, but let's avoid a branch.
// given a sphere of radius sourceRadius centered at lightDir,
// move lightDir towards the ray defined by reflectDir
lightDir = ExpandLightSize(lightDir, reflectDir);
dist = length(lightDir);
// Energy conservation term
float alpha_adjust = clamp(alpha + (sourceRadius/(2*dist)), 0.0, 1.0);
area_normalisation = alpha/alpha_adjust;
area_normalisation *= area_normalisation;
//end chunk
if(dist > lightRadius) {
discard;
}
attenuation = 1.0 - clamp(sqrt(dist / lightRadius), 0.0, 1.0);
} else if (lightType == LT_CONE) {
}
else if (lightType == LT_TUBE) { // Tube light
vec3 beamDir = normalize(beamVec);
//The actual 'lighting element' is shorter than the light volume cylinder
//To compensate the light is moved forward along the beam one radius and the length shortened
//this allows room for clean falloff of the light past the ends of beams.
vec3 adjustedLightPos = lightPosition - (beamDir * lightRadius);
vec3 adjustedbeamVec = beamVec - 2.0 * lightRadius * beamDir;
float beamLength = length(adjustedbeamVec);
//adjustments having been made, sourceDir needs recalculating
vec3 sourceDir = adjustedLightPos - position.xyz;
// Get point on beam nearest to the reflection ray.
vec3 a_t = reflectDir;
vec3 b_t = beamDir;
vec3 b_0 = sourceDir;
vec3 c = cross(a_t, b_t);
vec3 d = b_0;
vec3 r = d - a_t * dot(d, a_t) - c * dot(d,c);
float neardist = dot(r, r)/dot(b_t, r);
// Move along the beam by the distance we calculated
lightDir = sourceDir - beamDir * clamp(neardist, 0.0, beamLength);
// Somebody with a symbolic expression simplifier or a wrinklier brain than me
// should figure out how to optimise these calcs - qaz
// this chunk is unneccessary if sourceRadius = 0.0, but let's avoid a branch.
// Same principle as in LT_POINT, treat chosen location as a spherelight.
lightDir = ExpandLightSize(lightDir, reflectDir);
float dist = length(lightDir);
// Energy conservation term
float alpha_adjust = min(alpha + (sourceRadius/(2*dist)), 1.0);
area_normalisation = alpha/alpha_adjust;
// don't need to square as it's a line rather than a sphere.
//end chunk
if(dist > lightRadius) {
discard;
}
attenuation = 1.0 - clamp(sqrt(dist / lightRadius), 0.0, 1.0);
}
else if (lightType == LT_CONE) {
lightDir = lightPosition - position.xyz;
float coneDot = dot(normalize(-lightDir), coneDir);
float dist = length(lightDir);
attenuation = 1.0 - clamp(sqrt(dist / lightRadius), 0.0, 1.0);
area_normalisation = 1.0;
if(dualCone) {
if(abs(coneDot) < coneAngle) {
discard;
@@ -111,19 +167,22 @@ void main()
if(abs(dot(position, position)) < 0.1)
discard;
vec3 color = texture(ColorBuffer, screenPos).rgb;
vec3 diffColor = texture(ColorBuffer, screenPos).rgb;
vec4 normalData = texture(NormalBuffer, screenPos);
vec4 specColor = texture(SpecBuffer, screenPos);
// The vector in the normal buffer could be longer than the unit vector since decal rendering only adds to the normal buffer
vec3 normal = normalize(normalData.xyz);
float gloss = normalData.a;
float roughness = clamp(1.0f - gloss, 0.0f, 1.0f);
float alpha = roughness * roughness;
float fresnel = specColor.a;
vec3 eyeDir = normalize(-position);
vec3 lightDir;
float attenuation;
GetLightInfo(position, lightDir, attenuation);
float area_normalisation;
vec3 reflectDir = reflect(-eyeDir, normal);
GetLightInfo(position, alpha, reflectDir, lightDir, attenuation, area_normalisation);
if (enable_shadows) {
vec4 fragShadowPos = shadow_mv_matrix * inv_view_matrix * vec4(position, 1.0);
@@ -139,7 +198,7 @@ void main()
vec3 halfVec = normalize(lightDir + eyeDir);
float NdotL = clamp(dot(normal, lightDir), 0.0, 1.0);
vec4 fragmentColor = vec4(color * (diffuseLightColor * NdotL * attenuation), 1.0);
fragmentColor.rgb += computeLighting(specColor.rgb, lightDir, normal.xyz, halfVec, eyeDir, gloss, fresnel, NdotL).rgb * specLightColor * attenuation;
vec4 fragmentColor = vec4(1.0);
fragmentColor.rgb = computeLighting(specColor.rgb, diffColor, lightDir, normal.xyz, halfVec, eyeDir, roughness, fresnel, NdotL).rgb * diffuseLightColor * attenuation * area_normalisation;
fragOut0 = max(fragmentColor, vec4(0.0));
}
+3 -3
View File
@@ -12,7 +12,7 @@ layout (std140) uniform lightData {
vec3 diffuseLightColor;
float coneAngle;
vec3 specLightColor;
vec3 lightDir;
float coneInnerAngle;
vec3 coneDir;
@@ -21,10 +21,10 @@ layout (std140) uniform lightData {
vec3 scale;
float lightRadius;
vec3 lightDir;
int lightType;
bool enable_shadows;
float sourceRadius;
};
out vec3 lightPosition;
+185
View File
@@ -0,0 +1,185 @@
//!#version 150
#include "gamma.sdr" //! #include "gamma.sdr"
#define PI 3.1415926535897932384626433832795
uniform samplerCube envmap;
layout (std140) uniform genericData {
int face;
};
in vec4 fragTexCoord;
out vec4 fragOut0;
// Iteratively optimised points to give low discrepancy distribution on arbritrary hemisphere.
const vec3 points[128] = vec3[128](
vec3(-0.2268, 0.6185, 0.7523),
vec3( 0.9958, -0.0871, -0.0277),
vec3( 0.7132, -0.6099, 0.3455),
vec3(-0.9243, -0.3644, 0.1137),
vec3( 0.4580, -0.3977, -0.7950),
vec3(-0.2989, -0.7422, -0.5998),
vec3(-0.7263, -0.5965, 0.3416),
vec3(-0.7906, 0.4955, 0.3597),
vec3(-0.5006, -0.5116, 0.6984),
vec3( 0.3924, 0.8514, 0.3479),
vec3(-0.5916, -0.8009, 0.0925),
vec3( 0.5076, 0.2359, -0.8287),
vec3(-0.6712, 0.5976, -0.4386),
vec3( 0.5255, -0.5998, -0.6034),
vec3( 0.2083, 0.7588, -0.6172),
vec3( 0.8282, 0.0486, 0.5584),
vec3( 0.2563, -0.6217, -0.7401),
vec3(-0.4601, 0.2289, -0.8579),
vec3( 0.6840, 0.5803, -0.4421),
vec3(-0.0167, 0.9512, -0.3080),
vec3( 0.2259, 0.3423, 0.9120),
vec3( 0.3726, -0.7409, 0.5587),
vec3( 0.0440, -0.4696, 0.8818),
vec3(-0.5011, -0.6169, -0.6069),
vec3( 0.2801, 0.8534, 0.4396),
vec3(-0.2464, -0.9090, 0.3360),
vec3(-0.7297, 0.1734, 0.6614),
vec3(-0.2619, 0.2954, 0.9188),
vec3( 0.1519, -0.5555, -0.8176),
vec3(-0.6161, -0.7542, 0.2274),
vec3( 0.3067, -0.8999, -0.3100),
vec3( 0.4223, -0.6110, 0.6696),
vec3(-0.7079, 0.5325, 0.4640),
vec3( 0.9522, -0.3022, 0.0443),
vec3(-0.3054, -0.5260, -0.7937),
vec3(-0.7502, 0.1605, -0.6414),
vec3( 0.9070, -0.0741, -0.4145),
vec3(-0.1592, 0.8002, -0.5783),
vec3( 0.7672, 0.4286, 0.4772),
vec3(-0.9340, 0.2468, -0.2584),
vec3( 0.9905, -0.1254, 0.0563),
vec3(-0.7776, -0.4144, -0.4729),
vec3(-0.7503, 0.6316, -0.1952),
vec3(-0.3313, -0.2916, -0.8973),
vec3( 0.1147, -0.7738, 0.6230),
vec3( 0.1481, 0.3008, -0.9421),
vec3(-0.8300, 0.0980, 0.5491),
vec3(-0.1374, 0.9904, 0.0163),
vec3( 0.0996, -0.9950, -0.0014),
vec3( 0.7040, 0.0177, -0.7100),
vec3(-0.3455, 0.8607, -0.3740),
vec3(-0.6005, 0.2897, 0.7453),
vec3( 0.3546, -0.8403, -0.4100),
vec3(-0.5317, 0.5463, -0.6472),
vec3( 0.4780, -0.1825, -0.8592),
vec3( 0.3033, -0.1953, 0.9327),
vec3(-0.8416, -0.1018, -0.5304),
vec3( 0.2834, -0.6792, -0.6771),
vec3( 0.9488, 0.1900, -0.2522),
vec3( 0.3215, 0.7569, -0.5690),
vec3(-0.7391, 0.5883, -0.3281),
vec3( 0.4351, -0.2649, 0.8605),
vec3( 0.0829, -0.8264, 0.5570),
vec3(-0.6900, 0.5097, 0.5139),
vec3( 0.6869, -0.5626, 0.4601),
vec3(-0.9385, -0.1405, -0.3153),
vec3(-0.2377, 0.7921, 0.5622),
vec3( 0.3259, -0.1633, -0.9312),
vec3( 0.4753, 0.8652, -0.1597),
vec3( 0.9267, 0.0849, -0.3661),
vec3(-0.8777, -0.4241, -0.2231),
vec3( 0.5195, -0.8463, -0.1177),
vec3(-0.2962, -0.5401, 0.7878),
vec3( 0.9439, 0.3300, -0.0130),
vec3(-0.9481, 0.2886, 0.1333),
vec3(-0.0272, -0.5312, 0.8468),
vec3(-0.3538, 0.6180, -0.7021),
vec3(-0.9996, 0.0160, -0.0217),
vec3( 0.2800, -0.3399, 0.8978),
vec3( 0.2090, 0.9773, 0.0338),
vec3( 0.5249, 0.0450, 0.8500),
vec3( 0.8165, 0.3275, -0.4755),
vec3( 0.1568, -0.6439, -0.7489),
vec3( 0.3034, 0.6192, -0.7243),
vec3(-0.7233, -0.6519, -0.2278),
vec3(-0.8259, -0.4757, 0.3027),
vec3( 0.2690, -0.7823, 0.5618),
vec3( 0.3309, 0.4864, -0.8087),
vec3(-0.3891, 0.4036, 0.8281),
vec3(-0.0919, 0.1208, 0.9884),
vec3(-0.2482, -0.5348, 0.8077),
vec3( 0.8195, 0.3333, 0.4661),
vec3( 0.7890, -0.6104, 0.0702),
vec3(-0.4653, 0.8046, 0.3688),
vec3(-0.0413, -0.2247, -0.9736),
vec3( 0.1926, 0.2839, -0.9393),
vec3( 0.9205, -0.2443, -0.3048),
vec3(-0.4891, 0.8229, 0.2891),
vec3(-0.9010, -0.4189, -0.1128),
vec3( 0.0706, 0.2715, 0.9598),
vec3(-0.2682, 0.4639, -0.8443),
vec3(-0.6389, -0.0442, 0.7680),
vec3(-0.2588, 0.9613, -0.0949),
vec3( 0.5469, -0.4194, 0.7246),
vec3( 0.8399, 0.3814, 0.3860),
vec3( 0.8060, -0.3544, -0.4741),
vec3(-0.7109, -0.4466, 0.5432),
vec3(-0.2986, -0.9381, -0.1753),
vec3( 0.3983, -0.3642, -0.8418),
vec3( 0.4518, 0.8744, 0.1770),
vec3( 0.8792, -0.4098, 0.2432),
vec3(-0.7904, 0.6106, -0.0494),
vec3( 0.1667, -0.2852, -0.9438),
vec3( 0.5566, 0.6694, 0.4920),
vec3( 0.1761, 0.9638, 0.2000),
vec3( 0.6951, 0.7188, 0.0090),
vec3(-0.2659, -0.0544, 0.9625),
vec3(-0.0370, 0.6667, 0.7444),
vec3( 0.1119, -0.5816, 0.8058),
vec3(-0.1706, -0.9310, -0.3226),
vec3( 0.5573, -0.8143, 0.1624),
vec3( 0.3899, -0.9183, 0.0682),
vec3(-0.2921, -0.7937, 0.5336),
vec3( 0.8488, 0.4895, 0.1997),
vec3(-0.6887, 0.1527, 0.7088),
vec3(-0.3092, 0.0011, -0.9510),
vec3( 0.3066, 0.6124, 0.7287),
vec3( 0.7305, 0.6698, 0.1333)
);
void main() {
float xpos = 2 * gl_FragCoord.x/16 - 1; // remap to (-1, 1)
float ypos = 2 * gl_FragCoord.y/16 - 1;
vec3 fragDir;
vec4 fragCol = vec4(0.0);
switch (face) {
case 0: // +X
fragDir = vec3(1.0, -ypos, -xpos);
break;
case 1: // -X
fragDir = vec3(-1.0, -ypos, xpos);
break;
case 2: // +Y
fragDir = vec3(xpos, 1.0, ypos);
break;
case 3: // -Y
fragDir = vec3(xpos, -1.0, -ypos);
break;
case 4: // +Z
fragDir = vec3(xpos, -ypos, 1.0);
break;
case 5: // -Z
fragDir = vec3(-xpos, -ypos, -1.0);
break;
}
fragDir = normalize(fragDir);
for(int i=0;i<128;++i)
{
// This precalcualted sampling method seems weird, but by having a set of fixed directions
// and mirroring the bad ones onto the correct side of the normal means that
// approximately 50% of envmap texture samples (the non-mirrored ones)
// are shared between adjacent fragments, improving texture cache hit rate.
float PdotD = dot(points[i], fragDir);
float aPdotD = abs(PdotD);
vec3 sampDir = points[i] + (aPdotD - PdotD) * fragDir;
fragCol += aPdotD * vec4(srgb_to_linear(texture(envmap, sampDir)).rgb, 1.0);
}
fragOut0 = linear_to_srgb(PI * fragCol * (1.0/128));
}
+53 -19
View File
@@ -1,4 +1,4 @@
//? #version 150
const int LT_DIRECTIONAL = 0; // A light like a sun
const int LT_POINT = 1; // A point light, like an explosion
const int LT_TUBE = 2; // A tube light, like a fluorescent light
@@ -7,10 +7,12 @@ const int LT_CONE = 3; // A cone light, like a flood light
const float SPEC_FACTOR_NO_SPEC_MAP = 0.1;
const float GLOW_MAP_INTENSITY = 1.5;
const float GLOW_MAP_SRGB_MULTIPLIER = 3.0;
const float PI = 3.14159f;
vec3 FresnelSchlick(vec3 specColor, vec3 light, vec3 halfVec)
vec3 FresnelSchlick(vec3 halfVec, vec3 view, vec3 specColor)
{
return specColor + (vec3(1.0) - specColor) * pow(1.0 - clamp(dot(light, halfVec), 0.0, 1.0), 5.0);
return specColor + (vec3(1.0) - specColor) * pow(1.0 - clamp(dot(view, halfVec), 0.0, 1.0), 5.0);
}
vec3 SpecularBlinnPhong(vec3 specColor, vec3 light, vec3 normal, vec3 halfVec, float specPower, float fresnel, float dotNL)
@@ -18,35 +20,67 @@ vec3 SpecularBlinnPhong(vec3 specColor, vec3 light, vec3 normal, vec3 halfVec, f
return mix(specColor, FresnelSchlick(specColor, light, halfVec), fresnel) * ((specPower + 2.0) / 8.0 ) * pow(clamp(dot(normal, halfVec), 0.0, 1.0), specPower) * dotNL;
}
vec3 SpecularGGX(vec3 specColor, vec3 light, vec3 normal, vec3 halfVec, vec3 view, float gloss, float fresnelFactor, float dotNL)
float GeometrySchlickGGX(float dotAB, float k)
{
return dotAB / (dotAB * (1.0f - k) + k);
}
vec3 ComputeGGX(vec3 specColor, vec3 diffColor, vec3 light, vec3 normal, vec3 halfVec, vec3 view, float roughness, float fresnelFactor, float dotNL)
{
float roughness = clamp(1.0f - gloss, 0.0f, 1.0f);
float alpha = roughness * roughness;
float alphaSqr = alpha * alpha;
float dotNH = clamp(dot(normal, halfVec), 0.0f, 1.0f);
float dotNV = clamp(dot(normal, view), 0.0f, 1.0f);
float alphaSqr = alpha * alpha;
float pi = 3.14159f;
float denom = dotNH * dotNH * (alphaSqr - 1.0f) + 1.0f;
float distribution = alphaSqr / (pi * denom * denom);
// NOTE - we're intentionally using UE4's reflectance model as modellers are using tools designed for common engines.
vec3 fresnel = mix(specColor, FresnelSchlick(specColor, light, halfVec), fresnelFactor);
// Cook-Torrance BRDF Model (Specular Reflection) = Distibution * Fresnel * Geometry / (4*dotNV*dotNL)
float alphaPrime = roughness + 1.0f;
float k = alphaPrime * alphaPrime / 8.0f;
float g1vNL = 1.0f / (dotNL * (1.0f - k) + k);
float g1vNV = 1.0f / (dotNV * (1.0f - k) + k);
float visibility = g1vNL * g1vNV;
// Distribution Term - Trowbridge-Reitz GGX
float denom = dotNH * dotNH * (alphaSqr - 1.0f) + 1.0001f; // Extra .0001 to prevent div 0
float distribution = alphaSqr / (PI * denom * denom);
return distribution * fresnel * visibility * dotNL;
// Fresnel Term - Fresnel-Schlick
vec3 fresnel = mix(specColor, FresnelSchlick(halfVec, view, specColor), fresnelFactor);
// Geometry Term - Schlick-GGX approximation
float r = roughness + 1.0;
float k = r * r / 8.0f;
// Smith's method:
// Microsurfaces block light rays coming in from the light
// AND block light rays reflecting to the camera.
// Hence, model both seperately and multiply.
float g1vNL = GeometrySchlickGGX(dotNL, k);
float g1vNV = GeometrySchlickGGX(dotNV, k);
float geometry = g1vNL * g1vNV;
vec3 specular = distribution * fresnel * geometry / (4*dotNV*dotNL + 0.0001);
// Diffuse term - Lambertian, kD represents energy lost to specular reflection.
vec3 kD = vec3(1.0)-fresnel;
kD *= (vec3(1.0) - specColor);
vec3 diffuse = kD * diffColor/PI;
return (specular + diffuse) * dotNL;
}
vec3 computeLighting(vec3 specColor, vec3 light, vec3 normal, vec3 halfVec, vec3 view, float gloss, float fresnelFactor, float dotNL)
vec3 computeLighting(vec3 specColor, vec3 diffColor, vec3 light, vec3 normal, vec3 halfVec, vec3 view, float roughness, float fresnelFactor, float dotNL)
{
#ifdef FLAG_LIGHT_MODEL_BLINN_PHONG
return SpecularBlinnPhong(specColor, light, normal, halfVec, 32, fresnelFactor, dotNL);
#else
return SpecularGGX(specColor, light, normal, halfVec, view, gloss, fresnelFactor, dotNL);
return ComputeGGX(specColor, diffColor, light, normal, halfVec, view, roughness, fresnelFactor, dotNL);
#endif
}
mat3 localCoordinates(vec3 normal, vec3 tangent_in)
{
// Create basis so we can transform `view` direction into local coord system
// We're not particularly attached to any basis as we have an isotropic roughness, and don't need to align axes with x,y terms.
vec3 tangent = normalize (tangent_in - dot (tangent_in, normal) * normal);
vec3 bitangent = cross(tangent, normal);
mat3 basis = mat3(tangent, bitangent, normal);
return basis;
}
+83 -59
View File
@@ -1,7 +1,8 @@
//? #version 150
#include "shadows.sdr" //! #include "shadows.sdr"
#include "lighting.sdr" //! #include "lighting.sdr"
#include "gamma.sdr" //! #include "gamma.sdr"
#include "shadows.sdr"
#include "lighting.sdr"
#include "gamma.sdr"
#define MAX_LIGHTS 8
#define LT_DIRECTIONAL 0
@@ -13,10 +14,11 @@ struct model_light {
vec3 diffuse_color;
int light_type;
vec3 spec_color;
vec3 direction;
float attenuation;
vec3 direction;
float ml_sourceRadius;
};
layout (std140) uniform modelData {
@@ -52,20 +54,20 @@ layout (std140) uniform modelData {
int blend_alpha;
vec3 emissionFactor;
bool overrideDiffuse;
bool overrideDiffuse_;
vec3 diffuseClr;
bool overrideGlow;
vec3 diffuseClr_;
bool overrideGlow_;
vec3 glowClr;
bool overrideSpec;
vec3 glowClr_;
bool overrideSpec_;
vec3 specClr;
vec3 specClr_;
bool alphaGloss;
bool gammaSpec;
bool envGloss;
bool alpha_spec;
bool alpha_spec_;
int effect_num;
vec4 fogColor;
@@ -86,7 +88,7 @@ layout (std140) uniform modelData {
float middist;
float fardist;
vec2 normalAlphaMinMax;
vec2 normalAlphaMinMax_;
int sBasemapIndex;
int sGlowmapIndex;
@@ -102,9 +104,9 @@ in VertexOutput {
#ifdef FLAG_ENV_MAP
vec3 envReflect;
#endif
#ifdef FLAG_NORMAL_MAP
mat3 tangentMatrix;
#endif
mat3 tangentMatrix;
#ifdef FLAG_FOG
float fogDist;
#endif
@@ -128,6 +130,7 @@ uniform sampler2DArray sSpecmap;
#endif
#ifdef FLAG_ENV_MAP
uniform samplerCube sEnvmap;
uniform samplerCube sIrrmap;
#endif
#ifdef FLAG_NORMAL_MAP
uniform sampler2DArray sNormalmap;
@@ -139,7 +142,7 @@ uniform sampler2DArray sAmbientmap;
uniform sampler2D sFramebuffer;
#endif
#ifdef FLAG_TEAMCOLOR
vec2 teamMask = vec2(0.0, 0.0);
vec4 teamMask;
#endif
#ifdef FLAG_MISC_MAP
uniform sampler2DArray sMiscmap;
@@ -196,7 +199,8 @@ vec3 CalculateLighting(vec3 normal, vec3 diffuseMaterial, vec3 specularMaterial,
if(i > 0) {
shadow = 1.0;
}
float roughness = clamp(1.0f - gloss, 0.0f, 1.0f);
float alpha = roughness * roughness;
vec3 lightDir;
float attenuation;
// gather light params
@@ -205,9 +209,9 @@ vec3 CalculateLighting(vec3 normal, vec3 diffuseMaterial, vec3 specularMaterial,
float NdotL = clamp(dot(normal, lightDir), 0.0f, 1.0f);
// Ambient, Diffuse, and Specular
lightDiffuse += (lights[i].diffuse_color.rgb * diffuseFactor * NdotL * attenuation) * shadow;
lightSpecular += lights[i].spec_color * computeLighting(specularMaterial, lightDir, normal, halfVec, eyeDir, gloss, fresnel, NdotL) * attenuation * shadow;
lightSpecular += lights[i].diffuse_color.rgb * computeLighting(specularMaterial, diffuseMaterial, lightDir, normal, halfVec, eyeDir, roughness, fresnel, NdotL) * attenuation * shadow;
}
return diffuseMaterial * (lightAmbient + lightDiffuse) + lightSpecular;
return diffuseMaterial * lightAmbient + lightSpecular;
}
void main()
@@ -225,10 +229,7 @@ void main()
vec4 specColor = vec4(0.0, 0.0, 0.0, 1.0);
vec4 emissiveColor = vec4(0.0, 0.0, 0.0, 1.0);
float fresnelFactor = 0.0;
float glossData = 0.6;
#ifdef FLAG_LIGHT
glossData = defaultGloss;
#endif
float glossData = defaultGloss;
vec2 aoFactors = vec2(1.0, 1.0);
#ifdef FLAG_AMBIENT_MAP
// red channel is ambient occlusion factor which only affects ambient lighting.
@@ -272,7 +273,6 @@ void main()
// premultiply alpha if blend_alpha is 1. assume that our blend function is srcColor + (1-Alpha)*destColor.
// if blend_alpha is 2, assume blend func is additive and don't modify color
if(blend_alpha == 1) baseColor.rgb = baseColor.rgb * baseColor.a;
if(overrideDiffuse) baseColor.rgb = diffuseClr;
#endif
specColor = vec4(baseColor.rgb * SPEC_FACTOR_NO_SPEC_MAP, glossData);
#ifdef FLAG_HDR
@@ -281,10 +281,6 @@ void main()
#ifdef FLAG_SPEC_MAP
specColor = texture(sSpecmap, vec3(texCoord, float(sSpecmapIndex)));
if(alphaGloss) glossData = specColor.a;
if(overrideSpec) {
specColor.rgb = specClr;
fresnelFactor = 1.0;
}
if(gammaSpec) {
specColor.rgb = max(specColor.rgb, vec3(0.03f)); // hardcoded minimum specular value. read John Hable's blog post titled 'Everything Is Shiny'.
fresnelFactor = 1.0;
@@ -295,9 +291,17 @@ void main()
#endif
baseColor.rgb *= aoFactors.y;
specColor.rgb *= aoFactors.y;
// Anti-glint "trick" based on Valve's "Advanced VR Rendering" talk at GDC2015:
// http://media.steampowered.com/apps/valve/2015/Alex_Vlachos_Advanced_VR_Rendering_GDC2015.pdf Page 43
// basically make surfaces rougher if local normals change too fast in screenspace
vec2 normDx = dFdx(unitNormal.xy);
vec2 normDy = dFdy(unitNormal.xy);
float glossGeo = 1.0f - pow(clamp(max(dot(normDx,normDx), dot(normDy,normDy)),0.0,1.0),0.33);
glossData = min(glossData, glossGeo);
#ifdef FLAG_MISC_MAP
#ifdef FLAG_TEAMCOLOR
vec4 teamMask = vec4(0.0, 0.0, 0.0, 0.0);
teamMask = texture(sMiscmap, vec3(texCoord, float(sMiscmapIndex)));
//For team colors applied to a diffuse or spec map, we assume that the base color of the diffuse
@@ -351,30 +355,62 @@ void main()
#endif
#endif
#ifdef FLAG_ENV_MAP
vec3 envReflectNM = vertIn.envReflect;
#ifdef FLAG_NORMAL_MAP
envReflectNM += vec3(normalSample, 0.0);
envReflectNM = normalize(envReflectNM);
#endif
float mip = (envGloss) ? (1.0 - glossData) * 7.0 : 0.0;
vec4 envColour = textureLod(sEnvmap, envReflectNM, mip);
#ifdef FLAG_HDR
envColour.rgb = srgb_to_linear(envColour.rgb);
#endif
envColour.rgb *= (envGloss) ? 1.0 : specColor.a;
emissiveColor.rgb += envColour.rgb * FresnelLazarovEnv(specColor.rgb, eyeDir, normal, glossData);
#ifdef FLAG_LIGHT
// Bit of a hack here, pretend we're doing blinn-phong shading and use a (modified version of) the derivation from
// Plausible Blinn-Phong Reflection of Standard Cube MIP-Maps - McGuire et al.
// to determine the mip bias.
// We use the specular term listed at http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html
// 1/(pi*alpha^2) * NdotM^((2/alpha^2)-2)
// so let s = (2/alpha^2 - 2)
// 1/2 log(s + 1) = 1/2 log(2/alpha^2 -1)
const float ENV_REZ = 512; // Ideally this would be #define'd and shader recompiled with envmap rez changes
const float REZ_BIAS = log2(ENV_REZ * sqrt(3));
float roughness = clamp(1.0f - glossData, 0.0f, 1.0f);
float alpha = roughness * roughness;
float alphaSqr = alpha * alpha;
float rough_bias = 0.5 * log2(2/alphaSqr - 1);
float mip_bias = REZ_BIAS - rough_bias;
// Sample light, using mip bias to blur it.
vec3 light_dir = reflect(-eyeDir, normal);
vec3 env_light_dir = vec3(envMatrix * vec4(light_dir, 0.0));
vec4 specEnvColour = srgb_to_linear(textureLod(sEnvmap, env_light_dir, mip_bias));
vec3 halfVec = normal;
// Lots of hacks here to get things to look right. We aren't loading a BRDF split-sum integral texture
// or properly calculating IBL levels.
// Fresnel calculation as with standard lights.
vec3 fresnel = mix(specColor.rgb, FresnelSchlick(halfVec, eyeDir, specColor.rgb), specColor.a);
// Pseudo-IBL, so use k_IBL
float k = alpha * alpha/ 2.0f;
float NdotL = max(dot(light_dir, normal),0);
float g1vNL = GeometrySchlickGGX(NdotL, k);
vec3 specEnvLighting = specEnvColour.rgb * fresnel * g1vNL;
vec3 kD = vec3(1.0)-fresnel;
kD *= (vec3(1.0) - specColor.rgb);
vec3 diffEnvColor = srgb_to_linear(texture(sIrrmap, vec3(envMatrix * vec4(normal, 0.0))).rgb);
vec3 diffEnvLighting = kD * baseColor.rgb * diffEnvColor * aoFactors.x;
emissiveColor.rgb += (specEnvLighting + diffEnvLighting) * baseColor.a;
#endif
#endif
#ifdef FLAG_GLOW_MAP
vec3 glowColor = texture(sGlowmap, vec3(texCoord, float(sGlowmapIndex))).rgb;
if(overrideGlow) glowColor = glowClr;
#ifdef FLAG_HDR
glowColor = srgb_to_linear(glowColor) * GLOW_MAP_SRGB_MULTIPLIER;
#endif
#ifdef FLAG_MISC_MAP
#ifdef FLAG_TEAMCOLOR
float glowColorLuminance = dot(glowColor, vec3(0.299, 0.587, 0.114));
glowColor = team_glow_enabled ? mix(max(team_color_glow, vec3(0.0)), glowColor, clamp(glowColorLuminance - teamMask.b - teamMask.a, 0.0, 1.0)) : glowColor;
#endif
#endif
#ifdef FLAG_HDR
glowColor = srgb_to_linear(glowColor) * GLOW_MAP_SRGB_MULTIPLIER;
#endif
emissiveColor.rgb += glowColor * GLOW_MAP_INTENSITY;
#endif
@@ -424,10 +460,6 @@ void main()
#endif
}
#endif
#ifdef FLAG_NORMAL_ALPHA
float normViewOffset = dot(vec3(0.0, 0.0, 1.0), normal);
baseColor.a = smoothstep(min(normalAlphaMinMax.x, normalAlphaMinMax.y), max(normalAlphaMinMax.x, normalAlphaMinMax.y), clamp(normalAlphaMinMax.x > normalAlphaMinMax.y ? normViewOffset : 1.0 - normViewOffset, 0.0, 1.0));
#endif
#ifndef FLAG_DEFERRED
// emissive colors won't be added later when we are using forward rendering so we need to do that here
baseColor.rgb += emissiveColor.rgb;
@@ -436,15 +468,7 @@ void main()
fragOut0 = baseColor;
#ifdef FLAG_DEFERRED
fragOut1 = vec4(vertIn.position.xyz, 1.0);
// Anti-glint "trick" based on Valve's "Advanced VR Rendering" talk at GDC2015:
// http://media.steampowered.com/apps/valve/2015/Alex_Vlachos_Advanced_VR_Rendering_GDC2015.pdf Page 43
// basically make surfaces rougher if local normals change too fast in screenspace
vec2 normDx = dFdx(normal.xy);
vec2 normDy = dFdy(normal.xy);
float glossGeo = 1.0f - pow(clamp(max(dot(normDx,normDx), dot(normDy,normDy)),0.0,1.0),0.33);
fragOut2 = vec4(normal, min(glossData, glossGeo));
fragOut2 = vec4(normal, glossData);
fragOut3 = vec4(specColor.rgb, fresnelFactor);
fragOut4 = emissiveColor;
#endif
+16 -16
View File
@@ -22,10 +22,10 @@ struct model_light {
vec3 diffuse_color;
int light_type;
vec3 spec_color;
vec3 direction;
float attenuation;
vec3 direction;
float ml_sourceRadius;
};
layout (std140) uniform modelData {
@@ -61,20 +61,20 @@ layout (std140) uniform modelData {
int blend_alpha;
vec3 emissionFactor;
bool overrideDiffuse;
bool overrideDiffuse_;
vec3 diffuseClr;
bool overrideGlow;
vec3 diffuseClr_;
bool overrideGlow_;
vec3 glowClr;
bool overrideSpec;
vec3 glowClr_;
bool overrideSpec_;
vec3 specClr;
vec3 specClr_;
bool alphaGloss;
bool gammaSpec;
bool envGloss;
bool alpha_spec;
bool alpha_spec_;
int effect_num;
vec4 fogColor;
@@ -95,7 +95,7 @@ layout (std140) uniform modelData {
float middist;
float fardist;
vec2 normalAlphaMinMax;
vec2 normalAlphaMinMax_;
int sBasemapIndex;
int sGlowmapIndex;
@@ -111,9 +111,9 @@ in VertexOutput {
#ifdef FLAG_ENV_MAP
vec3 envReflect;
#endif
#ifdef FLAG_NORMAL_MAP
mat3 tangentMatrix;
#endif
mat3 tangentMatrix;
#ifdef FLAG_FOG
float fogDist;
#endif
@@ -139,9 +139,9 @@ out VertexOutput {
#ifdef FLAG_ENV_MAP
vec3 envReflect;
#endif
#ifdef FLAG_NORMAL_MAP
mat3 tangentMatrix;
#endif
mat3 tangentMatrix;
#ifdef FLAG_FOG
float fogDist;
#endif
+18 -19
View File
@@ -1,3 +1,4 @@
//? #version 150
#extension GL_ARB_gpu_shader5: enable
#include "shadows.sdr"
@@ -16,10 +17,10 @@ struct model_light {
vec3 diffuse_color;
int light_type;
vec3 spec_color;
vec3 direction;
float attenuation;
vec3 direction;
float ml_sourceRadius;
};
layout (std140) uniform modelData {
@@ -55,20 +56,20 @@ layout (std140) uniform modelData {
int blend_alpha;
vec3 emissionFactor;
bool overrideDiffuse;
bool overrideDiffuse_;
vec3 diffuseClr;
bool overrideGlow;
vec3 diffuseClr_;
bool overrideGlow_;
vec3 glowClr;
bool overrideSpec;
vec3 glowClr_;
bool overrideSpec_;
vec3 specClr;
vec3 specClr_;
bool alphaGloss;
bool gammaSpec;
bool envGloss;
bool alpha_spec;
bool alpha_spec_;
int effect_num;
vec4 fogColor;
@@ -89,7 +90,7 @@ layout (std140) uniform modelData {
float middist;
float fardist;
vec2 normalAlphaMinMax;
vec2 normalAlphaMinMax_;
int sBasemapIndex;
int sGlowmapIndex;
@@ -109,9 +110,7 @@ out VertexOutput {
#ifdef FLAG_ENV_MAP
vec3 envReflect;
#endif
#ifdef FLAG_NORMAL_MAP
mat3 tangentMatrix;
#endif
mat3 tangentMatrix;
#ifdef FLAG_FOG
float fogDist;
#endif
@@ -188,12 +187,12 @@ void main()
vertOut.shadowUV[2] = transformToShadowMap(shadow_proj_matrix[2], 2, shadowPos);
vertOut.shadowUV[3] = transformToShadowMap(shadow_proj_matrix[3], 3, shadowPos);
#endif
#ifdef FLAG_NORMAL_MAP
// Setup stuff for normal maps
vec3 t = normalize(mat3(modelViewMatrix) * mat3(orient) * vertTangent.xyz);
vec3 b = cross(normal, t) * vertTangent.w;
vertOut.tangentMatrix = mat3(t, b, normal);
#endif
// Setup stuff for normal maps and envmaps
vec3 t = normalize(mat3(modelViewMatrix) * mat3(orient) * vertTangent.xyz);
vec3 b = cross(normal, t) * vertTangent.w;
vertOut.tangentMatrix = mat3(t, b, normal);
#ifdef FLAG_ENV_MAP
// Environment mapping reflection vector.
vec3 envReflect = reflect(normalize(position.xyz), normal);
+6 -1
View File
@@ -3,6 +3,11 @@ out vec4 fragOut0;
uniform sampler2DArray ytex;
uniform sampler2DArray utex;
uniform sampler2DArray vtex;
layout (std140) uniform movieData {
float alpha;
float pad[3];
};
void main()
{
float y = texture(ytex, vec3(fragTexCoord.st, 0.0)).r;
@@ -12,5 +17,5 @@ void main()
fragOut0.r = dot(val, vec3(1.1640625, 0.0, 1.59765625));
fragOut0.g = dot(val, vec3(1.1640625, -0.390625, -0.8125));
fragOut0.b = dot(val, vec3(1.1640625, 2.015625, 0.0));
fragOut0.a = 1.0;
fragOut0.a = alpha;
}
@@ -8,7 +8,7 @@ local function cfileLoader(name)
local file = nil
for i,v in ipairs(exts) do
local real_name = name .. v
local real_name = string.gsub(name, "%.", "/") .. v
file = cf.openFile(real_name, "r", "data/scripts")
if (file:isValid()) then
+10
View File
@@ -0,0 +1,10 @@
#CUSTOM CHEATS
$Cheat:
+Code: arrrrwalktheplank
+Message: Walk the plank
+SpawnShip:
+Name: Volition Bravos
+Class: Volition Bravos
#END
+1 -1
View File
@@ -79,7 +79,7 @@ $Fog:
+Start dist: 10.0
+Compl dist: 500.0
$AI:
+Valid goals: ( "fly to ship" "dock" "undock" "waypoints" "waypoints once" "stay near ship" "keep safe dist" "stay still" "play dead" "play dead (persistent)" )
+Valid goals: ( "fly to ship" "dock" "undock" "waypoints" "waypoints once" "stay near ship" "keep safe dist" "stay still" "play dead" "play dead (persistent)" "rearm ship" )
+Accept Player Orders: YES
+Player orders: ( "rearm me" "abort rearm" "depart" )
+Auto attacks: YES
+2
View File
@@ -147,6 +147,8 @@ extern bool Knossos_warp_ani_used;
extern bool Fireball_use_3d_warp;
extern bool Fireball_warp_flash;
// Cyborg - get a count of how many valid fireballs are in the mission.
int fireball_get_count();
+25 -34
View File
@@ -17,10 +17,21 @@
#include "mission/missionparse.h"
#include "model/model.h"
#include "nebula/neb.h"
#include "options/Option.h"
#include "render/3d.h"
#include "render/batching.h"
#include "ship/ship.h"
bool Fireball_warp_flash = false;
static auto WarpFlashOption = options::OptionBuilder<bool>("Graphics.WarpFlash", "Warp Flash", "Show flash upon warp open or close")
.category("Graphics")
.default_val(true)
.level(options::ExpertLevel::Advanced)
.bind_to_once(&Fireball_warp_flash)
.importance(65)
.finish();
void warpin_batch_draw_face( int texture, vertex *v1, vertex *v2, vertex *v3 )
{
vec3d norm;
@@ -55,47 +66,27 @@ void warpin_queue_render(model_draw_list *scene, object *obj, matrix *orient, ve
verts[1] = verts[2] = verts[3] = verts[4] = verts[0];
if (warp_glow_bitmap >= 0) {
float r = radius;
bool render_it = true;
// Add in noise
int noise_frame = fl2i(Missiontime/15.0f) % NOISE_NUM_FRAMES;
#define OUT_PERCENT1 0.80f
#define OUT_PERCENT2 0.90f
r *= (0.40f + Noise[noise_frame] * 0.30f);
#define IN_PERCENT1 0.10f
#define IN_PERCENT2 0.20f
if (Cmdline_warp_flash)
{
if ( (life_percent >= IN_PERCENT1) && (life_percent < IN_PERCENT2) ) {
r *= (life_percent - IN_PERCENT1) / (IN_PERCENT2 - IN_PERCENT1);
//render_it = true;
} else if ( (life_percent >= OUT_PERCENT1) && (life_percent < OUT_PERCENT2) ) {
r *= (OUT_PERCENT2 - life_percent) / (OUT_PERCENT2 - OUT_PERCENT1);
//render_it = true;
}
// Bobboau's warp thingie, toggled by cmdline
if (Fireball_warp_flash) {
r += powf((2.0f * life_percent) - 1.0f, 24.0f) * max_radius * 1.5f;
}
if (render_it) {
// Add in noise
int noise_frame = fl2i(Missiontime/15.0f) % NOISE_NUM_FRAMES;
vecs[4] = center;
verts[4].texture_position.u = 0.5f; verts[4].texture_position.v = 0.5f;
r *= (0.40f + Noise[noise_frame] * 0.30f);
g3_transfer_vertex( &verts[4], &vecs[4] );
// Bobboau's warp thingie, toggled by cmdline
if (Cmdline_warp_flash) {
r += powf((2.0f * life_percent) - 1.0f, 24.0f) * max_radius * 1.5f;
}
float alpha = (The_mission.flags[Mission::Mission_Flags::Fullneb]) ? neb2_get_fog_visibility(&obj->pos, 1.0f) : 1.0f;
vecs[4] = center;
verts[4].texture_position.u = 0.5f; verts[4].texture_position.v = 0.5f;
g3_transfer_vertex( &verts[4], &vecs[4] );
float alpha = (The_mission.flags[Mission::Mission_Flags::Fullneb]) ? neb2_get_fog_visibility(&obj->pos, 1.0f) : 1.0f;
//batch_add_bitmap(warp_glow_bitmap, TMAP_FLAG_TEXTURED | TMAP_HTL_3D_UNLIT, &verts[4], 0, r, alpha);
batching_add_bitmap(warp_glow_bitmap, &verts[4], 0, r, alpha);
}
//batch_add_bitmap(warp_glow_bitmap, TMAP_FLAG_TEXTURED | TMAP_HTL_3D_UNLIT, &verts[4], 0, r, alpha);
batching_add_bitmap(warp_glow_bitmap, &verts[4], 0, r, alpha);
}
if ( (warp_model_id >= 0) && (warp_3d) ) {
@@ -165,7 +156,7 @@ void warpin_queue_render(model_draw_list *scene, object *obj, matrix *orient, ve
warpin_batch_draw_face( texture_bitmap_num, &verts[0], &verts[3], &verts[4] );
}
if (warp_ball_bitmap >= 0 && Cmdline_warp_flash) {
if (warp_ball_bitmap >= 0 && Fireball_warp_flash) {
flash_ball warp_ball(20, .1f,.25f, &orient->vec.fvec, pos, 4.0f, 0.5f);
float adg = (2.0f * life_percent) - 1.0f;
+36 -33
View File
@@ -73,19 +73,20 @@ SCP_vector<SOUNDTRACK_INFO> Soundtracks;
int Current_soundtrack_num; // Active soundtrack for the current mission.. index into Soundtracks[]
int Current_pattern = -1; // currently playing part of track
int Pattern_timer_id = 0;
TIMESTAMP Pattern_timer_id = TIMESTAMP::invalid();
// File Globals
static int Num_enemy_arrivals;
static int Num_friendly_arrivals;
#define ARRIVAL_INTERVAL_TIMESTAMP 5000
#define BATTLE_CHECK_INTERVAL 15000
static int Battle_over_timestamp;
static int Mission_over_timestamp;
static int Victory2_music_played;
static int Next_arrival_timestamp;
static int Check_for_battle_music;
constexpr int ARRIVAL_INTERVAL_TIMESTAMP = 5 * MILLISECONDS_PER_SECOND;
constexpr int BATTLE_CHECK_INTERVAL = 15 * MILLISECONDS_PER_SECOND;
static TIMESTAMP Battle_over_timestamp;
static TIMESTAMP Mission_over_timestamp;
static bool Victory2_music_played;
static TIMESTAMP Next_arrival_timestamp;
static TIMESTAMP Check_for_battle_music; // this timestamp is actually never set
typedef struct pattern_info
{
@@ -409,7 +410,7 @@ void event_music_do_frame()
// start off the music delayed
if ( timestamp_elapsed(Pattern_timer_id) ) {
Pattern_timer_id = 0;
Pattern_timer_id = TIMESTAMP::invalid();
Event_music_begun = TRUE;
if ( Current_pattern != -1 && Patterns[Current_pattern].handle >= 0) {
//WMC - removed in favor of if
@@ -457,7 +458,7 @@ void event_music_do_frame()
if (Event_Music_battle_started == 0) {
if (Current_pattern == SONG_NRML_1 || Current_pattern == SONG_NRML_2 || Current_pattern == SONG_NRML_3 ) {
if (timestamp_elapsed(Check_for_battle_music)) {
Check_for_battle_music = timestamp(1000);
Check_for_battle_music = _timestamp(1 * MILLISECONDS_PER_SECOND);
if (hostile_ships_present() == TRUE) {
Patterns[Current_pattern].next_pattern = SONG_BTTL_1;
Patterns[Current_pattern].force_pattern = TRUE;
@@ -465,7 +466,7 @@ void event_music_do_frame()
}
} else if (Current_pattern == SONG_BTTL_1 || Current_pattern == SONG_BTTL_2 || Current_pattern == SONG_BTTL_3) {
if (timestamp_elapsed(Battle_over_timestamp)) {
Battle_over_timestamp = timestamp(BATTLE_CHECK_INTERVAL);
Battle_over_timestamp = _timestamp(BATTLE_CHECK_INTERVAL);
if (hostile_ships_present() == FALSE) {
Patterns[Current_pattern].force_pattern = TRUE;
@@ -501,11 +502,11 @@ void event_music_do_frame()
if ( !Victory2_music_played ) {
if ( timestamp_elapsed(Mission_over_timestamp) ) {
Mission_over_timestamp = timestamp(BATTLE_CHECK_INTERVAL);
Mission_over_timestamp = _timestamp(BATTLE_CHECK_INTERVAL);
if ( mission_goals_met() && (!hostile_ships_present()) ) {
Patterns[Current_pattern].next_pattern = SONG_VICT_2;
Patterns[Current_pattern].force_pattern = TRUE;
Victory2_music_played = 1;
Victory2_music_played = true;
}
}
}
@@ -596,11 +597,11 @@ void event_music_level_start(int force_soundtrack)
Num_enemy_arrivals = 0;
Num_friendly_arrivals = 0;
Battle_over_timestamp = timestamp(BATTLE_CHECK_INTERVAL);
Mission_over_timestamp = timestamp(BATTLE_CHECK_INTERVAL);
Next_arrival_timestamp = timestamp(1);
Victory2_music_played = 0;
Check_for_battle_music = 0;
Battle_over_timestamp = _timestamp(BATTLE_CHECK_INTERVAL);
Mission_over_timestamp = _timestamp(BATTLE_CHECK_INTERVAL);
Next_arrival_timestamp = TIMESTAMP::immediate();
Victory2_music_played = false;
Check_for_battle_music = TIMESTAMP::invalid(); // this should probably be immediate; we might introduce a flag later
if (Event_music_level_inited)
{
@@ -642,9 +643,9 @@ void event_music_first_pattern()
// if we really are initializing the level
if (Missiontime == 0) {
Pattern_timer_id = timestamp(-1); // don't let this start quite yet; see event_music_set_start_delay()
Pattern_timer_id = TIMESTAMP::invalid(); // don't let this start quite yet; see event_music_set_start_delay()
} else {
Pattern_timer_id = timestamp(0); // start immediately
Pattern_timer_id = TIMESTAMP::immediate(); // start immediately
}
Event_music_begun = FALSE;
@@ -672,7 +673,7 @@ void event_music_set_start_delay()
return;
}
Pattern_timer_id = timestamp(1000);
Pattern_timer_id = _timestamp(1 * MILLISECONDS_PER_SECOND);
}
// -------------------------------------------------------------------------------------------------
@@ -752,7 +753,7 @@ int event_music_battle_start()
}
Event_Music_battle_started = 1; // keep track of this state though, need on restore
Battle_over_timestamp = timestamp(BATTLE_CHECK_INTERVAL);
Battle_over_timestamp = _timestamp(BATTLE_CHECK_INTERVAL);
return 0;
}
@@ -847,7 +848,7 @@ int event_music_enemy_arrival()
Patterns[Current_pattern].force_pattern = TRUE;
}
Battle_over_timestamp = timestamp(BATTLE_CHECK_INTERVAL);
Battle_over_timestamp = _timestamp(BATTLE_CHECK_INTERVAL);
return 0;
}
@@ -934,9 +935,9 @@ int event_music_friendly_arrival()
}
}
Next_arrival_timestamp = timestamp(ARRIVAL_INTERVAL_TIMESTAMP);
Next_arrival_timestamp = _timestamp(ARRIVAL_INTERVAL_TIMESTAMP);
Battle_over_timestamp = timestamp(BATTLE_CHECK_INTERVAL);
Battle_over_timestamp = _timestamp(BATTLE_CHECK_INTERVAL);
return 0;
}
@@ -1031,10 +1032,10 @@ int event_music_primary_goals_met()
// If the mission goals aren't met (or there are no goals), or if victory 2 music has already played, then go
// to the next default track
if ( !mission_goals_met() || Victory2_music_played || (Num_goals == 0)) {
if ( !mission_goals_met() || Victory2_music_played || Mission_goals.empty()) {
Patterns[next_pattern].next_pattern = Patterns[next_pattern].default_next_pattern;
} else {
Victory2_music_played = 1;
Victory2_music_played = true;
}
}
@@ -1474,7 +1475,7 @@ void event_music_enable()
else {
// start a new pattern
Event_music_begun = FALSE;
Pattern_timer_id = timestamp(150);
Pattern_timer_id = _timestamp(150);
event_music_start_default();
}
}
@@ -1539,6 +1540,8 @@ int hostile_ships_present()
for ( so = GET_FIRST(&Ship_obj_list); so != END_OF_LIST(&Ship_obj_list); so = GET_NEXT(so) )
{
if (Objects[so->objnum].flags[Object::Object_Flags::Should_be_dead])
continue;
shipp = &Ships[Objects[so->objnum].instance];
// skip ourselves
@@ -1684,7 +1687,7 @@ int event_music_get_spooled_music_index(const char *name)
int event_music_get_spooled_music_index(const SCP_string& name)
{
return event_music_get_spooled_music_index(name.c_str());
}
}
// set a score based on name
void event_music_set_score(int score_index, const char *name)
@@ -1702,9 +1705,9 @@ void event_music_reset_choices()
mprintf(("Current soundtrack set to -1 in event_music_reset_choices\n"));
Mission_music[SCORE_BRIEFING] = -1;
Mission_music[SCORE_FICTION_VIEWER] = -1;
event_music_set_score(SCORE_DEBRIEF_SUCCESS, "Success");
event_music_set_score(SCORE_DEBRIEF_AVERAGE, "Average");
event_music_set_score(SCORE_DEBRIEF_FAIL, "Failure");
event_music_set_score(SCORE_DEBRIEFING_SUCCESS, "Success");
event_music_set_score(SCORE_DEBRIEFING_AVERAGE, "Average");
event_music_set_score(SCORE_DEBRIEFING_FAILURE, "Failure");
// Goober5000
strcpy_s(The_mission.substitute_briefing_music_name, "None");
@@ -1713,7 +1716,7 @@ void event_music_reset_choices()
void event_music_hostile_ship_destroyed()
{
Battle_over_timestamp = timestamp(BATTLE_CHECK_INTERVAL);
Battle_over_timestamp = _timestamp(BATTLE_CHECK_INTERVAL);
}
void event_music_set_volume(float volume)
+3 -3
View File
@@ -50,9 +50,9 @@ extern float Master_event_music_volume; // range is 0->1
/////////////////////////////////////////////////////////////////////////////
#define NUM_SCORES 5
#define SCORE_BRIEFING 0
#define SCORE_DEBRIEF_SUCCESS 1
#define SCORE_DEBRIEF_AVERAGE 2
#define SCORE_DEBRIEF_FAIL 3
#define SCORE_DEBRIEFING_SUCCESS 1
#define SCORE_DEBRIEFING_AVERAGE 2
#define SCORE_DEBRIEFING_FAILURE 3
#define SCORE_FICTION_VIEWER 4
extern int Mission_music[NUM_SCORES]; // indicies into Spooled_music[]
/////////////////////////////////////////////////////////////////////////////
+15 -17
View File
@@ -642,6 +642,9 @@ void parse_gamesnd_old(game_snd* gs)
stuff_string(entry.filename, F_NAME, MAX_FILENAME_LEN, ",");
// since we have a new filename, first assume it's valid
gs->flags &= ~GAME_SND_NOT_VALID;
if (!stricmp(entry.filename, NOX("empty")) || !stricmp(entry.filename, NOX("none")))
{
entry.filename[0] = 0;
@@ -684,7 +687,7 @@ void parse_gamesnd_old(game_snd* gs)
{
if (stuff_int_optional(&temp_max) == 2)
{
mprintf(("Dutifully converting retail sound %s, '%s' to a 3D sound...\n", gs->name.c_str(), entry.filename));
nprintf(("Sound","Dutifully converting retail sound %s, '%s' to a 3D sound...\n", gs->name.c_str(), entry.filename));
is_3d = 1;
gs->flags |= GAME_SND_USE_DS3D;
@@ -854,12 +857,15 @@ void parse_gamesnd_new(game_snd* gs, bool no_create)
entry = &gs->sound_entries.back();
}
// Default pitch is 1.0. This is set here in case we don't have a valid file name
gs->pitch_range = util::UniformFloatRange(1.0f);
char name[MAX_FILENAME_LEN];
// New extended format found
stuff_string(name, F_NAME, MAX_FILENAME_LEN);
// Default pitch is 1.0. This is set here in case we don't have a valid file name
gs->pitch_range = util::UniformFloatRange(1.0f);
// since we have a new filename, first assume it's valid
gs->flags &= ~GAME_SND_NOT_VALID;
if (!stricmp(name, NOX("empty")) || !stricmp(name, NOX("none")))
{
@@ -1183,8 +1189,6 @@ void parse_sound_environments()
required_string("#Sound Environments End");
}
static SCP_vector<species_info> missingFlybySounds;
void parse_sound_table(const char* filename)
{
try
@@ -1285,20 +1289,14 @@ void gamesnd_parse_soundstbl()
parse_modular_table("*-snd.tbm", parse_sound_table);
// if we are missing any species then report
if (!missingFlybySounds.empty())
{
SCP_string errorString;
for (size_t i = 0; i < missingFlybySounds.size(); i++)
{
errorString.append(missingFlybySounds[i].species_name);
errorString.append("\n");
//Set any flyby sounds for species that use the borrowed feature
for (size_t i = 0; i < Species_info.size(); i++) {
if (Species_info[i].borrows_flyby_sounds_species >= 0) {
int idx = Species_info[i].borrows_flyby_sounds_species;
Species_info[i].snd_flyby_fighter = Species_info[idx].snd_flyby_fighter;
Species_info[i].snd_flyby_bomber = Species_info[idx].snd_flyby_bomber;
}
Error(LOCATION, "The following species are missing flyby sounds in sounds.tbl:\n%s", errorString.c_str());
}
missingFlybySounds.clear();
}
/**
+58
View File
@@ -6,6 +6,8 @@
#include "osapi/dialogs.h"
constexpr size_t UBYTE_SIZE = 8;
template<typename TEnum, size_t SIZE>
struct flag_combinator;
@@ -114,6 +116,61 @@ class flagset {
return *this;
}
size_t to_ubyte_vector(SCP_vector<ubyte>& vector_out)
{
int counter = 0; // a counter to determine how far to bitshift
ubyte ubyte_out= 0; // the holder for our bitshifted flags
for (size_t i = 0; i < SIZE; i++) {
// this needs to be at the beginning for push_back after the loop
// to work properly.
if (counter == UBYTE_SIZE) {
vector_out.push_back(ubyte_out);
counter = 0;
ubyte_out = 0;
}
// check whether that flag was set
// there is probably a more efficient way to do this,
// but not unless we can copy the underlying data safely.
if (values[i]) {
ubyte_out |= 1 << counter;
}
// iterate
++counter;
}
vector_out.push_back(ubyte_out);
return vector_out.size();
}
void set_from_vector(const SCP_vector<ubyte>& vector_in)
{
size_t flag = 0;
// just iterate through the entries, and set flags as appropriate.
for (auto& entry : vector_in) {
for (uint bitshift = 0; bitshift < UBYTE_SIZE; bitshift++){
if (entry & (1 << bitshift)) {
values.set(flag, true);
}
++flag;
// this function is used in multi where the size of flagsets can be different
// on server and client. Small differences in flagset sizes should not affect
// gameplay, but we have to make sure not to exceed the size of the flagset.
if (flag >= SIZE){
return;
}
}
}
}
flagset<T>& toggle(T idx) {
values[static_cast < size_t >(idx)] = !values[static_cast < size_t >(idx)];
@@ -124,6 +181,7 @@ class flagset {
bool none_set() { return values.none(); }
void from_u64(std::uint64_t num) { values = (unsigned long) num; }
std::uint64_t to_u64() const { return (std::uint64_t) values.to_ulong(); }
size_t hash() const { return std::hash<std::bitset<SIZE>>()(values); }
+4 -4
View File
@@ -32,8 +32,8 @@
#define SHORT_CALLSIGN_PIXEL_W 80 // max width of short_callsign[] in pixels
// from ship.h
#define MAX_SHIPS 400 // max number of ship instances there can be.DTP; bumped from 200 to 400
#define SHIPS_LIMIT 400 // what MAX_SHIPS will be at release time (for error checking in debug mode); dtp Bumped from 200 to 400
#define MAX_SHIPS 500 // max number of ship instances there can be.DTP; bumped from 200 to 400, then to 500 in 2022
#define SHIPS_LIMIT 500 // what MAX_SHIPS will be at release time (for error checking in debug mode); dtp Bumped from 200 to 400, then to 500 in 2022
// from missionparse.h and then redefined to the same value in sexp.h
#define TOKEN_LENGTH 32
@@ -61,7 +61,7 @@
#define MAX_COMPLETE_ESCORT_LIST 20
// from weapon.h
#define MAX_WEAPONS 2000
#define MAX_WEAPONS 3000 //Increased from 2000 to 3000 in 2022
#define MAX_WEAPON_TYPES 500
@@ -73,7 +73,7 @@
#define MAX_POLYGON_MODELS 300
// object.h
#define MAX_OBJECTS 3500
#define MAX_OBJECTS 5000 //Increased from 3500 to 5000 in 2022
// from weapon.h (and beam.h)
#define MAX_BEAM_SECTIONS 5
+15
View File
@@ -46,3 +46,18 @@ inline void *vm_realloc(void *ptr, size_t size)
return ret_ptr;
}
// For use with unique_ptr
template <typename T>
struct VmFreeDeleter
{
void operator()(T* const p) const
{
vm_free(p);
}
};
// Managed unique pointer for data allocated using vm_malloc. Never use with data allocated with new or malloc;
// allocation and deallocation must always be performed using matching operations.
template<typename T>
using SCP_vm_unique_ptr = std::unique_ptr<T, VmFreeDeleter<T>>;
+40 -14
View File
@@ -17,6 +17,7 @@
#include "windows_stub/config.h"
#include "globalincs/scp_defines.h"
#include "globalincs/toolchain.h"
#include "globalincs/vmallocator.h"
#include "utils/strings.h"
#include <cstdio> // For NULL, etc
@@ -25,6 +26,7 @@
#include <cstring>
#include <algorithm>
#include <cstdint>
#include <functional>
// value to represent an uninitialized state in any int or uint
#define UNINITIALIZED 0x7f8e6d9c
@@ -209,6 +211,7 @@ struct flag_def_list {
ubyte var;
};
//A list of parse names for a flag enum
template<class T>
struct flag_def_list_new {
const char* name; // The parseable representation of this flag
@@ -217,6 +220,17 @@ struct flag_def_list_new {
bool is_special; // Whether this flag requires special processing. See parse_string_flag_list<T, T> for details
};
//A list of parse names for a flag enum. Instead of specifying whether an argument needs special handling,
//a functor can passed that is called to handle an argument proceeding the flag. If used with parse_string_flag_list_special,
//these will automatically be called when a special argument is encountered
template<class T, typename... additional_args>
struct special_flag_def_list_new : public flag_def_list_new<T> {
std::function<void(const SCP_string&, additional_args...)> parse_special;
special_flag_def_list_new(const char* name, T flag, bool in_use) : flag_def_list_new<T>{ name, flag, in_use, false } {}
special_flag_def_list_new(const char* name, T flag, bool in_use, const decltype(parse_special)& parseSpecial) : flag_def_list_new<T>{ name, flag, in_use, true }, parse_special(parseSpecial) { }
};
// weapon count list (mainly for pilot files)
typedef struct wep_t {
int index;
@@ -468,25 +482,37 @@ SCP_string dump_stacktrace();
const auto ptr_memset = std::memset;
#define memset memset_if_trivial_else_error
// Forward declarations from libraries
struct ImDrawListSplitter;
// Put into std to be compatible with code that uses std::mem*
namespace std
{
template<typename T>
using trivial_check = std::is_trivially_copyable<T>;
template <typename T>
using trivial_check = std::is_trivially_copyable<T>;
template<typename T>
void *memset_if_trivial_else_error(T *memset_data, int ch, size_t count)
{
static_assert(trivial_check<T>::value, "memset on non-trivial object");
return ptr_memset(memset_data, ch, count);
}
template <typename T>
void* memset_if_trivial_else_error(
typename std::enable_if<!std::is_same<T, ImDrawListSplitter>::value, T>::type* memset_data,
int ch,
size_t count)
{
static_assert(trivial_check<T>::value, "memset on non-trivial object");
return ptr_memset(memset_data, ch, count);
}
// assume memset on a void* is "safe"
// only used in cutscene/mveplayer.cpp:mve_video_createbuf()
inline void *memset_if_trivial_else_error(void *memset_data, int ch, size_t count)
{
return ptr_memset(memset_data, ch, count);
}
// assume memset on a void* is "safe"
// only used in cutscene/mveplayer.cpp:mve_video_createbuf()
inline void* memset_if_trivial_else_error(void* memset_data, int ch, size_t count)
{
return ptr_memset(memset_data, ch, count);
}
// Dear ImGui triggers these as well, so we need to let them pass
inline void* memset_if_trivial_else_error(ImDrawListSplitter* memset_data, int ch, size_t count)
{
return ptr_memset(memset_data, ch, count);
}
// MEMCPY!
const auto ptr_memcpy = std::memcpy;
+45
View File
@@ -61,6 +61,51 @@ errno_t scp_strcpy_s( const char* file, int line, char* strDest, size_t sizeInBy
return 0;
}
errno_t scp_strncpy_s(const char* file, int line, char* strDest, size_t sizeInBytes, const char* strSource, size_t inputSizeInBytes) {
char* pDest;
const char* pSource;
size_t bufferLeft = sizeInBytes;
if (!strDest || !strSource)
{
if (strDest)
*strDest = '\0';
__safe_strings_error_handler(EINVAL);
return EINVAL;
}
if (sizeInBytes == 0)
{
*strDest = '\0';
__safe_strings_error_handler(ERANGE);
return ERANGE;
}
if (inputSizeInBytes == 0)
{
*strDest = '\0';
return 0;
}
pDest = strDest;
pSource = strSource;
while ((*pDest++ = *pSource++) != 0 && (--inputSizeInBytes > 0) && --bufferLeft > 0);
if (bufferLeft == 0 || (inputSizeInBytes == 0 && bufferLeft <= 1))
{
*strDest = '\0';
__safe_strings_error_handler(ERANGE);
return ERANGE;
}
if (inputSizeInBytes == 0) {
*pDest = '\0';
}
return 0;
}
errno_t scp_strcat_s( const char* file, int line, char* strDest, size_t sizeInBytes, const char* strSource )
{
char* pDest;
+10
View File
@@ -22,6 +22,7 @@
/* errno_t, EINVAL, ERANGE, etc.. */
#include <cerrno>
#include <cstdlib> /* size_t */
#include "globalincs/pstypes.h"
/* Because errno_t is not (yet) standard, we define it here like this */
typedef int errno_t;
@@ -48,6 +49,7 @@ typedef int errno_t;
#endif
extern errno_t scp_strcpy_s( const char* file, int line, char* strDest, size_t sizeInBytes, const char* strSource );
extern errno_t scp_strncpy_s( const char* file, int line, char* strDest, size_t sizeInBytes, const char* strSource, size_t inputSizeInBytes );
extern errno_t scp_strcat_s( const char* file, int line, char* strDest, size_t sizeInBytes, const char* strSource );
template< size_t size>
@@ -57,6 +59,13 @@ errno_t scp_strcpy_s( const char* file, int line, char (&strDest)[ size ], const
return scp_strcpy_s( file, line, strDest, size, strSource );
}
template< size_t size>
inline
errno_t scp_strncpy_s(const char* file, int line, char(&strDest)[size], const char* strSource, size_t count)
{
return scp_strncpy_s(file, line, strDest, size, strSource, count);
}
template< size_t size >
inline
errno_t scp_strcat_s( const char* file, int line, char (&strDest)[ size ], const char* strSource )
@@ -65,6 +74,7 @@ errno_t scp_strcat_s( const char* file, int line, char (&strDest)[ size ], const
}
#define strcpy_s( ... ) scp_strcpy_s( __FILE__, __LINE__, __VA_ARGS__ )
#define strncpy_s( ... ) scp_strncpy_s( __FILE__, __LINE__, __VA_ARGS__ )
#define strcat_s( ... ) scp_strcat_s( __FILE__, __LINE__, __VA_ARGS__ )
#elif defined(_MSC_VER) && _MSC_VER < 1400 || defined(NO_SAFE_STRINGS)
-17
View File
@@ -17,7 +17,6 @@
#include "options/Option.h"
fix Missiontime;
fix Skybox_timestamp;
fix Frametime;
int Framecount=0;
@@ -66,29 +65,13 @@ char Processing_filename[MAX_PATH_LEN];
#endif
// override states to skip rendering of certain elements, but without disabling them completely
bool Basemap_override = false;
bool Envmap_override = false;
bool Specmap_override = false;
bool Normalmap_override = false;
bool Heightmap_override = false;
bool Glowpoint_override = false;
bool Glowpoint_use_depth_buffer = true;
bool PostProcessing_override = false;
bool Shadow_override = false;
bool Trail_render_override = false;
bool Basemap_color_override_set = false;
float Basemap_color_override[4] = {0.0f, 0.0f, 0.0f, 1.0f};
bool Glowmap_color_override_set = false;
float Glowmap_color_override[3] = {0.0f, 0.0f, 0.0f};
bool Specmap_color_override_set = false;
float Specmap_color_override[3] = {0.0f, 0.0f, 0.0f};
bool Gloss_override_set = false;
float Gloss_override = 0.0f;
// Values used for noise for thruster animations
float Noise[NOISE_NUM_FRAMES] = {
0.468225f,
+5 -23
View File
@@ -85,7 +85,6 @@ typedef struct vci {
} vci;
extern fix Missiontime;
extern fix Skybox_timestamp;
extern fix Frametime;
extern int Framecount;
@@ -138,31 +137,14 @@ extern float Noise[NOISE_NUM_FRAMES];
// override states to skip rendering of certain elements, but without disabling them completely
extern bool Basemap_override;
extern bool Envmap_override;
extern bool Specmap_override;
extern bool Normalmap_override;
extern bool Heightmap_override;
extern bool Glowpoint_override;
extern bool Glowpoint_use_depth_buffer;
extern bool GLSL_override;
extern bool PostProcessing_override;
extern bool Shadow_override;
extern bool Trail_render_override;
extern bool Basemap_color_override_set;
extern float Basemap_color_override[4];
extern bool Glowmap_color_override_set;
extern float Glowmap_color_override[3];
extern bool Specmap_color_override_set;
extern float Specmap_color_override[3];
extern bool Gloss_override_set;
extern float Gloss_override;
// game skill levels
// game skill levels
#define NUM_SKILL_LEVELS 5
//====================================================================================
@@ -216,8 +198,8 @@ int current_detail_level();
// A sort for use with small or almost-sorted lists. Iteration time is O(n) for a fully-sorted list.
// This uses a type-safe version of the function prototype for stdlib's qsort, although the size is an int rather than a size_t (for the reasons that j is an int).
// The fncompare function should return <0, 0, or >0 as the left item is less than, equal to, or greater than the right item.
template <typename T>
void insertion_sort(T* array_base, int array_size, int (*fncompare)(const T*, const T*))
template <typename array_t, typename T>
void insertion_sort(array_t& array_base, int array_size, int (*fncompare)(const T*, const T*))
{
// NOTE: j *must* be a signed type because j reaches -1 and j+1 must be 0.
int i, j;
@@ -225,7 +207,7 @@ void insertion_sort(T* array_base, int array_size, int (*fncompare)(const T*, co
// allocate space for the element being moved
// (Taylor says that for optimization purposes malloc/free should be used rather than vm_malloc/vm_free here)
current_buf = (T*)malloc(sizeof(T));
current_buf = new T();
if (current_buf == nullptr)
{
UNREACHABLE("Malloc failed!");
@@ -264,7 +246,7 @@ void insertion_sort(T* array_base, int array_size, int (*fncompare)(const T*, co
}
// free the allocated space
free(current_buf);
delete current_buf;
}
#endif
+37
View File
@@ -48,6 +48,43 @@ version parse_version() {
return v;
}
version parse_version_inline() {
version v;
SCP_string input;
stuff_string(input, F_RAW);
size_t start_pos = 0;
size_t end_pos = input.find('.');
v.major = std::atoi(input.substr(start_pos, end_pos - start_pos).c_str());
if (end_pos == SCP_string::npos)
return v;
start_pos = end_pos + 1;
end_pos = input.find('.', start_pos);
v.minor = std::atoi(input.substr(start_pos, end_pos - start_pos).c_str());
if (end_pos == SCP_string::npos)
return v;
start_pos = end_pos + 1;
end_pos = input.find('.', start_pos);
v.build = std::atoi(input.substr(start_pos, end_pos - start_pos).c_str());
if (end_pos == SCP_string::npos)
return v;
start_pos = end_pos + 1;
end_pos = input.find('.', start_pos);
v.revision = std::atoi(input.substr(start_pos, end_pos - start_pos).c_str());
return v;
}
version get_executable_version() {
version v;
v.major = FS_VERSION_MAJOR;
+1
View File
@@ -68,6 +68,7 @@ struct version {
};
version parse_version();
version parse_version_inline();
version get_executable_version();
+49 -16
View File
@@ -1,12 +1,15 @@
#ifndef _VMALLOCATOR_H_INCLUDED_
#define _VMALLOCATOR_H_INCLUDED_
#include <algorithm>
#include <deque>
#include <iterator>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <type_traits>
@@ -14,24 +17,24 @@
#include <unordered_set>
#include <vector>
template< typename T >
using SCP_vector = std::vector< T, std::allocator< T > >;
template <typename T>
using SCP_vector = std::vector<T, std::allocator<T>>;
template< typename T >
template <typename T>
bool SCP_vector_contains(SCP_vector<T>& vector, T item) {
return std::find(vector.begin(), vector.end(), item) != vector.end();
}
template< typename T >
using SCP_list = std::list< T, std::allocator< T > >;
template <typename T>
using SCP_list = std::list<T, std::allocator<T>>;
extern std::locale SCP_default_locale;
template< class charT >
template <class charT>
charT SCP_toupper(charT ch) { return std::toupper(ch, SCP_default_locale); }
template< class charT >
template <class charT>
charT SCP_tolower(charT ch) { return std::tolower(ch, SCP_default_locale); }
typedef std::basic_string<char, std::char_traits<char>, std::allocator<char> > SCP_string;
@@ -46,24 +49,36 @@ inline void SCP_toupper(SCP_string &str) {
std::transform(str.begin(), str.end(), str.begin(), [](char c) { return SCP_toupper(c); });
}
inline bool SCP_truncate(SCP_string &str, size_t c_str_size) {
if (str.length() >= c_str_size) {
str.resize(c_str_size - 1);
return true;
} else {
return false;
}
}
extern void SCP_tolower(char *str);
extern void SCP_toupper(char *str);
template< typename T, typename U >
using SCP_map = std::map<T, U, std::less<T>, std::allocator<std::pair<const T, U> > >;
template <typename T, typename U>
using SCP_map = std::map<T, U, std::less<T>, std::allocator<std::pair<const T, U>>>;
template< typename T, typename U >
using SCP_multimap = std::multimap<T, U, std::less<T>, std::allocator<std::pair<const T, U> > >;
template <typename T, typename U>
using SCP_multimap = std::multimap<T, U, std::less<T>, std::allocator<std::pair<const T, U>>>;
template< typename T >
using SCP_queue = std::queue< T, std::deque< T, std::allocator< T > > >;
template <typename T>
using SCP_queue = std::queue<T, std::deque<T, std::allocator<T>>>;
template< typename T >
using SCP_deque = std::deque< T, std::allocator< T > >;
template <typename T>
using SCP_deque = std::deque<T, std::allocator<T>>;
template <typename T>
using SCP_set = std::set<T, std::less<T>, std::allocator<T>>;
#if __cplusplus < 201402L
template <class T, bool>
template<class T, bool>
struct enum_hasher_util {
inline size_t operator()(const T& elem) { return std::hash<T>()(elem); }
};
@@ -155,4 +170,22 @@ using SCP_unordered_map = std::unordered_map<Key, T, Hash, KeyEqual, std::alloca
template <typename Key, typename Hash = SCP_hash<Key>, typename KeyEqual = std::equal_to<Key>>
using SCP_unordered_set = std::unordered_set<Key, Hash, KeyEqual, std::allocator<Key>>;
template <typename T, typename... Args>
typename std::enable_if<!std::is_array<T>::value, std::unique_ptr<T>>::type make_unique(Args&&... args) {
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
template <typename T, typename... Args>
typename std::enable_if<std::is_array<T>::value, std::unique_ptr<T>>::type make_unique(std::size_t n) {
return std::unique_ptr<T>(new typename std::remove_extent<T>::type[n]());
}
template <typename T, typename... Args>
typename std::enable_if<!std::is_array<T>::value, std::shared_ptr<T>>::type make_shared(Args&&... args) {
return std::shared_ptr<T>(new T(std::forward<Args>(args)...));
}
template <typename T, typename... Args>
typename std::enable_if<std::is_array<T>::value, std::shared_ptr<T>>::type make_shared(std::size_t n) {
return std::shared_ptr<T>(new typename std::remove_extent<T>::type[n]());
}
#endif // _VMALLOCATOR_H_INCLUDED_
+6 -6
View File
@@ -175,7 +175,7 @@ static auto WindowModeOption = options::OptionBuilder<os::ViewportState>("Graphi
.change_listener(mode_change_func)
.finish();
const std::shared_ptr<scripting::OverridableHook> OnFrameHook = scripting::OverridableHook::Factory(
const std::shared_ptr<scripting::OverridableHook<>> OnFrameHook = scripting::OverridableHook<>::Factory(
"On Frame", "Called every frame as the last action before showing the frame result to the user.", {}, CHA_ONFRAME);
// z-buffer stuff
@@ -432,7 +432,7 @@ bool gr_is_smaa_mode(AntiAliasMode mode) {
bool Gr_post_processing_enabled = true;
static auto PostProcessOption =
options::OptionBuilder<bool>("Graphis.PostProcessing", "Post processing",
options::OptionBuilder<bool>("Graphics.PostProcessing", "Post processing",
"Controls whether post processing is enabled in the engine")
.category("Graphics")
.level(options::ExpertLevel::Advanced)
@@ -443,7 +443,7 @@ static auto PostProcessOption =
bool Gr_enable_vsync = true;
static auto VSyncOption = options::OptionBuilder<bool>("Graphis.VSync", "Vertical Sync",
static auto VSyncOption = options::OptionBuilder<bool>("Graphics.VSync", "Vertical Sync",
"Controls how the engine does vertical synchronization")
.category("Graphics")
.level(options::ExpertLevel::Advanced)
@@ -1305,6 +1305,7 @@ static bool gr_init_sub(std::unique_ptr<os::GraphicsOperations>&& graphicsOps, i
gr_screen.bytes_per_pixel= depth / 8;
gr_screen.rendering_to_texture = -1;
gr_screen.envmap_render_target = -1;
gr_screen.irrmap_render_target = -1;
gr_screen.line_width = 1.0f;
gr_screen.mode = mode;
gr_screen.res = res;
@@ -1552,7 +1553,8 @@ bool gr_init(std::unique_ptr<os::GraphicsOperations>&& graphicsOps, int d_mode,
if (gr_get_resolution_class(width, height) != GR_640) {
// check for hi-res interface files so that we can verify our width/height is correct
// if we don't have it then fall back to 640x480 mode instead
if ( !cf_exists_full("2_ChoosePilot-m.pcx", CF_TYPE_ANY)) {
// Lafiel: BUT! Only do this if the "low res graphic" ACTUALLY exists. Using SCPUI, not having this file is not a sufficient indicator for being on forced low-res.
if ( !cf_exists_full("2_ChoosePilot-m.pcx", CF_TYPE_ANY) && cf_exists_full("ChoosePilot-m.pcx", CF_TYPE_ANY)) {
if ( (width == 1024) && (height == 768) ) {
width = 640;
height = 480;
@@ -2560,8 +2562,6 @@ void gr_flip(bool execute_scripting)
if (OnFrameHook->isActive()) {
OnFrameHook->run();
}
// WMC - Do scripting reset stuff
Script_system.EndFrame();
}
gr_reset_immediate_buffer();
+16 -4
View File
@@ -30,6 +30,7 @@ class GPUMemoryHeap;
} // namespace util
} // namespace graphics
namespace scripting {
template<typename condition_t>
class OverridableHook;
}
@@ -75,7 +76,7 @@ extern bool High_dynamic_range;
extern os::ViewportState Gr_configured_window_state;
extern const std::shared_ptr<scripting::OverridableHook> OnFrameHook;
extern const std::shared_ptr<scripting::OverridableHook<void>> OnFrameHook;
class material;
class model_material;
@@ -206,6 +207,8 @@ enum shader_type {
SDR_TYPE_ENVMAP_SPHERE_WARP,
SDR_TYPE_IRRADIANCE_MAP_GEN,
NUM_SHADER_TYPES
};
@@ -230,7 +233,7 @@ enum shader_type {
#define SDR_FLAG_MODEL_CLIP (1<<17)
#define SDR_FLAG_MODEL_HDR (1<<18)
#define SDR_FLAG_MODEL_AMBIENT_MAP (1<<19)
#define SDR_FLAG_MODEL_NORMAL_ALPHA (1<<20)
#define SDR_FLAG_MODEL_UNUSED20 (1<<20)
#define SDR_FLAG_MODEL_THICK_OUTLINES (1<<21) // Renders the model geometry as an outline with configurable line width
#define SDR_FLAG_MODEL_ALPHA_MULT (1<<22)
@@ -251,7 +254,8 @@ enum class uniform_block_type {
DecalGlobals = 4,
DeferredGlobals = 5,
Matrices = 6,
GenericData = 7,
MovieData = 7,
GenericData = 8,
NUM_BLOCK_TYPES
};
@@ -697,6 +701,7 @@ typedef struct screen {
int rendering_to_face = 0; // wich face of the texture we are rendering to, -1 if the back buffer
int envmap_render_target = 0;
int irrmap_render_target = -1; // Irradiance map for diffuse env lighting.
float line_width = 0.0f;
@@ -715,9 +720,15 @@ typedef struct screen {
// dumps the current screen to a file
std::function<void(const char* filename)> gf_print_screen;
// dumps the current screen to a html blob string
std::function<SCP_string()> gf_blob_screen;
// transforms and dumps the current environment map to a file
std::function<void(const char* filename)> gf_dump_envmap;
// generate diffuse irradiance cubemap for IBL.
std::function<void()> gf_calculate_irrmap;
// Retrieves the zbuffer mode.
std::function<int()> gf_zbuffer_get;
@@ -790,7 +801,7 @@ typedef struct screen {
std::function<void()> gf_post_process_save_zbuffer;
std::function<void()> gf_post_process_restore_zbuffer;
std::function<void()> gf_deferred_lighting_begin;
std::function<void(bool clearNonColorBufs)> gf_deferred_lighting_begin;
std::function<void()> gf_deferred_lighting_end;
std::function<void()> gf_deferred_lighting_finish;
@@ -1002,6 +1013,7 @@ extern void gr_activate(int active);
// old Descent-style gr_xxx calls.
#define gr_print_screen GR_CALL(gr_screen.gf_print_screen)
#define gr_blob_screen GR_CALL(gr_screen.gf_blob_screen)
#define gr_dump_envmap GR_CALL(gr_screen.gf_dump_envmap)
//#define gr_flip GR_CALL(gr_screen.gf_flip)
+1 -7
View File
@@ -114,13 +114,7 @@ decal_draw_list::decal_draw_list(size_t num_decals)
header->viewportSize.x = (float) gr_screen.max_w;
header->viewportSize.y = (float) gr_screen.max_h;
header->ambientLight.xyz.x = gr_light_ambient[0] + gr_user_ambient;
header->ambientLight.xyz.y = gr_light_ambient[1] + gr_user_ambient;
header->ambientLight.xyz.z = gr_light_ambient[2] + gr_user_ambient;
CLAMP(header->ambientLight.xyz.x, 0.02f, 1.0f);
CLAMP(header->ambientLight.xyz.y, 0.02f, 1.0f);
CLAMP(header->ambientLight.xyz.z, 0.02f, 1.0f);
gr_get_ambient_light(&header->ambientLight);
// Square the ambient part of the light to match the formula used in the main model shader
header->ambientLight.xyz.x *= header->ambientLight.xyz.x;
+2 -2
View File
@@ -162,7 +162,7 @@ int generic_anim_stream(generic_anim *ga, const bool cache)
ga->type = BM_TYPE_NONE;
auto res = cf_find_file_location_ext(ga->filename, BM_ANI_NUM_TYPES, bm_ani_ext_list, CF_TYPE_ANY, false);
auto res = cf_find_file_location_ext(ga->filename, BM_ANI_NUM_TYPES, bm_ani_ext_list, CF_TYPE_ANY);
// could not be found, or is invalid for some reason
if ( !res.found )
@@ -217,7 +217,7 @@ int generic_anim_stream(generic_anim *ga, const bool cache)
ga->png.anim = new apng::apng_ani(ga->filename, cache);
}
catch (const apng::ApngException& e) {
mprintf(("Failed to load apng: %s\n", e.what() ));
nprintf(("apng","Failed to load apng: %s\n", e.what() ));
delete ga->png.anim;
ga->png.anim = nullptr;
ga->type = BM_TYPE_NONE;
+7 -1
View File
@@ -91,6 +91,11 @@ void gr_stub_print_screen(const char * /*filename*/)
{
}
SCP_string gr_stub_blob_screen()
{
return "";
}
void gr_stub_rect(int /*x*/, int /*y*/, int /*w*/, int /*h*/, int /*resize_mode*/)
{
}
@@ -217,7 +222,7 @@ void gr_stub_copy_effect_texture()
{
}
void gr_stub_deferred_lighting_begin()
void gr_stub_deferred_lighting_begin(bool /*clearNonColorBufs*/)
{
}
@@ -449,6 +454,7 @@ bool gr_stub_init()
// gr_screen.gf_shade = gr_stub_shade;
gr_screen.gf_print_screen = gr_stub_print_screen;
gr_screen.gf_blob_screen = gr_stub_blob_screen;
gr_screen.gf_zbuffer_get = gr_stub_zbuffer_get;
gr_screen.gf_zbuffer_set = gr_stub_zbuffer_set;
+13 -38
View File
@@ -15,6 +15,8 @@
#include "cmdline/cmdline.h"
#include "graphics/2d.h"
#include "lighting/lighting.h"
#include "lighting/lighting_profiles.h"
#include "math/bitarray.h"
#include "render/3d.h"
#include "util/uniform_structs.h"
@@ -24,7 +26,6 @@ struct gr_light
{
vec4 Ambient;
vec4 Diffuse;
vec4 Specular;
// light position
vec4 Position;
@@ -34,6 +35,7 @@ struct gr_light
float SpotCutOff;
float ConstantAtten, LinearAtten, QuadraticAtten;
float SourceRadius;
int type;
};
@@ -49,7 +51,7 @@ const float gr_light_color[4] = { 0.8f, 0.8f, 0.8f, 1.0f };
const float gr_light_zero[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
const float gr_light_emission[4] = { 0.09f, 0.09f, 0.09f, 1.0f };
float gr_light_ambient[4] = { 0.47f, 0.47f, 0.47f, 1.0f };
float gr_user_ambient = 0.0f;
void FSLight2GLLight(light* FSLight, gr_light* GLLight) {
GLLight->Ambient.xyzw.x = 0.0f;
@@ -62,11 +64,6 @@ void FSLight2GLLight(light* FSLight, gr_light* GLLight) {
GLLight->Diffuse.xyzw.z = FSLight->b * FSLight->intensity;
GLLight->Diffuse.xyzw.w = 1.0f;
GLLight->Specular.xyzw.x = FSLight->spec_r * FSLight->intensity;
GLLight->Specular.xyzw.y = FSLight->spec_g * FSLight->intensity;
GLLight->Specular.xyzw.z = FSLight->spec_b * FSLight->intensity;
GLLight->Specular.xyzw.w = 1.0f;
GLLight->type = static_cast<int>(FSLight->type);
// GL default values...
@@ -85,6 +82,7 @@ void FSLight2GLLight(light* FSLight, gr_light* GLLight) {
GLLight->Position.xyzw.y = FSLight->vec.xyz.y;
GLLight->Position.xyzw.z = FSLight->vec.xyz.z; // flipped axis for FS2
GLLight->Position.xyzw.w = 1.0f;
GLLight->SourceRadius = FSLight->source_radius;
switch (FSLight->type) {
@@ -93,9 +91,6 @@ void FSLight2GLLight(light* FSLight, gr_light* GLLight) {
GLLight->ConstantAtten = 1.0f;
GLLight->LinearAtten = (1.0f / MAX(FSLight->rada, FSLight->radb)) * 1.25f;
GLLight->Specular.xyzw.x *= static_point_factor;
GLLight->Specular.xyzw.y *= static_point_factor;
GLLight->Specular.xyzw.z *= static_point_factor;
break;
}
@@ -105,10 +100,6 @@ void FSLight2GLLight(light* FSLight, gr_light* GLLight) {
GLLight->LinearAtten = (1.0f / MAX(FSLight->rada, FSLight->radb)) * 1.25f;
GLLight->QuadraticAtten = (1.0f / MAX(FSLight->rada_squared, FSLight->radb_squared)) * 1.25f;
GLLight->Specular.xyzw.x *= static_tube_factor;
GLLight->Specular.xyzw.y *= static_tube_factor;
GLLight->Specular.xyzw.z *= static_tube_factor;
GLLight->Position.xyzw.x = FSLight->vec2.xyz.x; // Valathil: Use endpoint of tube as light position
GLLight->Position.xyzw.y = FSLight->vec2.xyz.y;
GLLight->Position.xyzw.z = FSLight->vec2.xyz.z;
@@ -130,10 +121,6 @@ void FSLight2GLLight(light* FSLight, gr_light* GLLight) {
GLLight->Position.xyzw.z = -FSLight->vec.xyz.z;
GLLight->Position.xyzw.w = 0.0f; // This is a direction so the w part must be 0
GLLight->Specular.xyzw.x *= static_light_factor;
GLLight->Specular.xyzw.y *= static_light_factor;
GLLight->Specular.xyzw.z *= static_light_factor;
break;
}
@@ -154,11 +141,10 @@ static void set_light(int light_num, gr_light* ltp) {
gr_light_uniforms[light_num].diffuse_color = vm_vec4_to_vec3(ltp->Diffuse);
gr_light_uniforms[light_num].spec_color = vm_vec4_to_vec3(ltp->Specular);
gr_light_uniforms[light_num].light_type = ltp->type;
gr_light_uniforms[light_num].attenuation = ltp->LinearAtten;
gr_light_uniforms[light_num].ml_sourceRadius = ltp->SourceRadius;
}
static bool sort_active_lights(const gr_light& la, const gr_light& lb) {
@@ -249,11 +235,6 @@ void gr_set_center_alpha(int type) {
}
glight.type = type;
glight.Specular.xyzw.x = 0.0f;
glight.Specular.xyzw.y = 0.0f;
glight.Specular.xyzw.z = 0.0f;
glight.Specular.xyzw.w = 0.0f;
glight.Ambient.xyzw.w = 1.0f;
glight.Diffuse.xyzw.w = 1.0f;
@@ -291,14 +272,6 @@ void gr_reset_lighting() {
Num_active_gr_lights = 0;
}
void gr_calculate_ambient_factor(int ambient_factor) {
if (gr_screen.mode == GR_STUB) {
return;
}
gr_user_ambient = (float) ((ambient_factor * 2) - 255) / 255.0f;
}
void gr_light_shutdown() {
gr_lights.clear();
}
@@ -308,8 +281,6 @@ void gr_light_init() {
return;
}
gr_calculate_ambient_factor();
// allocate memory for enabled lights
gr_lights.reserve(1024);
}
@@ -320,7 +291,6 @@ void gr_set_lighting() {
}
//Valathil: Sort lights by priority
extern bool Deferred_lighting;
if (!Deferred_lighting) {
pre_render_init_lights();
}
@@ -357,8 +327,13 @@ void gr_set_ambient_light(int red, int green, int blue) {
gr_light_ambient[1] = i2fl(green) / 255.0f;
gr_light_ambient[2] = i2fl(blue) / 255.0f;
gr_light_ambient[3] = 1.0f;
gr_calculate_ambient_factor();
}
void gr_get_ambient_light(vec3d* light_vector) {
auto abv = lighting_profile::current()->ambient_light_brightness;
auto over = lighting_profile::current()->overall_brightness;
light_vector->xyz.x = over.handle(abv.handle(gr_light_ambient[0]));
light_vector->xyz.y = over.handle(abv.handle(gr_light_ambient[1]));
light_vector->xyz.z = over.handle(abv.handle(gr_light_ambient[2]));
}
void gr_lighting_fill_uniforms(void* data_out, size_t buffer_size) {
+1 -3
View File
@@ -12,7 +12,6 @@ extern const float gr_light_color[4];
extern const float gr_light_zero[4];
extern const float gr_light_emission[4];
extern float gr_light_ambient[4];
extern float gr_user_ambient;
//Functions
void gr_set_light(light *fs_light);
@@ -20,8 +19,7 @@ void gr_reset_lighting();
void gr_set_lighting();
void gr_set_center_alpha(int type);
void gr_set_ambient_light(int red, int green, int blue);
void gr_calculate_ambient_factor(int ambient_factor = Cmdline_ambient_factor);
void gr_get_ambient_light(vec3d* light_vector);
void gr_lighting_fill_uniforms(void* data_out, size_t buffer_size);
+9 -41
View File
@@ -162,12 +162,12 @@ void material_set_rocket_interface(interface_material* mat_info,
mat_info->set_texture_type(material::TEX_TYPE_INTERFACE);
}
void material_set_movie(movie_material* mat_info, int y_bm, int u_bm, int v_bm) {
void material_set_movie(movie_material* mat_info, int y_bm, int u_bm, int v_bm, float alpha) {
mat_info->set_depth_mode(ZBUFFER_TYPE_NONE);
mat_info->set_blend_mode(ALPHA_BLEND_ALPHA_BLEND_ALPHA);
mat_info->set_cull_mode(false);
mat_info->set_color(1.0f, 1.0f, 1.0f, 1.0f);
mat_info->set_color(1.0f, 1.0f, 1.0f, alpha);
mat_info->setYtex(y_bm);
mat_info->setUtex(u_bm);
@@ -653,33 +653,6 @@ bool model_material::is_batched() const
return Batched;
}
void model_material::set_normal_alpha(float min, float max)
{
Normal_alpha = true;
Normal_alpha_min = min;
Normal_alpha_max = max;
}
void model_material::set_normal_alpha()
{
Normal_alpha = false;
}
bool model_material::is_normal_alpha_active() const
{
return Normal_alpha;
}
float model_material::get_normal_alpha_min() const
{
return Normal_alpha_min;
}
float model_material::get_normal_alpha_max() const
{
return Normal_alpha_max;
}
void model_material::set_fog(int r, int g, int b, float _near, float _far)
{
Fog_params.enabled = true;
@@ -760,7 +733,7 @@ uint model_material::get_shader_flags() const
Shader_flags |= SDR_FLAG_MODEL_ANIMATED;
}
if ( get_texture_map(TM_BASE_TYPE) > 0 && !Basemap_override ) {
if ( get_texture_map(TM_BASE_TYPE) > 0) {
Shader_flags |= SDR_FLAG_MODEL_DIFFUSE_MAP;
}
@@ -768,19 +741,18 @@ uint model_material::get_shader_flags() const
Shader_flags |= SDR_FLAG_MODEL_GLOW_MAP;
}
if ( (get_texture_map(TM_SPECULAR_TYPE) > 0 || get_texture_map(TM_SPEC_GLOSS_TYPE) > 0) && !Specmap_override ) {
if ( get_texture_map(TM_SPECULAR_TYPE) > 0 || get_texture_map(TM_SPEC_GLOSS_TYPE) > 0 ) {
Shader_flags |= SDR_FLAG_MODEL_SPEC_MAP;
if ( (ENVMAP > 0) && !Envmap_override ) {
Shader_flags |= SDR_FLAG_MODEL_ENV_MAP;
}
}
if ( (ENVMAP > 0) && !Envmap_override ) {
Shader_flags |= SDR_FLAG_MODEL_ENV_MAP;
}
if ( (get_texture_map(TM_NORMAL_TYPE) > 0) && !Normalmap_override ) {
if ( get_texture_map(TM_NORMAL_TYPE) > 0 ) {
Shader_flags |= SDR_FLAG_MODEL_NORMAL_MAP;
}
if ( (get_texture_map(TM_HEIGHT_TYPE) > 0) && !Heightmap_override ) {
if ( get_texture_map(TM_HEIGHT_TYPE) > 0 ) {
Shader_flags |= SDR_FLAG_MODEL_HEIGHT_MAP;
}
@@ -816,10 +788,6 @@ uint model_material::get_shader_flags() const
Shader_flags |= SDR_FLAG_MODEL_THRUSTER;
}
if ( Normal_alpha ) {
Shader_flags |= SDR_FLAG_MODEL_NORMAL_ALPHA;
}
if ( uses_thick_outlines() ) {
Shader_flags |= SDR_FLAG_MODEL_THICK_OUTLINES;
}
+1 -11
View File
@@ -196,10 +196,6 @@ class model_material : public material
bool Team_color_set = false;
team_color Tm_color;
bool Normal_alpha = false;
float Normal_alpha_min = 0.0f;
float Normal_alpha_max = 1.0f;
fog Fog_params;
float Outline_thickness = -1.0f;
@@ -243,12 +239,6 @@ public:
int get_animated_effect() const;
float get_animated_effect_time() const;
void set_normal_alpha(float min, float max);
void set_normal_alpha();
bool is_normal_alpha_active() const;
float get_normal_alpha_min() const;
float get_normal_alpha_max() const;
void set_outline_thickness(float thickness = -1.0f);
float get_outline_thickness() const;
bool uses_thick_outlines() const;
@@ -371,7 +361,7 @@ void material_set_unlit_color(material* mat_info, int texture, color *clr, bool
void material_set_unlit_color(material* mat_info, int texture, color *clr, float alpha, bool blending, bool depth_testing);
void material_set_unlit_volume(particle_material* mat_info, int texture, bool point_sprites);
void material_set_distortion(distortion_material *mat_info, int texture, bool thruster);
void material_set_movie(movie_material *mat_info, int y_bm, int u_bm, int v_bm);
void material_set_movie(movie_material *mat_info, int y_bm, int u_bm, int v_bm, float alpha = 1.0f);
void material_set_batched_bitmap(batched_bitmap_material* mat_info, int base_tex, float alpha, float color_scale);
void material_set_batched_opaque_bitmap(batched_bitmap_material* mat_info, int base_tex, float color_scale);
void material_set_nanovg(nanovg_material* mat_info, int base_tex);
Loaded 100 of 755 files, more files were not shown because too many files have changed in this diff. Show more