Compare commits

...
1461 Commits
Author SHA1 Message Date
chief1983 fc5a74a911 FINAL BUILD STAGE COMMIT: Sets Revision and Version properties to this commit version. 2012-10-23 07:07:43 +00:00
Goober5000 37c469ea84 Backport: Trunk 9271; fix for Mantis #2643 (generated shield quadrants displayed in the wrong spots) 2012-10-16 03:23:01 +00:00
Goober5000 f09e4dd328 Backport: Trunk 9268; add arrival_delay and departure_delay arguments to set-arrival-info and set-departure-info 2012-10-16 02:42:45 +00:00
Zacam 37252782bd RC9 BUILD STAGE COMMIT: Sets Revision and Version properties to this commit version. 2012-10-07 19:46:05 +00:00
Goober5000 544d90710e better preprocessor logic, as suggested by niffiwan 2012-10-03 03:06:55 +00:00
Goober5000 2123a62d21 MSVC6 compatibility 2012-10-01 05:44:44 +00:00
Goober5000 b561c627ce Backport: Trunk 9234; Fixed attempted reinitialization of collision pairs. Need to use OBJ_INDEX(objp), not objp->instance as that refers to the ship index, not the object index. 2012-10-01 03:28:08 +00:00
Goober5000 245e876558 Backport: Trunk 9226; Fix for Mantis 2709: Use the correct dimensions for updating texture images when texture streaming to fix crashes on hardware not capable of handling non power of 2 texture dimensions 2012-10-01 03:26:12 +00:00
Goober5000 89a81a4025 Backport: Trunk 9221; play-sound-from-table should work for both 3d and non-3d sounds 2012-10-01 03:25:00 +00:00
Goober5000 c20285d58e Backport: Trunk 9197; Fixes mantis 2711. AudioStream handles are leaked under certain conditions. / AudioStream handles that were to destroy and fade would not if the stream was already finished or not started. 2012-10-01 03:23:31 +00:00
chief1983 7a57db09ba RC8 BUILD STAGE COMMIT: Sets Revision and Version properties to this commit version. 2012-08-28 16:14:14 +00:00
chief1983 d005f0ec2f Backport: Trunk r9143; make red-alert not dependent on whether the HUD is visible or not (fixes Mantis #2683) 2012-08-28 15:54:41 +00:00
chief1983 7f2ae7551e Revert backport of r8848. 2012-08-27 22:46:00 +00:00
chief1983 af8d267ebe Backport: Trunk r9130; variable tokens can be quite a bit longer than standard tokens due to their unusual format; handle this properly (fixes Mantis #2670) 2012-08-22 20:01:40 +00:00
chief1983 a26d042e7a Backport: Trunk r9127; Adding nameplate textures to the list of texture names that trigger the transparency renderer. 2012-08-22 20:00:27 +00:00
chief1983 377d572863 Backport: The remaining changes in r9113, since most had been committed in 9054, and the rest is also known as mantis_2266_take3_followup.patch from Mantis 2266. 2012-08-22 19:59:21 +00:00
The_E 10845127c2 Backport trunk 9109/9112/9118: More efficient handling of ani ressources, fixes ani stuttering. Also allows EFF files as head anis. 2012-08-22 19:11:24 +00:00
chief1983 c7054d51fc Backport: Trunk r9095; fix for Mantis #2694: homing breaks when free_flight_time is 0; also, correctly set default free_flight_time to retail value of 0.5 second 2012-08-22 18:07:29 +00:00
chief1983 c938af26fa Backport: Trunk r9080/9081; Prevent garbage collection of texture handles which still have a non-zero load count. 2012-08-22 17:04:19 +00:00
The_E aa7ed66c64 Backport of trunk revision 9077: Remove a define from the builtin shader that was causing clipping issues now that AMD has fixed their driver's behaviour 2012-07-31 17:10:22 +00:00
Zacam 960cf37070 RC7 BUILD STAGE COMMIT: Sets Revision and Version properties to this commit version. 2012-07-25 03:41:04 +00:00
Zacam e237557a31 Mantis 2266: Take3 RC Branch Patch for "dense soundscapes cause sounds to intermittently not play." Patch by IssMneur. 2012-07-25 03:08:50 +00:00
Zacam 7d27e1d5e9 Backport: Trunk r9052; Fix 4 for #2590: don't use "j" when its value could be greater than the array size - thanks to Zacam & Goober for finding this 2012-07-25 02:56:54 +00:00
Zacam b69144e56b Revert Backport's of r8910/9026/9031. 2012-07-24 03:50:45 +00:00
Zacam 9b03888d39 Backport: Trunk r9027; [Modified] update SCP credits 2012-07-24 03:31:11 +00:00
Zacam cbca7ab34b Backport: Trunk r9031; Fixed glow points in the Tech Room. 2012-07-24 03:21:22 +00:00
Zacam 4452762786 Backport: Trunk r9026; Corrected glow point directional attenuation. Need to use world coordinates of glow points, not local. 2012-07-24 03:19:54 +00:00
Zacam e006ad7ade Backport: Trunk r8910; Changing glowpoint rendering from being a separate step during model rendering to being a part of the batch renderer. This makes glowpoint rendering much faster. (Required for r9026/r9031 backports) 2012-07-24 03:19:20 +00:00
Zacam 7a8da470b8 Backport: Trunk r9018; prevent ships with mismatched models and tables from causing crashes later on (Mantis #2689) 2012-07-24 03:11:11 +00:00
Zacam 336d4abf37 Backport: Trunk r9015; add four useful sexps: set-arrival-info, set-departure-info, set-debriefing-toggled, set-subspace-drive
also, fix a hole in the oswpt routine (and a few sexps) dealing with wings that weren't present yet
2012-07-24 03:09:43 +00:00
Zacam fc3fbdd1e5 Backport: Trunk r9014; this really ought to be a Warning, not an Error 2012-07-24 03:08:53 +00:00
Zacam d30f89bb01 Backport: Trunk r9010; check to make sure a wing that has a player does not also have an arrival delay (Mantis #2678) 2012-07-24 03:08:07 +00:00
Zacam 0cb744487e Backport: Trunk r9009; Target direction arrow properly disappears when target is placed under reticle. Fixes Mantis 2504. 2012-07-24 03:07:15 +00:00
Zacam 7f7a6decb8 Backport: Trunk 9004; add the mission cutscene save type, per Karajorma and MjnMixael 2012-07-24 03:06:19 +00:00
Zacam 516a8c68ee Backport: Trunk r9003; in the interest of avoiding mysterious and subtle differences in AI behavior, restore retail behavior where:
a) the player's wing forms on him at mission start
b) wings in the Starting_wings list will form on the player if they arrive later in the mission
c) no other wing automatically forms on its leader
2012-07-24 02:23:44 +00:00
Zacam 28b733738c Backport: Trunk r9002; also revert the "nohtl" part of r8977 for FRED (Mantis #2676) because no-HTL models shouldn't use HTL rendering 2012-07-24 02:15:20 +00:00
Zacam 966735a65b Backport: Trunk r9001; revert r8975 because this fix adds unwanted diagonal lines to the jump node model (Mantis #2396) 2012-07-24 02:14:44 +00:00
Zacam a5560a59c9 Backport: Trunk r9000; niffiwan's fix for Mantis #2681 2012-07-24 02:13:07 +00:00
Zacam 7db44e0177 Backport: Trunk 8999; Fix for Mantis 2682: extra glowpoints are rendered for targeted ships 2012-07-24 01:39:59 +00:00
Zacam c98504da11 Backport: Trunk 8995; Fix number 3 for mantis #2590 - move array overflow detection to correct place in loops 2012-07-24 01:37:42 +00:00
chief1983 ad007cfe0c Backport Xcode4 project from trunk, removing the mod_table files from the project. 2012-07-09 18:38:24 +00:00
Goober5000 4dcc6da75f Manual backport due to differing implementation: Trunk r8982; replace variables in recommendations too 2012-07-04 20:08:57 +00:00
Zacam c6b4b79c2f Backstep: Reverting Backport of Trunk r8982 which in trunk operates on the SCP_STringification which was not backported. 2012-07-04 19:59:47 +00:00
Zacam 82d36d5f1f Backport: Trunk r8982; replace variables in recommendations too 2012-07-04 19:53:43 +00:00
Zacam 10ede3185f Backport: Trunk r8979; Linux release compilation back to using -Wall, but with -Wno-write-strings 2012-07-04 19:52:16 +00:00
Zacam b8331e7216 Backport: Trunk r8978; fix a rather important variable initialization
(follow-up to r8967)
2012-07-04 19:51:42 +00:00
Zacam 2fe257afca Backport: Trunk r8977; this is the equivalent of r8975 for FRED (Mantis #2676) 2012-07-04 19:51:14 +00:00
Zacam 6fdc81cd88 Backport: Trunk r8976; attacking a protected target will remove its protected flag, so don't allow this if hit by EMP
(Mantis #2192)
2012-07-04 19:50:42 +00:00
Zacam af09318d24 Backport: Trunk r8975; Zacam's fix for Mantis #2396 2012-07-04 19:50:13 +00:00
Zacam c22a0697f8 Backport: Trunk r8974; fix for Mantis #2179, proper afterburner shutdown 2012-07-04 19:48:33 +00:00
Zacam f1df0c31db Backport: Trunk r8972; fix Mantis #1972: hotkey brackets are drawn around stealth ships 2012-07-04 19:48:02 +00:00
Zacam 6a1b6638fc Backport: Trunk r8971; fix TD2192...
[derp, wrong game]
fix Mantis #2192, EMP brings play-dead fighters back to life
2012-07-04 19:47:18 +00:00
Zacam a5776e277c Backport: Trunk r8968; CommanderDJ's set-player-throttle-speed 2012-07-02 02:51:52 +00:00
Zacam b8cc620079 Backport: Trunk r8967; wings that are initially docked will now arrive in mission correctly 2012-07-02 02:51:11 +00:00
Zacam 1b7c9b2f8d Backport: Trunk r8917; fix for Mantis #2673, following Valathil's detective work 2012-07-02 01:46:24 +00:00
Zacam bc20b94cde Backport: Trunk r8914/8918/8921/8922/8923/8924;
fix the old Volition bug where a docked ship would execute its default behavior even when the preceding comment explicitly said that it should "just sit here" :-/
also guard against a few edge cases related to this (Mantis 945)
this should fix all of the issues with docked fighters and bombers (Mantis 945)
looks like this was never actually implemented!
add more error checking for initially docked ships, per Mantis (Mantis 1658)
make the dock leader code more robust, and make FRED mark dock leaders in wings correctly
follow-up to r8922: this part isn't actually a problem
2012-07-02 01:45:47 +00:00
Zacam aa497aa236 Backport: Trunk r8912; CommanderDJ's fix for Mantis #2628 2012-07-02 01:30:11 +00:00
Zacam 1fba5a9bd4 Backport: Trunk r8909; Fix for Mantis 2671: Skip submodels that have been blown off in ship-ship collisions. 2012-07-02 01:29:39 +00:00
Zacam 69c54645b6 Backport: Trunk r8904; No warnings for release linux builds. 2012-07-02 01:29:03 +00:00
Zacam bb5fc833d4 Backport: Trunk r8903/8906/8911; Fix for Mantis 2670: Truncate tokens to their maximum length and pop up a MessageBox for the user.
Fix for Mantis 2670: Followup: Fix the bug without breaking mission parsing.
fine-tune Valathil's error message
2012-07-02 01:28:34 +00:00
Zacam e505e84f95 Backport: Trunk r8902; synchronize the ship classes that evade shockwaves
(this fixes Mantis #2548)
2012-07-02 01:27:03 +00:00
Zacam ed65937afc Backport: Trunk r8901; restore retail behavior for chaining by reverting r8603 -- this fixes Mantis #2667
also add descriptive comment in header file
2012-07-02 01:26:25 +00:00
Zacam d4cb17531c Backport: Trunk r8900; Fix for mantis #2666: call the new HUD renderBitmap function for the red alert notification background image 2012-07-02 01:25:42 +00:00
Zacam 2af7151592 Backport: Trunk r8899; From CommanderDJ: Fix for Mantis 2657 (Alt-Shift-E does not clear escort list) 2012-07-02 01:25:04 +00:00
Zacam ffd4142864 Backport: Trunk r8894; since the if() block already checks for a specific gauge type, we can safely do the static_cast 2012-07-02 01:24:29 +00:00
Zacam 73a048c92f Backport: Trunk r8892; Fix for Mantis 2665: Include Player Ship's in the search for valid Message Sources 2012-07-02 01:23:42 +00:00
Zacam 35b1cb383f Backport: Trunk r8871; Fix for Mantis 2631: Take the main hall of first mission of the fallback campaign as the current one and save the campaign to the pilot struct. 2012-07-02 01:22:55 +00:00
Zacam 0a2ffe7653 Backport: Trunk r8869; Valathil's fix for Mantis #2652 2012-07-02 01:22:20 +00:00
Zacam f91c78d7a7 Backport: Trunk r8456/8866/8867/8868; Made subsystems contain an objnum reference to their parent ship.
fix some aspects of homing (pun not intended), including hopefully Mantis #2652
remove the vestiges of free_flight_time, which never worked
remove the unnecessary null sets
2012-07-02 01:21:44 +00:00
Zacam cfa67a5390 Backport: Trunk r8865; parentheses are A-1 SUPAR 2012-07-02 01:18:52 +00:00
Zacam 77c1a903ee Backport: Trunk r8848; Mastadon's fix to make auto-target pick the nearest enemy ship instead of the nearest ship attacking the player. 2012-07-02 01:17:58 +00:00
Zacam 442837521f Backport: Trunk r8847; From CommanderDJ: Fix for Mantis 2663 (hud-set-color only works once per mission) 2012-07-02 01:16:29 +00:00
Zacam 8e20c8f780 Backport: Trunk r8845; As requested and tested by VA, bumping MAX_INSTANCE_DEPTH to 10 2012-07-02 01:15:09 +00:00
Zacam 8579209137 Backport: Trunk r8844; Fix Evil Turret Bug of Doom. :) 2012-07-02 01:13:42 +00:00
Zacam 0a73016391 Backport: Trunk r8830; Mantis 2419: add a new ETS gauge that behaves like the retail one 2012-07-02 01:12:29 +00:00
Zacam 97819f8ee5 Backport: Trunk r8813; fix for Mantis #2117 (dock names with trailing spaces cause errors) 2012-07-02 01:11:14 +00:00
Zacam a3454349e6 Backport: Trunk r8812; restrict multi-editing for Mantis #1681 2012-07-02 01:10:30 +00:00
Zacam 2b0d7fdaa8 Backport: Trunk r8807; if a movie fails to play, give back the mouse cursor 2012-07-02 01:07:52 +00:00
Zacam 5b9f250861 Backport: Trunk r8806; restore code that was inadvertently deleted, fixing Mantis #2478 2012-07-02 01:07:16 +00:00
Zacam 5f934f28dd Backport: Trunk r8805; Documentation for head-ani's && messages 2012-07-02 01:06:11 +00:00
Zacam fcde91a42c Backport: Trunk r8804; GCC: remove trivial warning: multi-line comment [-Wcomment] 2012-07-02 01:05:27 +00:00
Zacam 182af9fea9 Backport: Trunk r8803; save a tiny amount of RAM when creating BMP_AABITMAP bitmaps 2012-07-02 01:04:53 +00:00
Zacam 170e04ebd0 Backport: Trunk r8802; Fix for mantis 2655: play messages at least until head ani finishes 2012-07-02 01:04:21 +00:00
Zacam eee6f49bf8 Backport: Trunk r8801; Fix for mantis 2411: allow repeated messages to play head anis 2012-07-02 01:03:41 +00:00
Zacam 795e2fbe67 Backport: Trunk r8795; Niffiwan's fix for 2590 seems to have introduced a bug of it's own. Easy enough to fix it though. 2012-07-02 01:02:07 +00:00
Zacam 8f164bcdc7 Backport: Trunk r8789; From jg18: Allow FSO to actually fetch the max anisotropy value rather than hard capping at 2.0. 2012-07-02 01:01:14 +00:00
Zacam 69c9935ffa Backport: Trunk r8788; Fixes #2624. The sound environment should now track the camera correctly. 2012-07-02 01:00:31 +00:00
Zacam 3e3f0691f1 Backport: Trunk r8784/8785/8786; add capability to specify different nested default colors
make the closing color span brace be $} instead of $c}
if we are ignoring whitespace and we encounter a newline, don't eat it
2012-07-02 00:59:43 +00:00
Zacam fbd217ee3a Backport: Trunk r8782: other people than me deprecate sexps now 2012-07-02 00:57:48 +00:00
Zacam b38d9b0704 Backport: Trunk r8773; supernova-stop sexp, written by CommanderDJ 2012-07-02 00:56:56 +00:00
Zacam 7b2a349ee0 Backport: Trunk r8772/8870; Partial fix for 2410: Fixes Directive gauge ignoring hud-disable-except messages
Fix for last bit of mantis #2410: show training messages when hud-disabled-except-messages
2012-07-02 00:55:58 +00:00
Zacam 00dc14be96 Backport: Trunk r8771; Fix for Mantis 2606: Local SSMs fired in swarm may cause propagating NaN errors 2012-07-02 00:52:53 +00:00
Zacam c4e5640893 Backport: Trunk r8758; From CommanderDJ: Fix for mantis #0002646 2012-07-02 00:52:02 +00:00
Zacam e00f3c8c58 Backport: Trunk r8751; Change this little piece of code to avoid a potentially very baffling null pointer dereference later on 2012-07-02 00:51:02 +00:00
Zacam 54e9a7bbab Backport: Trunk r8740/8741; Use CLAMP utility macro in lighting.cpp 2012-07-02 00:50:01 +00:00
Zacam a403887a90 Backport: Trunk r8696; Fix a bug that caused bombs to be indestructible by the player for much longer than they should be according to the table settings given. 2012-07-02 00:48:19 +00:00
niffiwan 61b584cef6 RC6 BUILD STAGE COMMIT (Take 2): Sets Revision and Version properties to this commit version. 2012-05-03 10:56:58 +00:00
niffiwan 4f92dae237 RC6 BUILD STAGE COMMIT: Sets Revision and Version properties to this commit version. 2012-05-03 10:53:17 +00:00
niffiwan 4a0e043cc3 Update 8592 to not use a SCP_string and to use vsnprintf to avoid a buffer overrun 2012-05-03 10:53:09 +00:00
niffiwan 7e6c86d8aa Backport: Trunk r8695; Fix the bug in closing the event editor that caused it to take minutes with some missions rather than seconds. 2012-05-03 10:53:02 +00:00
niffiwan 61f908268e Revert "Backport: Trunk r8686; Fix Mantis 2642: Cockpits are rendered incorrectly when post-processing is disabled, thanks m_m"
Depends on other non-backported commits

This reverts commit cdb713f15a75169ee1352aad2bae5d84951e53a6.
2012-05-03 10:52:54 +00:00
niffiwan 43ed5dd385 Backport: Trunk r8686; Fix Mantis 2642: Cockpits are rendered incorrectly when post-processing is disabled, thanks m_m 2012-05-02 11:38:59 +00:00
niffiwan 5b01e4d387 Backport: Trunk r8681; These two variables were missed; the sort of overlooked error that is easy with this odd method of copy constructing... 2012-05-02 11:38:53 +00:00
niffiwan 83922f6c0d Backport: Trunk r8670; fix for Mantis #2630
(LUA is not mentioned, but the problem might affect that too)
2012-05-02 11:38:45 +00:00
niffiwan 6328aa6a78 Backport: Trunk r8662; warning C6280: 'tmp_Player' is allocated with 'new', but deleted with 'free' 2012-05-02 11:38:38 +00:00
niffiwan 0f10e80cd9 Backport: Trunk r8652; MSVC Analyze warning fix: Incorrect type passed as parameter in call to function printf() 2012-05-02 11:38:32 +00:00
niffiwan c880ad1634 Backport: Trunk r8649; Fix Mantis 2632: Sounds assigned to objects get dropped when limit hardcoded gets reached. Patch from m_m 2012-05-02 11:38:25 +00:00
niffiwan 00fc4382c0 Backport: Trunk r8642; Fix Doxygen documentation for wl_draw_ship_weapons() 2012-05-02 11:38:18 +00:00
niffiwan 6c30105602 Backport: Trunk r8641; PVS-Studio fix: The 'Player' pointer is used simultaneously as an array and as a pointer to single object. 2012-05-02 11:38:12 +00:00
niffiwan 3042a805d4 Backport: Trunk r8640; PVS-Studio fix: The 'Players' pointer is used simultaneously as an array and as a pointer to single object. Check lines: 1392, 1410. 2012-05-02 11:38:06 +00:00
niffiwan 9adb70e863 Backport: Trunk r8639; PVS-Studio fix: The 'Weapon_info' pointer is used simultaneously as an array and as a pointer to single object. Check lines: 2962, 2975. 2012-05-02 11:38:00 +00:00
niffiwan 5fb5f58dbb Backport: Trunk r8643 + r8644; Fix for Mantis 2635: Invalid memory access when saving a mission due to a weapon bank set to empty. && Same for secondary weapons 2012-05-02 11:37:53 +00:00
niffiwan e4228f9b2b Backport: Trunk r8630; revision 8155 inadvertently made ALL weapons area-effect... so don't add an automatic inner radius (for Mantis #2634) but still be careful about potential divide-by-zero 2012-05-02 11:37:47 +00:00
niffiwan 76f4e460e4 Backport: Trunk r8628; Gliding bugfix: only "decay" glide speed when actually thrusting. 2012-05-02 11:37:41 +00:00
niffiwan 2b3c446f26 Backport: Trunk r8618; Fix a rather unhelpfully vague piece of the SEXP documentation. 2012-05-02 11:37:34 +00:00
niffiwan c54053535f Backport: Trunk r8614 + r8615 + r8619; Allowed hud-set-directive and hud-set-message to set custom gauge text up to MESSAGE_LENGTH instead of NAME_LENGTH. && Added hud-clear-messages. Clears active messages currently displayed. && considering that both the HUD and sexp_replace_variable_names_with_values work with SCP_string, just use SCP_string directly and remove the character limit
also, MESSAGE_LENGTH isn't 32 characters
2012-05-02 11:37:26 +00:00
niffiwan 6ea6b82db1 Backport: Trunk r8610; Fix for Mantis 2629: PVS-Studio warning: The variable j is being used for this loop and for the outer loop. (controlsconfig.cpp 1613) 2012-05-02 11:37:19 +00:00
niffiwan aad3b1c0e8 Backport: Trunk r8603; Well I find it hard to believe that in over eight years three senior SCP coders couldn't find THAT!
Fix Mantis 0082 (Repeat count sexp does not work reliably)
2012-05-02 11:37:13 +00:00
niffiwan 7467cd5537 Backport: Trunk r8602 + r8613; Reorder setting of filename in game init to stop missions crashing in load screen && Update to 8602 - an even simpler fix 2012-05-02 11:37:06 +00:00
niffiwan 5f1a5b3120 Backport: Trunk r8596 + r8597; From Echelon9, fix for mantis #0002621 && fix a derp by Echelon9 (local variable was hiding the member field) 2012-05-02 11:37:00 +00:00
niffiwan d128b00be0 Backport: Trunk r8592; per discussion with mjn.mixael, fix error function so that it doesn't break on messages that are too long 2012-05-02 11:36:54 +00:00
niffiwan 62c4963276 Backport: Trunk r8585; Fix for Mantis #0002604: using m_m's patch, allow swarm/corkscrew bank to keep firing if current bank changes 2012-05-02 11:36:47 +00:00
niffiwan 18d5980178 Backport: Trunk r8579; Fix for Mantis 2619: Adds .png to FRED's list of recognized file formats for loading screens. 2012-05-02 11:36:40 +00:00
niffiwan 62ecc849ac Backport: Trunk r8577; From casual_pilot: Fix for Mantis 2395 (incorrect index values passed to OpenGL) 2012-05-02 11:36:33 +00:00
niffiwan 3f683496d3 Backport: Trunk r8563; Fix for Mantis 2327 - Strange behavior with key-press, patch from Eli2 2012-05-02 11:36:26 +00:00
niffiwan 03d9ffcbdc Backport: Trunk r8562; Fix for Mantis 2616 - Lua forward controls don't get applied to player controls, patch by m_m 2012-05-02 11:36:18 +00:00
niffiwan d9b05259bf Backport: Trunk r8561 + r8565; PVS-Studio fixes: Resolve some warnings about use of pointers before checking for a null pointer && partial revert of 8561: vm_malloc should never return null, so the Assert is necessary, and will immediately flag the error as it happens instead of leaving a mine to be triggered later 2012-05-01 12:27:25 +00:00
niffiwan 680907778e Backport: Trunk r8554; const correctness for fhash 2012-05-01 12:27:18 +00:00
niffiwan 8d9c3833b8 Backport: Trunk r8552; Fix Mantis 2620 - PVS-Studio warning: Consider inspecting the '(strlen(filename) > 6)' expression. A 5 year old bug. 2012-05-01 12:27:12 +00:00
niffiwan 97a9146ebc Backport: Trunk r8551; PVS Studio fix: The conditional expressions of the 'if' operators situated alongside each other are identical (aicode.cpp) 2012-05-01 12:27:05 +00:00
niffiwan fdb68fdc8b Backport: Trunk r8550 + r8553; fix compilation for MSVC6 && this is a fix that doesn't require #including another file 2012-05-01 12:26:58 +00:00
niffiwan 2998e9e54f Backport: Trunk r8459; stdint.h and inttypes.h moved, and let's fix some paths that VC6 botched up for us again. 2012-05-01 12:26:51 +00:00
niffiwan 7a80419d17 Backport: Trunk r8545; change stuff_vector to stuff_vec3d for clarity, since "vector" now refers to a dynamic list and "vec3d" now refers to the three-float struct 2012-05-01 12:26:44 +00:00
niffiwan 5c46b2530a Backport: Trunk r8543; Fix a bug where placing the host in team 2 of a TvT mission would cause the clients to crash out. 2012-05-01 12:26:37 +00:00
niffiwan 7e679a2272 Backport: Trunk r8540; Related to Mantis 2617 - there is no way this is correct, now we have a properly functioning constructor for mc_info 2012-05-01 12:26:30 +00:00
niffiwan 75e0b54f1c Backport: Trunk r8539; Fix Mantis 2617: LLVM warning: argument to 'sizeof' in 'memset' call is the same expression as the destination; did you mean to dereference it? 2012-05-01 12:26:24 +00:00
niffiwan 505b701fd7 Backport: Trunk r8536; Fix ignore-keys not blocking joystick or mouse buttons. (Mantis 2611) 2012-05-01 12:26:17 +00:00
niffiwan 1b9de12ad6 Backport: Trunk r8533; Fix for Mantis 2614: Remove that statement, it works fine without exponentiating the offset. 2012-05-01 12:26:11 +00:00
niffiwan 115d5aa3b8 Backport: Trunk r8532; Forgot newlines 2012-05-01 12:26:05 +00:00
niffiwan 5037612651 Backport: Trunk r8531; Deprecating stuff: Good. Printing messages to the log: Good. Using Warning() instead of mprintf(): Bad. 2012-05-01 12:25:58 +00:00
niffiwan 46a91c4128 Backport: Trunk r8523; Fixed a few typos in scripting documentation. 2012-05-01 12:25:51 +00:00
chief1983 f05252fba4 RC5 BUILD STAGE COMMIT (Take 3): Sets Revision and Version properties to this commit version. Also fix a typo I made in fred.rc 2012-02-20 21:21:54 +00:00
Zacam e9688af867 RC5 BUILD STAGE COMMIT (Take 2): Sets Revision and Version properties to this commit version. 2012-02-19 19:20:09 +00:00
Zacam 86b5b2f1f2 Backport: Trunk r8519; Fix for 8515: Need to init Use_GLSL earlier 2012-02-19 19:17:29 +00:00
chief1983 b570391a11 RC5 BUILD STAGE COMMIT: Sets Revision and Version properties to this commit version. 2012-02-17 19:57:53 +00:00
Zacam 0ba13f58e3 Backport: Trunk r8512; Fixes GLSL detection to switch off GLSL support if reported GLSL version is below 1.2 2012-02-16 13:02:46 +00:00
chief1983 11c2bec249 Backport: Trunk 8505; From CommanderDJ, fix for mantis #0002601: create constructor for player struct 2012-02-15 16:11:18 +00:00
Zacam 04287f31e6 According to zookeeper, Trunk r8446 relies also on Trunk r8292 and as such, should not have been backported on its own (which is causing GCC complaints). Reverting the Backport until further discussion. 2012-02-15 09:31:21 +00:00
Zacam c7b811646b Backport: Trunk r8507; Reported by ni1s: GCC complaint about missing .c_str() in the updated dynamic MAX_SHIELD_ICON dynamic change. 2012-02-15 08:00:02 +00:00
Zacam 37885df34e Backport: Trunk r8465; Proper way to fix what was attempted in r8439. (Makes subsystem targeting brackets always get drawn in the right place in the targeting box.) 2012-02-14 01:08:35 +00:00
Zacam 113136af3b Backport: Trunk r8459; Fix for Mantis 2603: Fullscreen_window window not centered. 2012-02-14 01:07:38 +00:00
Zacam 706714f73a Backport: Trunk r8452; From CommanderDJ: Makes MAX_SHIELD_ICONS dynamic 2012-02-14 01:06:35 +00:00
Zacam 32e72658be Backport: Trunk r8450; Mantis #2524 2012-02-14 01:05:44 +00:00
Zacam ad90167396 Backport: Trunk r8447; Fixed the annoying OpenAL error messages in the log. AL_DOPPLER_FACTOR is only valid for alGet. Changed all instances to the correct alDopplerFactor. 2012-02-14 01:04:51 +00:00
Zacam b129927404 Backport: Trunk r8446; Slightly relocated the triggering of $On Turret Fired hooks as well as the setting of a few weapon variables. Makes sure that the variables only get set when a weapon is actually created and that all the weapon variables have been set before the hook is triggered. 2012-02-14 01:04:08 +00:00
Zacam 583c9ac6ee Backport: Trunk r8444; Minor optimization when rendering tris that do not use distortion effects and therefore do not require calling glDrawBuffers. 2012-02-14 01:03:19 +00:00
Zacam 1917578c82 Backport: Trunk r8443; Fixed Mantis 2413. hud-set-color changes to the HUD will no longer reset when pausing or entering options menu. Introduced Color entry fields for hud_gauges.tbl. 2012-02-14 01:02:35 +00:00
Zacam 96d35f010a Backport: Trunk r8442; Fix for mantis #0002597: fix some GCC compiler warnings 2012-02-14 01:01:34 +00:00
Zacam 0313a452fa Backport: Trunk r8441; Removed configOverride from HudGauge class since we don't even use it. 2012-02-14 01:00:50 +00:00
Zacam 5de995b5dd Backport: Trunk r8437 + r8438; Makes the $AliveSnd, $DeadSnd and $RotationSnd entries for subsystems work. NOTE: This will apparently not work correctly for nested subsystems. && Make the OS_SUBSYS_ROTATION sound depend on the SSF_ROTATES flag 2012-02-14 00:59:56 +00:00
Zacam b0452f08f2 Backport: Trunk r8436; Removing superfluous SSM alert message spawning. 2012-02-14 00:58:51 +00:00
Zacam f54f348f19 Backport: Trunk r8432; Make $FlyBySnd actually do something and allow primaries as well. 2012-02-14 00:58:12 +00:00
Zacam 4530f04484 Backport: Trunk r8427; Fix for mantis #0002593: structs containing vectors don't like being memset to zero... 2012-02-14 00:57:17 +00:00
Zacam 14c708be24 Backport: Trunk r8426; Fix for Mantis 2534: Separate Warp IN and OUT when checking if the thrusters are behind the clip plane and don't do any checks for the "Hyperspace" warp type 2012-02-14 00:56:29 +00:00
Zacam 84dee408ad Backport: Trunk r8423 + 8424; Given how often the particle shaders are called, moving them up to the beginning of the shaders array makes sense. && Add a random offset to the thruster distortion to make thruster clusters look better. 2012-02-14 00:55:44 +00:00
Zacam 1601a5b270 Backport: Trunk r8418 + r8419 + r8449; Fix for Mantis 2588: Messages without voice files now show the target brackets for at least "Message Length" * 100ms && 100ms was perhaps a bit too long. The answer is, of course, 42. Wait, what was the question...? && Don't wait for brackets for messages without a target. 2012-02-14 00:53:48 +00:00
Zacam 60ea1c4f7f Backport: Trunk r8417 + r8420; From Swifty: Alternative fix to the font distortion problem by glyph realignment at the font creation phase rather than by manipulating the draw stage. http://www.hard-light.net/forums/index.php?topic=79807.0 && Apologies to Swifty, this line change got truncated from the Font Fix. 2012-02-14 00:52:07 +00:00
Zacam 6eeb7e5c0c Backport: Trunk r8416; Fix for the Fix for Mantis #2374: Had only updated the Effect 2 portion of the missionscreencommon. Don't I feel silly now. Did a little housekeeping while at it. 2012-02-14 00:50:53 +00:00
Zacam f61eed4dbb Backport: Trunk r8414; Fix for Mantis #2374: Adds "+Closeup_pos:" and "+Closeup_zoom:" as entries following "$Tech Model:" for the weapons.tbl. For entries not using a dedicated $Tech Model, simply specify the $Tech Model as the same POF used in $Model to adjust Loadout Screen viewing position and zoom. 2012-02-14 00:49:53 +00:00
Zacam 380f4e31b5 Backport: Trunk r8413; Fix for mantis #0002590: fix array overruns caused by starting wings have > MAX_WING_SLOTS ships 2012-02-14 00:48:41 +00:00
Zacam ab18bfacad Backport: Trunk r8412; more robust saving of dockpoint indexes (again for Mantis #2587) 2012-02-14 00:47:58 +00:00
Zacam 07f58a21a1 Backport: Trunk r8407; Fix for Mantis 2589: Deactivate the Special* buttons while no ship is selected 2012-02-14 00:47:04 +00:00
Zacam 7e6aae12ca Backport: Trunk r8406; Fix for Mantis 2458: Initialize stuff before calling the point_to_vec function so it has the right matrices for calculation, also fixed scripted sphere drawing 2012-02-14 00:46:16 +00:00
Zacam 26afaaf56e Backport: Trunk r8400; undo animations for undockings that happen from exploding or jettisoning cargo 2012-02-14 00:45:15 +00:00
Zacam d81fa6bbe2 Backport: Trunk r8398; fix Mantis #2587 2012-02-13 21:18:36 +00:00
Zacam b6a94ff3fe Backport: Trunk r8397; tweaks 2012-02-13 21:17:48 +00:00
Zacam 9182a31173 Backport: Trunk r8396; Vasudan Admiral's fix for the modelanim code 2012-02-13 21:16:57 +00:00
Zacam bb5da5b6f7 Backport: Trunk r8395; Fix for mantis #0002591: add braces based on code indentation 2012-02-13 21:15:53 +00:00
Zacam ac25e6ddfa Backport: Trunk r8394; remove another four warnings 2012-02-13 21:15:05 +00:00
Zacam ddf0737133 Backport: Trunk r8393; remove warning 2012-02-13 21:14:18 +00:00
Zacam 0b3f745c59 Backport: Trunk r8389 + r8390 + r8391 + r8392; wait until animation finishes before separating during undocking && VA says this might work? && derp fixes 2012-02-13 21:13:35 +00:00
Zacam ad33b70fb6 Backport: Trunk r8388; Fix for Mantis 2521: Don't use the ship list for updating when we're in the middle of creating it. 2012-02-13 21:11:17 +00:00
Zacam 3c97ebbb75 Backport: Trunk r8385; Fix for Mantis 2538: From Eli2, corrects for looping fade issue reported by FelixJim. 2012-02-13 21:10:26 +00:00
Zacam 9f19cd1a41 Backport: Trunk r8383; Fix for mantis #0002370: ignore missing starting wing indexes during mission restart 2012-02-13 21:09:19 +00:00
Zacam 336283eedc Backport: Trunk r8382; two new sexps, signum and trigger-submodel-animation. also, fix a smattering of missing sexp stuff from other people's commits such as argument types, validity checking, putting things in submenus, and using is_sexp_true 2012-02-13 21:08:18 +00:00
Zacam e2d293a2e4 Backport: Trunk r8378 + r8379 + r8381; enhancement for bug 2582: trigger animations on BOTH ships undergoing docking && docking code some more. add code logic to (theoretically) set submodels instantly to initial or final positions && Fix to Trunk r8379, for want of a ; a compile was lost. 2012-02-13 21:07:25 +00:00
Zacam 4da71f5ed8 Backport: Trunk r8377; remove unnecessary warning 2012-02-13 21:05:24 +00:00
chief1983 4821c7b92e RC4 BUILD STAGE COMMIT: Sets Revision and Version properties to this commit version. 2012-01-26 05:47:25 +00:00
chief1983 9e6b964b4b Backport: Trunk 8373; partial fix for Mantis #2582:
--add Vasudan Admiral's fix for setting submodels to their initial positions
--add trigger for moving submodels to their docked positions when an initially-docked ship arrives
2012-01-26 05:27:06 +00:00
chief1983 d15856e2ba Backport: Trunk 8369; From Eli2: Mantis #2538: Fade-in time limitation. Testing in Multiplayer as well, no drastic incompatibility found. (If the host is patched but the client is not, then the timing returns are a little funny, but it doesn't cause for any crashes) 2012-01-25 21:37:25 +00:00
chief1983 827ada1960 Backport: Trunk 8368; Fix for Mantis 2556: Check if the mouse cursor is really there before drawing it. 2012-01-25 21:19:10 +00:00
chief1983 9cfac8dc42 Backport: Trunk 8363; Fix for Mantis 2583: Reinitialize the timer right when changing selection modes. 2012-01-24 00:19:14 +00:00
chief1983 03ad562905 Backport: Trunk r8362; Makes a very strangely coded warning more readable and useful. 2012-01-24 00:18:31 +00:00
chief1983 02d638a05a Backport: Trunk r8361; upgrades to the docking system to incorporate docking animations -- incidentally, fixes Mantis #2581. also, remove DOCK_BACKUP_RETURN_VAL which never did anything even in retail 2012-01-24 00:14:49 +00:00
chief1983 880b7b68eb Backport: Trunk 8344; Fix for Mantis 2580: Use the texture matrix in the vertex shader to support texture panning. 2012-01-23 23:16:58 +00:00
chief1983 160180b230 Backport: Trunk 8329; fix Mantis #2579 2012-01-23 23:16:30 +00:00
chief1983 82d5b218e3 Backport: Trunk 8327 + 8341; Fix for Mantis 1997: 'Filename too long' warning for nonexistant textures. && Followup to 8327: Texture names from pofs are provided without extension, so we have to make sure to account for it. 2012-01-23 23:06:05 +00:00
chief1983 9d6f75e4fe Backport: Trunk 8326; Fixes #2578 - Change the < in these checks against NAME_LENGTH to <=. 2012-01-23 23:04:12 +00:00
chief1983 269574af5c Backport: Trunk 8305; quash a warning 2012-01-23 23:01:18 +00:00
chief1983 9670d16537 Backport: Trunk 8304; Documentation: pedantic rename of this function to describe it better 2012-01-23 23:00:34 +00:00
chief1983 44706c03a1 Backport: Trunk 8301; Documentation: Missionweaponchoice.cpp and related changes. Removed a few redundant functions. 2012-01-23 23:00:04 +00:00
chief1983 5242a38755 Backport: Trunk 8300; don't remove the escort flag from invisible ships that aren't on the escort list (fixes Mantis #2057). also, don't remove dead or dying ships from the escort list, because due to the design of the culling function, they were never removed previously 2012-01-23 22:59:19 +00:00
chief1983 97382b69ca Backport: Trunk 8299 + 8302; the proper way to fix Mantis #2441 is by modifying the team_visibility_update function && follow-up to 8299: we need to check visibility for our own team in case we have a friendly-stealth-invisible ship covered by AWACS, or something\nalso, clarify terminology: in-frustum/not-in-frustum replaces visible/invisible\nand do some minor rewrites for additional clarification 2012-01-23 22:56:02 +00:00
chief1983 3131006fd5 Backport: Trunk 8298 + 8350; From Valathil: Adjusts view point rotation in 3rd Person/chase view. This is especially apparent in Nebula missions where rotating in Chase View is radically different from cockpit view. This fix corrects that, and has additionally been tested in Multiplayer. && Follow up to 8289 + 8310: Make the sprite rotation independent of the camera direction and revert the docking change and make it simpler 2012-01-23 22:53:33 +00:00
chief1983 87f4c064f7 Backport: Trunk 8297; Purely aesthetic. I have no idea what a packlock is. 2012-01-23 22:37:35 +00:00
chief1983 c1ad2ed64f Backport: Trunk 8295; tie scramble-messages and unscramble-messages into the communications subsystem status so that they will affect all aspects of communications in a consistent way (squadmsg menu, dashed text, etc.)also make hud_communications_state() be a pure function, i.e. one without side effectsalso fixes Mantis #2577 2012-01-23 22:36:01 +00:00
chief1983 2b91bfb98a Backport: Trunk 8294; Fix for Mantis 2575: Don't increment array indices without checking for the maximum. 2012-01-23 22:22:33 +00:00
chief1983 0c33d511b0 Backport: Trunk 8293; Small scripting documentation fix: modeltextures -> modeltextures_h. 2012-01-23 22:21:49 +00:00
chief1983 0467fbb289 Backport: Trunk 8291; Fix a few unused variable warnings that popped up after recent commits by Echelon9 2012-01-23 22:20:59 +00:00
chief1983 910046729b Backport: Trunk 8289 + 8310; Fix for Mantis 2522: Moved the calculation of the sprite rotation to get the updated orientation matrix after dock calculation. && Follow up to 8289: Change the rotation back to relative cause of flipping out billboards at certain viewing angles and fix the dock rotation another way. 2012-01-23 18:18:54 +00:00
Zacam 73ef4c52df Backport: Trunk 8274-8286; LLVM Warnings Fixes from Echelon9. 2012-01-23 18:11:25 +00:00
chief1983 4a3b9f9b76 Backport: Trunk 8272; Fix for Mantis 2576: Use the beam direction as the applied force vector 2012-01-23 05:00:22 +00:00
chief1983 b4ce4b3f85 Backport: Trunk 8270; Fix for Mantis 2461: Check to see if the reduced damp timestamp is valid so we don't get ridiculous acceleration values. 2012-01-23 04:59:41 +00:00
chief1983 2cb514ab3f Backport: Trunk 8269; These error messages need to be waay clearer 2012-01-23 04:59:07 +00:00
chief1983 2d8861e2d1 Backport: Trunk 8266; Fix for Mantis 2574: Timestamps do not work that way, also fixed the rapid fire "Out of Energy" sound for fighter beams. 2012-01-23 04:58:29 +00:00
chief1983 78e9e431e4 Backport: Trunk 8265; Fix for Mantis 2553: Fix overdrawing subspace glows by changing them from thrusters to normal bitmaps therefore avoiding a render time problem with the thruster geometry batcher. 2012-01-23 04:57:30 +00:00
chief1983 f5a192c27c Backport: Trunk 8263 + 8271; Fix for Mantis 2573: Special Hitpoint settings get carried over when deleting and adding ships in FRED && update to revision 8263: one should probably reset the special shields if you reset special hitpoints 2012-01-23 04:56:33 +00:00
chief1983 97dd5149cd Backport: Trunk 8262; need to use subsystem_stricmp for subsystems 2012-01-23 04:54:20 +00:00
chief1983 26a0ffe6ee Backport: Trunk 8261; Fix for Mantis 2572: Just dont render 0.0 Laser Length weapons 2012-01-23 04:53:43 +00:00
chief1983 52f3e10c80 Backport: Trunk 8260; Fix for mantis #0002480: when emptying secondary banks use the standard function... 2012-01-23 04:52:47 +00:00
chief1983 37ac788606 Backport: Trunk 8254; Fixes #2571 - Changes a value in each config to match the config name. 2012-01-23 04:47:28 +00:00
Zacam 844b3bab4f RC3 Build Stage Commit: Correction to configure.ac and Revision bump to this commit version. 2012-01-18 04:49:57 +00:00
Zacam 32977365d0 RC3 BUILD STAGE COMMIT: Redux and version update to this commit. 2012-01-16 00:39:03 +00:00
Zacam 78289b4802 Backport: Trunk 8233; Made the failure message for failed model loads include the model filename. 2012-01-16 00:32:07 +00:00
Zacam 4e6b031bb9 backport: Trunk 8232 + 8237; Fix for Mantis 2441: "friendly-stealth-invisible" flag doesn't work 2012-01-16 00:31:26 +00:00
Zacam 41c834157d Backport: Trunk 8231; Fix for Mantis 1768: Cutscene bars do not display properly. 2012-01-16 00:30:17 +00:00
Zacam d4c2e9727e Backport: Trunk 8227; Fix for Mantis #0002443: allow primary weapons to have fire_waits longer than 5 secs 2012-01-16 00:28:22 +00:00
Zacam 315e1d489c Backport: Trunk 8225; yeesh... part of the original iff_defs feature that wasn't updated 2012-01-16 00:27:46 +00:00
Zacam 259c805c63 Backport: Trunk 8224; Clear a whole set of LLVM warnings - some of these would have caused memory fubars, so should marginally improve stability 2012-01-16 00:27:05 +00:00
Zacam a944a2d9e9 Backport: Trunk 8223 + 8235; Ensure we don't leak memory on Mac OS X. Any object created with a CF*Create() function must have CFRelease() called upon it. 2012-01-16 00:22:40 +00:00
Zacam 120a780470 Backport: Trunk 8222; Fix LLVM warnings in weapon folder 2012-01-16 00:21:16 +00:00
Zacam 704f6580db Backport: Trunk 8220; Fix for #2570: Changed the external camera messages to be IFF color and internal messages back to green 2012-01-16 00:20:38 +00:00
Zacam 361e7ae590 Backport: Trunk 8219; Fix for #2549 & #2457 - Fixed rendering of bars and moved earlier in code so we dont overdraw the hud messages 2012-01-16 00:19:56 +00:00
Zacam f556a6694d Backport: Trunk 8218; Fix for Mantis 1803: Lensflares are rendered with no sun in sight 2012-01-16 00:19:20 +00:00
Zacam 5735d59fdd Backport: Trunk 8216; Fix OpenGL errors caused by animated shaders when not rendering to a fbo 2012-01-16 00:18:37 +00:00
Zacam 3989ce21aa Backport: Trunk 8215; Fix "Unable to get shader uniform location" warning for distortion shaders 2012-01-16 00:17:55 +00:00
Zacam bfd30fa3d8 Backport: Trunk 8214; Fix for Mantis 2568: "Fog Near/Far Mult:" being written to mission files even when in retail compatibility mode. 2012-01-16 00:16:32 +00:00
Zacam 55801b8941 Backport: Trunk 8212; Fix for #2567 - LLVM warning: Semantic issue in lua.cpp 2012-01-16 00:15:38 +00:00
Zacam 8bcd195e48 Backport Revert (8180): Reverting the backport of Trunk 8216. 2012-01-16 00:02:11 +00:00
Zacam 832db695ec Okay. This was ridiculous running all these changes separately. This setts svn:eol-type across the board for types that were not previously set to LF as they should have been. 2012-01-13 18:44:18 +00:00
Zacam 0d747ad3b8 RC3 BUILD STAGE COMMIT: Sets Revision and Version properties to this commit version. 2012-01-12 22:25:28 +00:00
Zacam ebb5206315 And to finally clean up the compiler issues caused by TortoiseSVN being a wanker in merging across some of the backports. This returns .14 to being Stable again. 2012-01-12 22:05:56 +00:00
Zacam d5c8494297 Fixes def_files merge of the 8171 Backport commit of Trunk 8109. 2012-01-12 20:47:43 +00:00
Zacam 40071290f2 Backport: Trunk 8056; zookeeper's addition of new scripting hook that runs right before entering mission.
(Required for Backport of Trunk 8102)
2012-01-12 20:11:02 +00:00
Zacam cc6050b711 Backport: Documentation Update. This copies the documentation related changes from Trunk as a unified commit. 2012-01-12 20:01:30 +00:00
Zacam 97e9d9e8d6 Back in Commit 7843 of this branch, a sync to Trunk 7842 took place.
This sync was incompletely done, resulting in the following to be missing:
7815 - Set-docked SEXP
7834/7835 - Update to ad.playMusic to allow control over whether or not to loop the passed sound file.
7841 - From m!m: Allows per-ship customization of ship sounds in ships.tbl. See Wiki for details.
2012-01-12 19:05:14 +00:00
Zacam 838ae6eee2 Backport: Trunk 8164; Fix for #2559 - new frameworks file that strips the metadata files out of the archive. 2012-01-12 03:28:32 +00:00
Zacam ed71fe08df Backport: Trunk 8163; Make sure the FXAA pass only draws to COLOR_ATTACHMENT0 2012-01-12 03:26:39 +00:00
Zacam de5f6671ea Backport: Trunk 8160; Change the define to one that is a little less confusing. 2012-01-12 03:25:23 +00:00
Zacam 933b9422d8 Backport: Trunk 8159; Not that it matters much since it's that's what it's ending up as anyway but since the variable that uses it was switched to unsigned we might as well change this. 2012-01-12 03:24:44 +00:00
Zacam 55edb850a7 Backport: Trunk 8158; Fix for Mantis #2558 : Resolves the issue by updating the libpng provided to version 1.5.7. 2012-01-12 03:23:50 +00:00
Zacam 14d3a1a007 Backport: Trunk 8157; Made WIF2_SMALL_ONLY weapons on turrets not fire on HUGE ships when grouped with other weapons that are not WIF2_SMALL_ONLY 2012-01-12 03:22:41 +00:00
Zacam b7de7ae422 Backport: Trunk 8155; Another Assert->Assertion change. Also changes parsing code to throw warnings when a shockwaves' inner radius is zero. 2012-01-12 03:21:52 +00:00
Zacam c3bc4ba563 Backport: Trunk 8128; Removed an unused #define 2012-01-12 03:16:43 +00:00
Zacam f97c5059f0 Backport: Trunk 8126; Remove a magic number. This number will probably become something defined in mod.tbl eventually but for now at least it's easy to find again. 2012-01-12 03:15:41 +00:00
Zacam 4f62a53354 Backport: Trunk 8125; Training weapons shouldn't cause smoke to come off of ships which haven't really taken any damage. 2012-01-12 03:13:30 +00:00
Zacam 708c0ae8fa Backport: Trunk 8124; Switch from the directive-is-variable SEXP to the more powerful directive-value one. 2012-01-12 03:12:39 +00:00
Zacam 8740115165 Backport: Trunk 8120; Fixed font rendering at high resolutions 2012-01-12 03:11:56 +00:00
Zacam b75151cef1 Backport: Trunk 8116; Fixing an old mistake I made back in September 2010. Note: Assertions are optimized out of release builds, leaving this necessary skip out. 2012-01-12 03:11:14 +00:00
Zacam a998afffe4 Backport: Trunk 8115; Make sure to include the right lua headers on all platforms, as pointed out by rhl. 2012-01-12 03:10:13 +00:00
Zacam eeaf958420 Backport: Trunk 8114; We do need to bind the correct depth buffer for rendering, else things get all confused. 2012-01-12 03:09:35 +00:00
Zacam 2cd28541e7 Backport: Trunk 8111; From m|m: Fix for Mantis 2400 (RTT rendering broken in current builds). Also changes GL_rendering_to_framebuffer to the more aptly named GL_rendering_to_texture. 2012-01-12 03:02:49 +00:00
Zacam 596bae9cfa Backport: Trunk 8110; Adjust alignment when shader debug logs are written. 2012-01-12 02:55:25 +00:00
Zacam 1176523e9d Backport: Trunk 8109; Added hardware accelerated YUV to RGB conversion with shaders to the ogg video renderpath. 2012-01-12 02:54:38 +00:00
Zacam d9a29ac708 Backport: Trunk 8108; Adds an intermediate render target for FXAA to work against, this removes a previous reliance on undocumented behaviour in OpenGL. 2012-01-12 02:46:55 +00:00
Zacam f4fa2e00a2 Backport: Trunk 8107; Allow for FS1 shader effect to be customized in post_process.tbl 2012-01-12 02:46:03 +00:00
Zacam 2167ece1fd Backport: Trunk 8104; Removed the unused "Ghost Save" entry from Object_type_names, because it was causing an off-by-one when using the getBreedName() scripting function. Also added "Beam" to the list since it's a valid object type. 2012-01-12 02:44:33 +00:00
Zacam bca3d084a5 Backport: Trunk 8103; Fix for Mantis 2498: Invalid species reference in ships.tbl is not detected. 2012-01-12 02:43:11 +00:00
Zacam bbc0eec0ba Backport: Trunk 8102; from zookeeper: make hv.Player availiable in "$On Gameplay Start" scripting hook 2012-01-12 02:42:04 +00:00
Zacam a5684ba6cf Backport: Trunk 7981/810; zookeeper: fix $Shots for turret-fired weapons, with fix to from Valathil. 2012-01-05 22:34:15 +00:00
Zacam 2a2c5856c3 Backport: Trunk 8099; Fix for Mantis 2545: Default ship in FRED is not the ship defined by #Default Player Ship 2012-01-05 22:32:33 +00:00
Zacam 3a951225e9 Backport: Trunk 8098; Fix for Mantis 2550: Text in multiplayer is rendered outside the textbox if custom fonts are in use 2012-01-05 22:31:50 +00:00
Zacam 3f7b0b1c8f Backport: Trunk 8097; fix for Mantis #2547 2012-01-05 22:30:36 +00:00
Zacam edb67c1b17 Backport: Trunk 8096; make sexp category stuff accessible, fix Mantis #2551 2012-01-05 22:29:53 +00:00
Zacam 12d27b7913 Backport: Trunk 8059; Hellzed's french keyboard layout stuff 2012-01-05 22:24:19 +00:00
Zacam e6f0fe4ffb Backport: Trunk 7905/7906; From Eli2: Allows adjustment of the keyboard layout on Linux/MacOS (German, '-keyboard_layout qwertz') 2012-01-05 22:23:36 +00:00
Zacam fcf6cec066 Backport: Trunk 8028; zookeeper's initial velocity patch 2012-01-05 22:22:10 +00:00
Zacam c2896f83f6 Backport: Trunk 8013; That's a rather pointless test when we don't have AI smart missiles. 2012-01-05 22:21:17 +00:00
Zacam a2f8be65ae Backport: Trunk 7993; Add $Armor Type support for missiles 2012-01-05 22:20:35 +00:00
Zacam 53c0b4ae35 Backport: Trunk 7992; Clean up Ship Maneuvers, Improve SEXP Help for 2012-01-05 22:19:49 +00:00
Zacam 5ebae3603d Backport: Trunk 7991; Add "only target if can fire" turret flag 2012-01-05 22:19:08 +00:00
Zacam 7853397544 Backport: Trunk 7988; cfile: change Assert to Assertion 2012-01-05 22:18:18 +00:00
Zacam 3241e58eaa Backport: Trunk 7969; Add workaround so that AI landings consistently work 2012-01-05 22:16:32 +00:00
Zacam 4e9f4af398 Backport: Trunk 7960; Originally spotted by zookeeper: "$gun_rotation:" should be set to "!= NULL" like the other entries around it. 2012-01-05 22:15:42 +00:00
Zacam 80462cb097 Backport: Trunk 7929; the ship copy flag needs to be able to recognize ships that appear later in the table 2012-01-05 22:14:56 +00:00
Zacam 1a2588cfba Backport: Trunk 7928; we have some preconditions, so let's enforce them 2012-01-05 22:14:11 +00:00
Zacam d12fee5955 RC2 BUILD STAGE COMMIT (For Reals this time). Updates version information for logging to sync to this commit. 2011-12-13 18:07:25 +00:00
Zacam 4a120433e8 Backport: Trunk r8066+8068; Adds a sexp to switch the thrusters on a given ship or list of ships on and off. (Includes fix to infinite loops) 2011-12-13 16:37:33 +00:00
Zacam 80730a2ffa Backport: Trunk r7986; add is-in-mission sexp 2011-12-13 16:35:55 +00:00
Zacam 4910a0239b Backport: Trunk r8086; Fix to the sexp_ship_effect causing an assert when used against ships that get destroyed before the event triggering it fires off. (From The E) 2011-12-13 16:34:02 +00:00
The_E 36e7ebea4a Backport of trunk 8083: Fix for trunkated command briefings with custom fonts. 2011-12-13 16:15:11 +00:00
Zacam 746f86883d RC2 BUILD STAGE COMMIT (Take 3); Bump OS X build output names to 3.6.14-RC2 (no formulative revision change to logging however, will still identify as 8075) 2011-12-08 23:15:52 +00:00
Zacam beb0aec724 RC2 BUILD STAGE COMMIT (Take 2); Version information bumped to match this commit revision. 2011-12-08 23:10:35 +00:00
Zacam 8cf10625bc Backport: Trunk r8072; Fix stdint's existence breaking OS X compiling. 2011-12-08 23:07:34 +00:00
Zacam e1e5895749 Backport: Trunk r8070; Fix crash when framebuffer shockwaves are enabled but no weapon loads the standard shockwave animation 2011-12-08 23:06:28 +00:00
Zacam e8556981d3 Backport: Trunk r8065; Fix r8054: Const char* to char* conversion was causing GCC compile errors 2011-12-08 23:05:42 +00:00
Zacam b796f523e3 RC2 BUILD STAGE COMMIT; Version information bumped to match this commit revision. 2011-12-03 15:15:41 +00:00
Zacam bf6d547cd5 Backport: Trunk 8054; make weapon parsing more robust for Mantis #2369 2011-12-03 14:45:14 +00:00
Zacam c827121e1a Backport: Trunk 8052/8053; From CommanderDJ: Nebula distance check for set-object-position's regeneration of local nebula. Since "neb2_eye_changed()" contains "Neb2_regen" why not use it instead? 2011-12-03 14:44:29 +00:00
Zacam 130e254c89 Fix to Backport of 7971: when adding more lines to an if, braces are your friend. 2011-11-23 05:13:22 +00:00
Zacam 708e8d3d6c Backport: Trunk 8040; LOL and DERP, whoever coded this didn't even read his own comment 2011-11-23 03:39:48 +00:00
Zacam b3420befc7 Backport: Trunk 7907/7908; Geometry and Distortion map batcher adjustments. 2011-11-22 23:55:02 +00:00
Zacam b347ea17e8 Backport: Trunk 7971; Fix Mantis 2343: Assert on arriving from destroyed ship 2011-11-22 21:36:15 +00:00
Zacam 02fe9d3243 Backport: Trunk 7967; Mantis 2537: Help track down a memory leak problem 2011-11-22 21:35:17 +00:00
Zacam 985da615ba Backport: Trunk 7966; Fix Mantis 2539: Valgrind: Memory leak - parse_ship_values(ship_info*, bool, bool, bool) 2011-11-22 21:34:03 +00:00
Zacam ac406437ae Backport: Trunk 7921; Fix Mantis 2526: Valgrind: Conditional jump or move depends on uninitialized value(s) - init_anim_instance() 2011-11-22 21:33:10 +00:00
Zacam f2eef10a61 Backport: Trunk 7920; Fix Mantis 2525: Valgrind: Conditional jump or move depends on uninitialized value(s) - parse_ship_values() 2011-11-22 21:32:14 +00:00
Zacam af7e811cf1 Backport: Trunk 7962, 7963, 7974, 7976; Fix for Mantis 2533 from Eli2: Integer overflow in mission-time-msecs (with fixes from The E and inclusion of stdint.h and inttypes.h) 2011-11-22 21:28:46 +00:00
Zacam 95e924b6ce Backport: Trunk 7985; fix compilation on MSVC 6 2011-11-22 19:03:23 +00:00
Zacam c91f65e274 Backport: Trunk 7957; Linux: remove -g (debug symbols) flag from release builds & switch optimisations from -Os -to -O2 2011-11-22 18:58:36 +00:00
Zacam 721d529776 Backport: Trunk 7918; From ni1s: -Wreorder warnings clean up for GCC output. 2011-11-22 18:56:21 +00:00
Zacam 458b67e0fc Backport: Trunk 7902; Wrong EOL type on these two. 2011-11-19 21:56:44 +00:00
Zacam 6b9a61dae0 Backport: Trunk 7890; Remove unneeded warnings 2011-11-19 21:55:38 +00:00
Zacam 9f2a038976 Backport: Trunk 7889; From m\!m: access to the Viewer_mode as I need to know if the view is currently in the cockpit or not 2011-11-19 21:54:09 +00:00
Zacam 96486ad64a Backport: Trunk 7887; Change the log message here to better explain what's happening. 2011-11-19 21:53:14 +00:00
Zacam c6155a784c Backport: Trunk 7885; From Eli2: fix for mantis 2517: loop sounds are always at 100% volume locked and afterburner fade out sound not work 2011-11-19 21:52:25 +00:00
Zacam e7b8feef5f Backport: Trunk 7884; Testing Assert() to track down a series of bugs reported by QuantumDelta 2011-11-19 21:51:32 +00:00
Zacam cf684e67c0 Backport: Trunk 7882; found by Valathil; in "int obj_in_view_cone( object * objp )", codes=g3_rotate_vector(&tmp,&pt); works out better than running the check, then discarding it since g3_code_vector calls to run g3_rotate_vector anyway. 2011-11-19 21:50:16 +00:00
Zacam 535a9ec32b Backport: Trunk 7879; Adds Success/Average/Fail music selections to the Debriefing Editor. 2011-11-19 21:48:31 +00:00
Zacam b7fdae636a Backport: Trunk 7847; From Eli2: Patch for Mantis 2489: adjust-audio-volume doesn't affect subspace 2011-11-19 21:47:07 +00:00
The_E 4dfb17ab01 Backport of trunk 7997: Extended patch for Mantis 2391 2011-11-16 18:15:22 +00:00
The_E bdda953b21 Backport of Trunk 7996: Fix for Mantis 2544 2011-11-16 18:14:21 +00:00
The_E 767bb5c862 Backport of trunk 7995: Fix for Mantis 2543 2011-11-16 18:13:25 +00:00
niffiwan aa07330f1e Linux: include version in output binary names 2011-11-05 10:03:38 +00:00
chief1983 66f0dec8f4 Backport of Trunk r7939: From niffiwan: Fix our linking order to work with --as-needed 2011-11-02 21:04:30 +00:00
Zacam 16322a4a88 RC1 BUILD STAGE: Take 2. Corrects modelinterp issue by replacing the "SCP_" vectors with "std::" vectors. Corrects 2008 Speech compilation. Increases internal Revision to 7903. 2011-10-12 19:49:12 +00:00
Zacam 9c78519420 RC1 BUILD STAGE COMMIT: This will set the "Revision" value for output builds to "7899" so that troubleshooting/tracking can accurately asses version information.
Also updates the windows execs to report the version in the file system properties.
2011-10-12 17:35:51 +00:00
Zacam 3806a4ed9f Backport: Trunk r7898; Improve performance of jpeg byte swap operation 2011-10-12 16:11:54 +00:00
Zacam d3b61db4a0 Backport: Trunk r7895; Fix the transparency delay framework to work with submodel_render() 2011-10-11 18:49:38 +00:00
Zacam caaf6526fe Backport: Trunk r7891; Add RGB / BGR byte swap to jpeg reading - libjpeg now doesn't need jmorecfg.h to be updated 2011-10-11 05:47:33 +00:00
Zacam d8633494fb Backport: Trunk r7874; Fix for medal room crash reported by QuantumDelta 2011-10-08 08:12:22 +00:00
Zacam 3345b78f18 Backport: Trunk 7871; Fixes issue with the mn.Asteroids and mn.Debris scripting tables, as these were accidentally 0-indexed instead of the Lua-standard way of starting indices from 1. 2011-10-08 08:10:06 +00:00
Zacam d9b69e290d Backport: Trunk r7861; Remove the empty hudresource.cpp/.h files from /code/hud and all projects. 2011-10-06 06:07:09 +00:00
Zacam d48da6e765 Backport: Trunk r7862; enhance are-waypoints-done-delay to allow ships to complete waypoint paths multiple times
make count check more robust in has-docked-delay and has-undocked-delay; Assert shouldn't be used for mission data entered in FRED
2011-10-06 06:06:05 +00:00
Zacam 8d35cbcfb2 Backport: Trunk r7859; PVS-Studio V581 in revision 7779 was actually a false alarm; overzealous cleanup created a condition where a negative array index could occur, triggering either an assert or a crash (Mantis #2514) 2011-10-06 06:05:15 +00:00
Zacam 6645dae670 Backport: Trunk r7858; Revision: 7858 CommanderDJ's fix for Mantis 2276 set-object-speed SEXPs don't work in multiplayer. 2011-10-06 06:04:20 +00:00
Zacam 35f1394997 Backport: Trunk r7853; Fix: Mantis 2470 - $Flags: ("untargetable") does not work on turret subsystems 2011-10-06 06:03:24 +00:00
Zacam 45b3efd0fc Backport: Trunk r7845; Finish removing debugfile.cpp/h from the rest of the projects. 2011-10-06 06:02:17 +00:00
The_E c599d359cf Sync to trunk 7842 due to bugfixes and and feature additions for the scripting API 2011-10-02 07:47:31 +00:00
Zacam e870a9cb63 Backport: Trunk 9728, restore sound index to gamesnd.h 2011-09-30 05:06:04 +00:00
Zacam b081e42418 Backport: Re-apply fix for Mantis 2477 from niffiwan (Trunk 7825) 2011-09-28 17:25:53 +00:00
Zacam f2ebe497c6 A bunch of audio code hacks to address the concerns in http://www.hard-light.net/forums/index.php?topic=77889.0 until proper fixes of the sound code are completed.
+F -donotenforce = to turn off concurrent playback limit for sounds.
+F -percent_flashtobang = sets the default percentage of nebula flashes get converted to bangs.  Default is 50, max 100, min 0.
+T lightning.tbl +flash_to_bang_percent: = sets the percentage of nebula flashes that get converted to bangs for the storm type.
-- Audio gain of OpenAL is set to 65% of max.
2011-09-27 21:22:35 +00:00
Zacam b8530023db Updates Build output names and XCode embedded version. 2011-09-27 21:04:46 +00:00
chief1983 d076e9ae95 Copy trunk r7811 to 3.6.14 branch. 2011-09-26 18:23:27 +00:00
niffiwan ece4ad88bc Fix for mantis 2501 2011-09-26 11:17:06 +00:00
Zacam 02a23b22b1 From CommanderDJ: Fix for Mantis 2224 "Chat messages may end up unreadable due to unfortunate color choice"
Allows for the specification of colors via a colors.tbl
(Wiki Documentation here: http://www.hard-light.net/wiki/index.php/Colors.tbl )
2011-09-26 05:40:07 +00:00
The_E 9710f64934 Aargh. NOW it's fixed correctly 2011-09-25 20:47:31 +00:00
The_E e8d36eac79 And a final fix here 2011-09-25 20:46:22 +00:00
The_E c052cbe1e2 Fix for subsystem flags resetting erroneously. Thanks to zookeeper for noticing this. 2011-09-25 10:50:08 +00:00
Zacam 206279c5fd Sync Drift: Apparently still some lingering ifdefs for OEM/Multiplayer_Beta and non-AP specific things not having made it to trunk for some reason. 2011-09-25 08:26:45 +00:00
The_E 6b90b35f56 FRom CommanderDJ: Patch for Mantis 2307, set-object-position weirdness when in nebula 2011-09-25 07:50:07 +00:00
IssMneur 1ac6127251 Fixes Mantis 2510 - Rotation periods for submodels of less than 1.0 seconds cause uncontrolled rotation of submodel. 2011-09-25 04:00:06 +00:00
Echelon9 e3195a82d6 Code cleanup: We should be really careful with using these scoring struct elements, as the types were changed from ushort to int at some point. 2011-09-25 02:42:27 +00:00
The_E 0f51dc1925 Redo 7777 without breaking anything else in the process 2011-09-24 19:47:47 +00:00
The_E 531a7c71bb Revert 7791. Something went wrong there. 2011-09-24 18:31:20 +00:00
The_E 4ce7dfe9e4 Revert 7789 2011-09-24 17:42:56 +00:00
The_E a982eb153d Remove more useless encryption stuff. NOTE FOR PROJECT FILE MAINTAINERS: parse/encrypt.(cpp|h) should no longer be part of the project. 2011-09-24 17:37:12 +00:00
The_E b964c63d6e From niffiwan: Fix for Mantis 2477 2011-09-24 15:59:00 +00:00
The_E 24d6ca3bad PVS Studio related: False alarms 2011-09-24 15:46:24 +00:00
The_E 5f0cf81cd2 PVS Studio fix: Rearranged struct to decrease size 2011-09-24 15:46:03 +00:00
The_E 6511cfdddf From eli2: Change the control defines into a more manageable enum 2011-09-24 15:45:13 +00:00
The_E 05f3578109 PVS Studio fix: V547, <variable> >= 0 check on size_t variable 2011-09-24 14:26:04 +00:00
The_E 0e66893f32 Remove unused variable 2011-09-24 14:22:35 +00:00
Echelon9 cd1cc88640 Xcode project file cleanup: Xcode 3 thinks these sections are unnecessary after the encrypt.cpp file was removed recently 2011-09-24 01:35:19 +00:00
Echelon9 7d9ea6b21c Documenation: Code cleanup of keycontrol.cpp 2011-09-24 01:34:25 +00:00
Echelon9 911025d835 A small code cleanup patch from Eli2. Thanks. 2011-09-24 01:19:29 +00:00
Echelon9 8e1c689f32 PVS-Studio fix: V581 The conditional expressions of the 'if' operators situated alongside each other are identical. Check lines: 2056, 2061 (multiteamselect.cpp) 2011-09-23 20:28:06 +00:00
Echelon9 2866b4fb3b PVS-Studio fix: V581 The conditional expressions of the 'if' operators situated alongside each other are identical. Check lines: 2039, 2044 (multiteamselect.cpp) 2011-09-23 20:27:25 +00:00
Echelon9 82a36997cb PVS-Studio fix: V581 The conditional expressions of the 'if' operators situated alongside each other are identical. Check lines: 2172, 2186 (sexp.cpp) 2011-09-23 20:26:32 +00:00
Echelon9 efcdac911e PVS-Studio fix: V581 The conditional expressions of the 'if' operators situated alongside each other are identical. Check lines: 1977, 1986 (sexp.cpp) 2011-09-23 20:24:43 +00:00
The_E ad0581dd4d Fix for Mantis 2134: set-fov sexp has no effect at mission start. This moves the camera initialization stuff up a few lines to run before game_simulation_frame, thus ensuring the main camera is set up when sexps are evaluated.
Many thanks to CommanderDJ for tracking this down.
2011-09-23 19:09:23 +00:00
Swifty e329d4542f Fixed Mantis 2502. Messages gauge will no longer calculate string sizes using the incorrect font. 2011-09-23 09:14:02 +00:00
Echelon9 586491f150 PVS-Studio fix: V512 A call of the 'memset' function will lead to underflow of the buffer '&stackFrame' (mspdb_callstack.cpp). 2011-09-22 13:42:07 +00:00
Swifty 0ab6ecd58c Further fix for Mantis 2500. Directives should now be using sexp overrides. 2011-09-22 06:28:49 +00:00
Echelon9 2db013e321 Documentation: Code cleanup of grbatch.cpp and work to prepare for 64bit with size_t 2011-09-21 14:37:36 +00:00
Zacam cf5125d6a0 Revert enabling Speech and Voice Recognition, as it doesn't play well with Express versions of MSVC (at least not without a lot of work) 2011-09-21 06:37:56 +00:00
IssMneur 023c267374 - renamed +frequency to +period to reflect what the code actually does (as Valathil pointed out)
- +period: or +index: is no longer required for $substitute: (default is +index: 0)
- removed unnecessary check on +period: (1 is now a valid period)
2011-09-20 02:47:39 +00:00
The_E c428e55ee2 Move this check outside the for loop for better performance 2011-09-19 18:01:56 +00:00
The_E 5c05db7c40 Small fix for the logic here 2011-09-19 15:53:11 +00:00
The_E e689c90703 As requested by zookeeper: Adds "play fire sound for player" subsystem flag 2011-09-18 17:31:41 +00:00
Echelon9 83bc0e33fa From niffiwan: Fix for Mantis 2468 - Change-Ship-Class does not change armor type 2011-09-18 05:24:34 +00:00
Zacam c88660eca9 Also from Eli2: Code cleanup 2011-09-18 01:03:23 +00:00
Zacam 0a4f360908 Project cleanup for the removals of cryptstring, scramble, and crypt.cpp/.h. 2011-09-18 00:35:48 +00:00
Valathil 7a810e1dde From Eli2_: Change cheat codes to not use that useless crypto function anymore 2011-09-17 23:00:58 +00:00
The_E 9f4d15b9d6 Make sure ETS settings carry over when changing ship class, as well as making sure that weapon selection are still valid after the change. 2011-09-17 22:11:34 +00:00
The_E 7751e8c076 Another case where one should use the case-insensitive check found and fixed. 2011-09-17 21:48:46 +00:00
Valathil fe8f7ebaec Reinitialize collision checks when executing the change-ship-class sexp 2011-09-17 21:02:33 +00:00
Valathil 4c4258eb6d Reordered shaders for performance reasons 2011-09-17 20:55:03 +00:00
The_E 704908f74e Since this header and cpp define a single function used in a single place, let's move the function to where it's used, and get rid of these files 2011-09-17 20:25:49 +00:00
The_E d031406000 And another obsolete tool goes away 2011-09-17 20:08:13 +00:00
The_E 75790a647d These are unused as well. 2011-09-17 20:00:29 +00:00
The_E b692311667 These files are referenced nowhere, so away they go 2011-09-17 19:53:27 +00:00
The_E b1fc8971de Little change to fix bug with external post shaders not loading 2011-09-17 19:36:24 +00:00
Valathil df80d5a1c3 Add Ships.tbl flag to disable lighting 2011-09-17 18:00:38 +00:00
Valathil 7074db9287 Don't do a boolean check on Floats could be -0.0 which is boolean true 2011-09-17 14:36:29 +00:00
The_E c4ea493f9e From m!m: Make the player object and mn.* table available in an $On Mission Start hook 2011-09-17 13:03:52 +00:00
The_E 5b53430da5 From m!m: Adds isTurret() and isAfterburnerActive() Scripting functions 2011-09-17 12:59:54 +00:00
The_E 5cb8835238 Highly experimental project files for the highly experimental MSVC 2011. 2011-09-16 21:17:02 +00:00
The_E 8c129cfc3d Reverting 7733. This is clearly not ready for primetime, let alone a release. 2011-09-16 10:01:10 +00:00
The_E 5ec132d6e4 Adding support for the $On Weapon Fired: hook going off when turret weapons are firing 2011-09-15 11:46:33 +00:00
The_E 2997266ce9 Fix for the $On Weapon fired: scripting hook firing on every frame as long as the fire button is pressed 2011-09-15 11:35:32 +00:00
Zacam 1c324758f0 Enable Text-to-Speech (SVN Include) and Voice Recognition. (MSVC 2010) 2011-09-15 03:29:05 +00:00
Zacam cc14debd26 Enable Text-to-Speech (SVN Include) and Voice Recognition. 2011-09-14 22:44:50 +00:00
Zacam 9b9b172e9e EOL inconsistencies corrected to match the rest of the files. 2011-09-14 19:25:15 +00:00
The_E 7d5bce148f strcmp != stricmp. Using stricmp is necessary to avoid breaking old missions. 2011-09-14 18:49:06 +00:00
The_E 49fe727218 Fix for the $On Weapon Fired: scripting hook 2011-09-14 12:21:45 +00:00
Backslash 28c482a2f1 Add radar gauges to Hud_gauge_types list, so that hud-activate-gauge-type sexp can affect radar. Also a bit of code sorting to make it easier to make sure all gauges are accounted for. 2011-09-14 02:53:12 +00:00
chief1983 f07609e6db Update codeblocks project file. 2011-09-13 22:00:26 +00:00
The_E 36aaaf018e Since this is the only place where r1 and r2 are variable, let's safeguard it. 2011-09-13 20:36:41 +00:00
The_E 4c838f2014 Adding an exit path here. 2011-09-13 20:26:23 +00:00
Echelon9 dacd3337c7 Documentation: Code cleanup in hudnavigation and hudobserver 2011-09-12 13:52:07 +00:00
Echelon9 8c272b61ae Documentation: Code cleanup in fvi.cpp 2011-09-12 13:31:38 +00:00
Echelon9 5d2e1444e6 Documentation: Code cleanup in font.cpp and font.h 2011-09-12 12:52:33 +00:00
Echelon9 c17fbdbcfc Documentation: Code cleanup in flak.cpp and flak.h 2011-09-12 12:45:19 +00:00
Echelon9 7f6e6e0b03 Documentation: Remove the old CreditWins from credits.cpp. These were unused for some time 2011-09-12 12:38:36 +00:00
The_E debdb78531 A few fixes for the $Weapon Class scripting hook and associated actions 2011-09-12 12:35:08 +00:00
Echelon9 0ebe034272 Documentation: Big code cleanup of the collide**.cpp files 2011-09-12 12:34:49 +00:00
Echelon9 10f9ecac09 Documentation: Code cleanup of camera.cpp and camera.h, and removal of redundant function 2011-09-12 12:15:27 +00:00
IssMneur dedd73a3f5 Lets try this again without templates that VC6 doesn't like (this time for real).
Use const strings in split_str.
2011-09-12 05:14:58 +00:00
Goober5000 3597538bde revert 7705... it did, in fact, contain templates that VC6 doesn't like 2011-09-12 05:01:57 +00:00
IssMneur 10809783f9 Lets try this again without templates that VC6 doesn't like.
Use const strings in split_str.
2011-09-12 04:03:56 +00:00
Valathil a899b8601f Allow customization of the thruster distortion effect in species_defs.tbl and ships.tbl 2011-09-12 03:59:45 +00:00
Echelon9 eb56cc982d Documentation: Code cleanup of asteroid.cpp and asteroid.h 2011-09-11 13:56:10 +00:00
Echelon9 1f07c6fcb1 Documentation: Code cleanup of alphacolors.cpp 2011-09-11 13:38:17 +00:00
Echelon9 6c4e057035 Documentation: Code cleanup of afterburner.cpp 2011-09-11 13:36:33 +00:00
Zacam f779a5b8a8 Fix for Trunk r7677 causing map corruption on model cache rebuild. 2011-09-10 21:14:55 +00:00
Zacam b781d3220c From Goober5000: Fix for model read for 'submodel_get_two_random_points' failing to find any points in the POF 'defpoints' as reported by Nighteyes. 2011-09-09 15:13:23 +00:00
Zacam 83045f7d4c Some more Parity/drift correction between Antipodes and Trunk: cfile update for better handling. 2011-09-09 14:06:29 +00:00
Zacam f15c81fdd0 Part Three: Synchronization pass of Trunk and Antipodes Differences.
Catching on anything missed in the first two passes.
2011-09-09 10:38:14 +00:00
Zacam a63dbe572c Part Two: Synchronization pass of Trunk and Antipodes Differences.
Removes all extraneous ifdefs (Demo, E3, Multi Beta, etc).
Leaves Debug and Inferno.
2011-09-09 10:23:53 +00:00
Zacam 9678d18bc3 Part One: Synchronization pass of Trunk and Antipodes Differences.
Whitespace/tab mostly.
aicode does have a change of an Int3 to an Assertion.
bmpman has an update to bm_next_handle.
2011-09-09 09:37:45 +00:00
Zacam efaa50fd0c From Valathil: Fixes thrusters with -trans textures 2011-09-08 17:12:25 +00:00
Goober5000 6c2f4f3c30 PVS-Studio fixes:
V506	Pointer to local variable 'Default_video_settings' is stored outside the scope of this variable. Such a pointer will become invalid.	code	2d.cpp	507
V506	Pointer to local variable 'pos' is stored outside the scope of this variable. Such a pointer will become invalid.	code	shipfx.cpp	1075
2011-09-08 06:55:50 +00:00
Goober5000 fd4dc268d4 made show/hide jumpnode work on more than one argument 2011-09-08 06:41:38 +00:00
IssMneur 0717ad3d13 PVS-Studio fix: V512 A call of the 'memcpy' function will lead to overflow of the buffer '& x'. (pstypes.h:131) 2011-09-08 05:39:53 +00:00
IssMneur dd3404b441 PVS-Studio: These are not false positives. Variable args can only be PODs, changing the "class" to a structure makes ade_odata a POD which should stop PVS-Studio from flagging this. 2011-09-08 05:38:21 +00:00
Echelon9 3eb9602696 Documentation: Complete code clean up of the 3d/2d code 2011-09-07 14:33:26 +00:00
Echelon9 f1cd24101f Documentation: Code clean up in 3dlaser.cpp 2011-09-07 14:26:25 +00:00
Echelon9 dd99b7b035 Documentation: Code cleanup of 3ddraw.cpp 2011-09-07 14:22:03 +00:00
Echelon9 687b91d197 Documentation: Code cleanup to 2d.cpp, 2d.h and 3d.h 2011-09-07 14:10:41 +00:00
Echelon9 23d689e087 PVS-Studio fix: V512 A call of the 'memcpy' function will lead to underflow of the buffer 'szcode'. 2011-09-07 12:46:35 +00:00
Echelon9 6de5b02e77 Documentation: Code clean up of psnet2.cpp 2011-09-07 12:28:18 +00:00
Echelon9 dece779168 PVS-Studio fix (courtesy of niffiwan): V512 A call of the 'memcpy' function will lead to underflow of the buffer '& bit_24'. 2011-09-07 12:00:21 +00:00
Echelon9 9086c95131 PVS-Studio fix (courtesy of niffiwan): V512 A call of the 'memcpy' function will lead to underflow of the buffer (psnet2.cpp) 2011-09-07 11:58:47 +00:00
Zacam c946bc4a45 PVS-Studio fix (courtesy of niffiwan): V512 - A call of the 'memcpy' function will lead to overflow of the buffer '& ip_addr.sin_addr'. 2011-09-07 10:00:03 +00:00
Zacam 0dac515506 MSVC Analysis: Local declaration of <variable> hides previous declaration at <line> of <file>: 'Scene_texture_width'/'Scene_texture_height' in gropengldraw lines 56 & 57. 2011-09-07 09:57:37 +00:00
karajorma d7274c3714 Fix Mantis 2497 (SEXP help text not available in the ships editor) 2011-09-07 02:50:05 +00:00
Valathil 388fd3bb81 Delay transparent texture rendering to fix z-buffer ordering issues 2011-09-06 17:17:58 +00:00
Echelon9 f678baabde Documentation: Major code clean up of shield.cpp 2011-09-06 14:39:53 +00:00
Echelon9 6d245f7bc2 PVS-Studio fix: V524 It is odd that the body of 'multi_xfer_reset' function is fully equivalent to the body of 'multi_xfer_close' function (multi_xfer.cpp, line 185).
Remove duplicate, unused function
2011-09-06 12:29:56 +00:00
Goober5000 f3349119b8 end string at hash symbol for jump nodes too 2011-09-06 08:59:29 +00:00
karajorma 7e97177a75 Fix Mantis 2492 (Confusing help messages for the get-x-ammo SEXPs) 2011-09-06 02:29:47 +00:00
Goober5000 d94416f71b remove unreferenced variable 2011-09-05 19:50:26 +00:00
Echelon9 aacaa2d331 Documentation: Major code cleanup of ship.cpp 2011-09-05 14:30:34 +00:00
Echelon9 7d56f961e5 PVS-Studio fix (courtesy of niffiwan): V568It's odd that the argument of sizeof() operator is the '(short) method' expression. 2011-09-05 12:49:37 +00:00
Echelon9 1de8a20958 PVS-Studio fix (courtesy of niffiwan): This is a false positive, BUT IT REALLY SHOULD be rewritten with an STL container 2011-09-05 12:47:12 +00:00
karajorma 1fe4fdeaef Fix the cloaked ship flag not saving. 2011-09-05 00:05:20 +00:00
Valathil 02848eb577 Fixed a little misunderstanding of the collision query framework in the sun occlusion test 2011-09-04 20:01:34 +00:00
The_E 5ea6138708 A bit of cleanup here. Removed unnecessary "if (true)" and changed the sexp code to use the already written armor_type_get_idx function 2011-09-04 19:33:09 +00:00
Valathil 944ea0b367 Implemented Sun occlusion for Cockpit models and shown Ship models 2011-09-04 15:48:05 +00:00
Echelon9 47ce96863f PVS-Studio fix: Mark a false positive reported by niffiwan 2011-09-04 15:30:34 +00:00
The_E e63a8680f9 PVS Studio fix: V535 The variable 'j' is being used for this loop and for the outer loop. 2011-09-04 12:36:33 +00:00
The_E c187041e9f PVS Studio fix: Variable "item_index" was assigned values twice in succession 2011-09-04 12:35:14 +00:00
The_E d283d5800d Another false alarm from PVS Studio 2011-09-04 12:33:00 +00:00
The_E 834e383c26 Marking a bunch of PVS Studio warnings as false alarms. While the warnings are technically correct, none of these are in places where performance matters. 2011-09-04 12:31:33 +00:00
The_E 5bec06b168 PVS Studio fix: V803 Decreased performance. In case 'obji' is iterator it's more effective to use prefix form of increment. Replace iterator++ with ++iterator. 2011-09-04 12:14:35 +00:00
The_E b92c6402a4 More false alarms from PVS Studio 2011-09-04 12:13:31 +00:00
The_E 124138ae07 PVS Studio related: Mark false alarms as such 2011-09-04 10:14:17 +00:00
The_E 790dba1d3d PVS Studio related: Mark false alarms as such 2011-09-04 09:35:08 +00:00
The_E 383403967c PVS Studio fix: V510, class type argument passed to sprintf 2011-09-04 09:31:30 +00:00
The_E c14d9213d2 Change batch_render_* to use iterators 2011-09-04 08:19:21 +00:00
Swifty 8e2fbd8b9e Thrusters render in the proper position when drawing an auto centered model. 2011-09-04 06:54:09 +00:00
Goober5000 001baa29a2 remove unneeded Assert 2011-09-04 05:43:42 +00:00
Goober5000 bab303963b fix a bug from the waypoint conversion 2011-09-04 00:41:05 +00:00
Goober5000 0e278350d7 d'oh... in most cases, atoi(CTEXT(n)) should be eval_num(n) 2011-09-03 21:46:49 +00:00
Valathil 107f02d8d6 Fix tcache_set() OpenGL Errors by not using vertex attributes when drawing distortion Thrusters 2011-09-03 16:17:19 +00:00
Echelon9 e3c100d5fa Documentation: A few documentation fixes 2011-09-03 09:06:00 +00:00
Echelon9 67658b89c8 Documentation: A few documentation fixes so that Doxygen 1.7.5.1 outputs a clean log 2011-09-03 08:25:53 +00:00
Echelon9 eda7103399 PVS-Studio fix: V581 The conditional expressions of the 'if' operators situated alongside each other are identical. Check lines: 1281, 1312. 2011-09-03 05:38:28 +00:00
Echelon9 6c55c061c4 Suppress a PVS-Studio false positive 2011-09-03 05:34:08 +00:00
Echelon9 f701d00d0a PVS-Studio fix: V592 The expression was enclosed by parentheses twice: ((expression)). One pair of parentheses is unnecessary or misprint is present (starfield.cpp). 2011-09-03 05:31:12 +00:00
Echelon9 4f2574dddb PVS-Studio fix: V592 The expression was enclosed by parentheses twice: '((cur_sep > 0.9f * desired_sep))'. One pair of parentheses is unnecessary or misprint is present (aicode.cpp).
I think this is the right fix. In addition the code comments did not reflect what was happening, so I've updated these to reflect the if() comparison.
2011-09-03 05:20:27 +00:00
Goober5000 3b5512d60a whoops 2011-09-03 04:30:23 +00:00
Goober5000 725762bf35 The_E made the wrong fix; this is the right one 2011-09-03 02:34:14 +00:00
Goober5000 70a1873c86 a bunch of small PVS-Studio fixes (mostly duplicate assignments) 2011-09-03 02:25:39 +00:00
Goober5000 43cbdb0783 wl_fury_missile_offset_hack was only applicable for FS1 2011-09-03 02:21:20 +00:00
Goober5000 eee761ab79 PVS-Studio fix: V507 Pointer to local array 'name' is stored outside the scope of this array. Such a pointer will become invalid. code missioncampaign.cpp
(This is a Volition bug!  In all other locations, Campaign_file_names and Campaign_names are set using strdup.)
2011-09-03 01:48:06 +00:00
Goober5000 c7ddf2f619 PVS-Studio fix: V506 Pointer to local variable 'terminus' is stored outside the scope of this variable. Such a pointer will become invalid. 2011-09-03 01:45:56 +00:00
Goober5000 2ce8ca62cf PVS-Studio fix: V804 Decreased performance. The 'strlen' function is called twice in the specified expression to calculate length of the same string. 2011-09-03 01:32:07 +00:00
Goober5000 09bb4ab771 PVS-Studio fix: V804 Decreased performance. The 'strlen' function is called twice in the specified expression to calculate length of the same string. 2011-09-03 01:15:20 +00:00
Goober5000 ee4e1f2afa PVS-Studio fix: V805 Decreased performance. It is inefficient to identify an empty string by using 'strlen(str) != 0' construct. A more efficient way is to check: str[0] != '\0'.
(and sorry Kazan, you don't get to call your for statement a work of art if you use strlen inefficiently)
2011-09-03 01:05:00 +00:00
Valathil 22c4cf13da Changed Sun glow and lens flare rendering to not be obscured by objects 2011-09-01 19:35:17 +00:00
Valathil a67f2d4f29 Enable alpha channel on render to texture targets and provide scripting functions with alpha capabilities 2011-09-01 16:16:03 +00:00
Echelon9 45f8701e68 Documentation: Code cleanup of missionbriefcommon.cpp 2011-09-01 13:50:37 +00:00
Echelon9 4201582786 Let's have another go at this one... around we go again 2011-09-01 13:08:32 +00:00
karajorma 7df5137ac4 Fix a mismatch. 2011-08-31 14:06:19 +00:00
Echelon9 a20c658026 cppcheck fix: Memory leak in icon table parsing. 2011-08-31 13:53:14 +00:00
Echelon9 3063b2cd85 Undo my rather silly patch, apply niffiwan's patch as a temporary measure (at least). 2011-08-31 13:48:23 +00:00
Echelon9 2abd999dd9 PVS-Studio fix: V522 Dereferencing of the null pointer 'snd' might take place. Check the logical condition (autopilot.cpp) 2011-08-31 13:25:14 +00:00
Echelon9 9be05a4d7f PVS-Studio fix: V523 The 'then' statement is equivalent to the 'else' statement (psnet2.cpp).
This one was particular bad as it code have lead to remotely induced crashes over the network with oversize packets.
2011-08-31 13:12:46 +00:00
Echelon9 dc29308c31 PVS-Studio false positive: V581 The conditional expressions of the 'if' operators situated alongside each other are identical.(hudtarget.cpp) 2011-08-31 13:02:44 +00:00
Echelon9 81f5d8ee99 PVS-Studio false positive: V581 The conditional expressions of the 'if' operators situated alongside each other are identical. Check lines: 185, 189 (dscap.cpp) 2011-08-31 13:00:57 +00:00
Echelon9 bcb60d8bd0 PVS-Studio false positive: V537 Consider reviewing the correctness of 'y' item's usage (3dmath.cpp) 2011-08-31 12:58:58 +00:00
Zacam 64efa9f2fa Clean up the commented out code from niffiwan's PVS-Studio patches. (from niffiwan) 2011-08-31 10:58:33 +00:00
Zacam 10445ba0c3 MSVC Analysis C6244: Local declaration of <variable> hides previous declaration at <line> of <file>. (lock_world_pos; 31; hudlock.cpp) 2011-08-31 09:59:55 +00:00
Zacam def9877ade MSVC Analysis C6246: Local declaration of <variable> hides declaration of same name in outer scope. (wip, swp, objp, j) 2011-08-31 09:37:20 +00:00
Zacam e21235bfb9 Fix for 7590: Shipp can be NULL, which would lead to a crash. This resolves that crash from happening. 2011-08-30 22:59:57 +00:00
The_E 0525e871d0 PVS Studio related: Mark false alarms as such. 2011-08-30 17:46:49 +00:00
The_E 724f1be9d3 Removing the RELEASE_REAL define from ye olde ✌️ days. We really don't need it anymore. 2011-08-30 17:46:03 +00:00
The_E 9e8f902ed3 PVS Studio fix: V581 The conditional expressions of the 'if' operators situated alongside each other are identical. 2011-08-30 17:40:00 +00:00
Swifty fa54551e26 Engine glows no longer render when on the wrong side of a warp-in/out. 2011-08-30 17:39:48 +00:00
The_E 9d9d2d0eb2 PVS Studio fix: V576 Incorrect format. A different number of actual arguments is expected while calling 'Format' function. Expected: 2. Present: 3. 2011-08-30 17:29:56 +00:00
The_E 57fae21a9c PVS Studio fix: V567 Undefined behavior. The 'index' variable is modified while being used twice between sequence points. 2011-08-30 17:28:39 +00:00
The_E 27e0c1b3b2 PVS Studio fix: V547 Expression 'character <= 127' is always true. The value range of signed char type: [-128, 127]. 2011-08-30 17:26:57 +00:00
The_E 0ce71ca239 PVS Studio fix: V541 It is dangerous to print the string 'base' into itself. 2011-08-30 17:24:50 +00:00
The_E b15d864aac PVS Studio fix: V541 It is dangerous to print the string 'ani_name' into itself. 2011-08-30 17:23:01 +00:00
Echelon9 3453cc9c70 PVS-Studio fix: V576 Incorrect format. Consider checking the [third] actual argument of the 'sprintf' function. The SIGNED integer type argument is expected.
Fixes a number of this class of issue with sprintf formats.
2011-08-30 15:39:29 +00:00
Echelon9 a03118b88d PVS-Studio fix: V805 Decreased performance. It is inefficient to identify an empty string by using 'strlen(str) == 0' construct. A more efficient way is to check: str[0] == '\0' (missioncampaign.cpp). 2011-08-30 15:17:28 +00:00
Echelon9 a5bd4b9845 PVS-Studio fix: V523 The 'then' statement is equivalent to the 'else' statement (shipfx.cpp).
Also take opportunity to clean up the BSG warp effect code. That duplice if() else() had been included since the original WMC commit in r5261.
2011-08-30 14:32:10 +00:00
Echelon9 64d2e8b9fb PVS-Studio fix: V803 Decreased performance. In case 'aip->wp_index' is iterator it's more effective to use prefix form of decrement. Replace iterator-- with --iterator. 2011-08-30 14:06:03 +00:00
The_E e3039d3ea4 PVS Studio fix: V570 The 'end_angle.a1d [axis]' variable is assigned to itself. 2011-08-30 13:55:36 +00:00
The_E 2a723f78b0 PVS Studio fix: V547 Expression is always true. Unsigned type value is always >= 0. 2011-08-30 13:48:56 +00:00
The_E c7422150fc PVS Studio fix: V535 The variable 'i' is being used for this loop and for the outer loop. 2011-08-30 13:46:00 +00:00
The_E 003ed628c7 PVS Studio fix: V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 279, 287. 2011-08-30 13:40:36 +00:00
The_E 32bc367306 PVS Studio fix: "delete operator applied to non-pointer" 2011-08-30 13:38:33 +00:00
The_E 1aa806a3ab PVS Studio fix: duplicated "!strlen(filename)" check 2011-08-30 13:21:28 +00:00
Echelon9 5a0dc8f6b1 PVS-Studio (courtesy of niffiwan): V523 The 'then' statement is equivalent to the 'else' statement (techmenu.cpp). 2011-08-30 13:12:51 +00:00
Echelon9 8a4482c827 PVS-Studio fix (courtesy of niffiwan): V523 The 'then' statement is equivalent to the 'else' statement (missiontraining.cpp). 2011-08-30 13:06:28 +00:00
karajorma 7ca92457b4 PVS-Studio fix: V512 A call of the 'memset' function will lead to underflow of the buffer 'type'.
Never really would matter but it's a waste of memory declaring an int buffer and then only using 1/4 of it
2011-08-30 11:50:23 +00:00
Goober5000 2ef9fa11b6 add fire-beam-at-coordinates, which is as awesome as it sounds 2011-08-30 07:29:57 +00:00
Goober5000 3f1fcf2e71 having null iterators is apparently a no-no according to the C++ standard, so use a globally defined invalid iterator instead 2011-08-30 07:27:32 +00:00
karajorma af96b121b6 Gliding remains on when the player restarts a mission. 2011-08-30 04:12:55 +00:00
Goober5000 3ce69f150a waypoints and waypoint paths now have dynamic limits 2011-08-30 03:35:42 +00:00
karajorma caff640862 Documentation for the Multiplayer SEXP system. 2011-08-30 00:18:32 +00:00
Echelon9 9a76fcfe78 PVS-Studio fix: V515 The 'delete' operator is applied to non-pointer (hud.cpp). 2011-08-29 16:08:03 +00:00
Echelon9 e58723d589 PVS-Studio fix (Courtesy of niffiwan): V523 The 'then' statement is equivalent to the 'else' statement (barracks.cpp and missionhotkey.cpp). 2011-08-29 13:19:58 +00:00
Echelon9 b55516dfdb Documentation: Code cleanup of sexp.cpp 2011-08-28 15:10:07 +00:00
Echelon9 a5249cf57c Reverting 7545: Due to some odd errors coming through as Asserts in cfile.cpp 2011-08-28 12:48:20 +00:00
Echelon9 81c9c92479 PVS-Studio fix: V516 Consider inspecting an odd expression. Non-null function pointer is compared to null: 'jumpnode_get_by_name == 0' (sexp.cpp).
Ironic that check_sexp_syntax() appeared to have a mistake in it's check functions.
2011-08-28 09:49:02 +00:00
Echelon9 5386b9da7c PVS-Studio fix: V555 The expression '(now - bi->last_down_check) > 0' will work as 'now != bi->last_down_check'.
Due to unsigned int type wrapping the former code would have always returned true.
2011-08-28 09:41:54 +00:00
Echelon9 9c0edf2d64 Documentation: Code cleanup in multi_obj.cpp 2011-08-28 09:36:18 +00:00
Echelon9 66dd978878 PVS-Studio fix: V519 The 'num_users' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 2296, 2297 (multi_pxo.cpp) 2011-08-28 09:34:09 +00:00
Echelon9 91f01706fd PVS-Studio fix: V519 The 'player_index' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 1389, 1392 (multi_obj.cpp) 2011-08-28 09:32:55 +00:00
Echelon9 9bd9ea619d PVS-Studio fix: V519 The 'list_size' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 597, 604 (gropenglpostprocessing.cpp) 2011-08-28 09:31:21 +00:00
Echelon9 b765ca37b9 PVS-Studio fix: V519 The 'path_index' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 12782, 12809 (aicode.cpp) 2011-08-28 09:30:07 +00:00
Echelon9 cb07f76f6c Documentation: Clean up lua.cpp 2011-08-28 08:54:10 +00:00
Echelon9 80a027a400 PVS-Studio fix: V803 Decreased performance. In case 'tvs' is iterator it's more effective to use prefix form of increment. Replace iterator++ with ++iterator.
For further discussion see, http://www.viva64.com/en/b/0093/

The scenarios where it will improve performance are under Debug builds. This improvement will however allow quicker use of other profiling tools that need to run on Debug builds.

Note. Code with size_t does not see the performance improvement comparison to iterators due to absence of array overrun check.
2011-08-28 08:31:25 +00:00
Echelon9 2226ca29d8 Revert r7546 -- will need more work. 2011-08-28 07:39:56 +00:00
Echelon9 34084aebe6 PVS-Studio fix: V501 There are identical sub-expressions '(stricmp (szCmd, "372") == 0)' to the left and to the right of the '||' operator.
and 

V501 There are identical sub-expressions '(stricmp (szCmd, "375") == 0)' to the left and to the right of the '||' operator.
2011-08-28 07:27:53 +00:00
Echelon9 2d01954585 PVS-Studio fix: V802 On 32-bit platform, structure size can be reduced from 80 to 76 bytes by rearranging the fields according to their sizes in decreasing order. 2011-08-28 07:16:42 +00:00
Echelon9 9fa25a9ae4 PVS-Studio fix: V802 On 32-bit platform, structure size can be reduced from 50 to 48 bytes by rearranging the fields according to their sizes in decreasing order. 2011-08-28 07:08:40 +00:00
Echelon9 58b77fb8f9 PVS-Studio fix: V802 On 32-bit platform, structure size can be reduced from 52 to 48 bytes by rearranging the fields according to their sizes in decreasing order. 2011-08-28 07:03:57 +00:00
Echelon9 93622a3748 PVS-Studio fix: V802 On 32-bit platform, structure size can be reduced from 40 to 32 bytes by rearranging the fields according to their sizes in decreasing order. 2011-08-28 07:00:38 +00:00
Echelon9 499c698ba8 PVS-Studio fix: V802 On 32-bit platform, structure size can be reduced from 24 to 20 bytes by rearranging the fields according to their sizes in decreasing order. 2011-08-28 06:55:00 +00:00
Echelon9 a93f7d50fd PVS-Studio fix: V802 On 32-bit platform, structure size can be reduced from 28 to 24 bytes by rearranging the fields according to their sizes in decreasing order. 2011-08-28 06:50:02 +00:00
Goober5000 7931831cbe add dynamic vector stuffing 2011-08-28 03:31:46 +00:00
Goober5000 13366ad45b add linked lists, woot 2011-08-27 05:27:24 +00:00
Goober5000 9ef2aac09a return special exp values to ints, per discussion with Zacam awhile ago
while we're at it, change kamikaze damage to int since it's treated as such
2011-08-27 05:08:39 +00:00
Goober5000 7f5d1b362f enhance end-mission to possibly dump player to main hall 2011-08-27 04:39:18 +00:00
Goober5000 3b2b76206f add infrastructure and parsing support for mission forks (vs. mission loops)
mission fork interface art and selection logic still needs to be written
2011-08-27 03:57:16 +00:00
Zacam c6beca2629 Fix for Mantis 2467: untargeted heat seekers ignore ship protect
from niffiwan: http://www.hard-light.net/forums/index.php?topic=78001.0
2011-08-26 00:17:45 +00:00
Zacam 2115469681 Alt Name field for ships not being set was interfering with displaying the ship class or name in the loadout screen when selecting a weapon said ship could not carry. This fixes that. From Wanderer, via Karajorma. 2011-08-25 07:33:49 +00:00
Zacam 9bbc485f0c Slight update to optimize the built in main-f.sdr. 2011-08-25 02:42:05 +00:00
karajorma 7952433415 I've already removed this section of code once! Let's see if it stays out this time! 2011-08-25 02:36:10 +00:00
Sushi 04af101eda Add "$Max Turrets per Bomb" and "$Max Turrets per Target" turret attributes. Allow per-turret control over maximum number of targeted bombs and ships (respectively). Works like "$Max Turret Target Ownage" but on a per-turret basis, and with the ability to affect incoming bombs as well. 2011-08-25 01:33:44 +00:00
Echelon9 0b17acff72 Documentation: Cleanup a few comments in pstypes.h 2011-08-24 21:27:07 +00:00
The_E fe0ec8dffa Update for the ad.playMusic() function so that it accepts a volume parameter 2011-08-24 15:20:04 +00:00
Echelon9 d208740bcd PVS-Studio fix: V524 It is odd that the body of 'ds_eax_set_preset' function is fully equivalent to the body of 'ds_eax_set_environment' function (ds.cpp, line 2091). 2011-08-24 15:06:22 +00:00
Echelon9 a47f5b4069 PVS-Studio fix: V525 The code containing the collection of similar blocks. Check items 'Scene_color_texture', 'Scene_color_texture', 'Scene_depth_texture' in lines 2073, 2076, 2079. code gropengldraw.cpp 2011-08-24 14:56:48 +00:00
Echelon9 c2e41e4a95 PVS-Studio fix: V524 It is odd that the body of 'l_Object_getrvec_f' function is fully equivalent to the body of 'l_Object_getfvec_f' function (lua.cpp, line 4735). 2011-08-24 14:52:05 +00:00
Echelon9 dbcce6b112 PVS-Studio fix: V524 It is odd that the body of 'fireball_level_close' function is fully equivalent to the body of 'fireball_close' function (fireballs.cpp, line 970). 2011-08-24 14:48:17 +00:00
Echelon9 a248a37d58 PVS-Studio: Fix V805. Decreased performance. It is inefficient to identify an empty string by using 'strlen(str) > 0' construct 2011-08-24 13:37:01 +00:00
karajorma 56f758967a Fix several SEXPs for multiplayer use. This should fix Mantis issues 2401, 2483 and 2382.
In addition, fix a bug caused by SEXPs that do a callback but don't send any data.
2011-08-24 08:37:11 +00:00
Goober5000 f5ad44950a change the units on rotation acceleration to bring them in line with rotational velocity
this is not a compatibility break because acceleration didn't work until just a few days ago :D
2011-08-24 02:41:07 +00:00
Goober5000 b232661a78 supposedly these two checks were forgotten 2011-08-24 02:23:44 +00:00
The_E 94bb513f0f Another FXAA change to stop it from murdering our pretty pretty starfields. 2011-08-23 19:07:58 +00:00
The_E 34e7c0c927 Removing a preprocessor define from the fxaa fragment shader that we're not using. 2011-08-23 18:41:19 +00:00
Echelon9 745ec904d5 Documentation: Minor tweaking to ai.cpp 2011-08-23 13:50:24 +00:00
Zacam ec58a7388f Formating the shaders entries for soft particles to match the rest of the shaders. 2011-08-22 22:18:06 +00:00
Zacam c8d0e343e2 From jg18: Platform flag exclusion, Soft Particles wiki link.
(reformatting/spacing is mine)
2011-08-22 22:17:34 +00:00
Valathil da6727d9d1 Let's try this again. Adding Framebuffer distortion thrusters and explosions. 2011-08-22 17:57:01 +00:00
The_E 14ac7a3cbf object:checkRayCollision() for scripting, from m!m 2011-08-22 12:57:01 +00:00
karajorma 9aa338ecd8 Add a version of the event-true-delay SEXP which works using milliseconds rather than seconds. 2011-08-22 10:44:41 +00:00
Goober5000 a74ae93a14 wow... it looks like the subsystem acceleration sexp never worked until now... 2011-08-22 08:38:02 +00:00
Goober5000 f492ce292c revert 7508, which MSVC6 doesn't like 2011-08-22 07:58:00 +00:00
IssMneur 80d3b0ed84 - make split_str use const strings were appropriate.
- make brief_color_text_init use const strings where appropriate.
2011-08-21 17:05:04 +00:00
Zacam 583f5c976f Revert 7498: You should also test without optional command lines present, yellow disco screens of death in-mission are bad. 2011-08-21 04:04:45 +00:00
Goober5000 b1ad28efdb add an option to fire-beam to force the beam to fire
combine fighter_beam flag into flags field
2011-08-21 01:11:24 +00:00
Goober5000 6346fc6de6 fix string length 2011-08-21 00:43:31 +00:00
Goober5000 8e27e23acc Zacam's patch for bringing MSVC 2005 up to date 2011-08-21 00:29:11 +00:00
Valathil 89da5f6fdc Added thruster heat distortions and explosion framebuffer effects 2011-08-20 23:31:07 +00:00
Swifty fe605149c4 Soft sphere sprite rendering for particles, explosions, shockwaves, and thrusters. 2011-08-20 22:14:52 +00:00
Sushi 68b036a4af Add "Fog Near Multiplier" and "Fog Far Multiplier" options for missions. Allows the FREDder to tweak distances at which ships fade out in a nebula. 2011-08-20 15:06:18 +00:00
Goober5000 bc1b977c77 rewrite facing and is-facing to be more clear; I think I also fixed a bug in the process 2011-08-20 08:25:39 +00:00
Goober5000 5a28b96872 the key should be in the training category along with the other key sexps 2011-08-20 05:55:14 +00:00
Valathil 9c5e18225e Fixed a crash in the Ship effect SEXP so it doesn't crash the game if you try to cloak a wing with destroyed/departed/vanished ships. 2011-08-19 14:49:04 +00:00
karajorma c56684cf43 Fix Mantis 2397 (Variables do not use more than one column when using replace data or replace variable unlike all other data) 2011-08-19 10:10:53 +00:00
karajorma 4dfa577114 Add options to send objects, shorts and ushorts via the multiplayer SEXP system. 2011-08-19 08:09:50 +00:00
Goober5000 ce48784a5f add some sanity protections against overstuffing arrays 2011-08-19 04:39:12 +00:00
Goober5000 017699d8a3 minor tweaks 2011-08-19 04:32:24 +00:00
The_E bb2c773d7b Fix for Mantis 2484: Default text length for EFF files was far too short. 2011-08-18 20:21:05 +00:00
Echelon9 555a9033de Documentation: General clean-up and function documentation 2011-08-18 16:47:54 +00:00
karajorma 77745bdb75 Doh, missed one! 2011-08-18 07:56:31 +00:00
karajorma 1a577f6473 Fixes and clean up for the multiplayer SEXP packet system.
- Make the system more robust against accidental attempts to write data to the packet without proper initialisation. 
- Improve the error messages and function names to make clear the difference between the packet the game actually sends and the abstracted packets the coder seems to create and send in sexp.cpp
- Add a convenience methods to deal with SEXPs that don't need to write any data.
2011-08-18 07:48:59 +00:00
karajorma df0722f929 Fixes for the multiplayer SEXP packet to prevent errors caused by the coder taking too little data out of the packet before reporting that they are done. 2011-08-18 05:24:27 +00:00
Echelon9 13d8c4e97c Diaspora feature: Control configs override and default table 2011-08-17 14:40:13 +00:00
karajorma dc980ecc21 Halleck's bomb scoring code 2011-08-16 09:45:14 +00:00
Goober5000 a60c3d5a2d compilation fix 2011-08-16 04:55:47 +00:00
IssMneur 9395281267 From jg18: Add some missing wiki urls in the flag file output. 2011-08-14 23:10:08 +00:00
Zacam 608880bae5 Fred2 Open debug log now records build version data, just like fs2_open.log.
Updated the fs2_open.log output to declare "FreeSpace 2 Open version" instead of just "FreeSpace version"
2011-08-14 16:42:47 +00:00
The_E d5c065bf74 When loading FXAA shaders, always use the built-in defaults. 2011-08-14 15:08:28 +00:00
Echelon9 639fd1951a PVS-Studio fix: Expression 'b->type < 0' is always false. Unsigned type value is never < 0. 2011-08-14 14:07:11 +00:00
Goober5000 570aaf88ae change warnings to mprintfs 2011-08-14 08:42:50 +00:00
Zacam 0054d25e0b Shader Update: main-f updated with latest cloaking code. small amount of cleanup done as well. 2011-08-14 02:36:33 +00:00
Echelon9 37097f2d83 PVS-Studio fix: Duplicate comparison check for stricmp('FRED2_Open', scp->data.name). Instead use the second comparison to check for the same naming format as stricmp('FS2Open', scp->data.name) 2011-08-13 08:22:51 +00:00
Echelon9 c45aa93a9a PVS-Studio fix: Calling empty() on an STL vector does not modify the content of the vector in any way. To clear, use clear(). In addition, this commit also fixes the spelling of the containing function and turns on Doxygen documentation. 2011-08-13 08:19:55 +00:00
Echelon9 3a9f72c231 PVS-Studio fix: A call of the 'memset' function will lead to underflow of the buffer 'txt'. In HudGaugeMultiMsg::render() 2011-08-11 15:31:44 +00:00
Echelon9 ddb6039161 PVS-Studio fix: The '&' operator is applied to bool type value. You've probably forgotten to include parentheses or intended to use the '&&' operator. In UI_SLIDER2::draw() 2011-08-11 14:59:16 +00:00
Echelon9 5b60b84cfd PVS-Studio: The '&' operator is applied to bool type value. You've probably forgotten to include parentheses or intended to use the '&&' operator. In process_event_update_packet() 2011-08-11 14:56:43 +00:00
Echelon9 71255d6ba5 PVS-Studio: A call of the 'memset' function will lead to underflow of various buffers in multi code. 2011-08-11 14:53:11 +00:00
Echelon9 f25f912848 PVS-Studio fix: Fix r5260 - A call of the 'memset' function will lead to underflow of the buffer 'Valid_builtin_message_types'. 2011-08-11 14:35:03 +00:00
Echelon9 fe1c83e4eb PVS-Studio fix: Expression 'i >= 0' is always true. Unsigned type value is always >= 0. 2011-08-11 14:18:26 +00:00
Echelon9 2808f6624d PVS-Studio fix: Expression 'idx < 0' is always false. Unsigned type value is never < 0. 2011-08-11 14:15:05 +00:00
Echelon9 682936b8d7 PVS-Studio fix: XYZ co-ordinated were not correctly copied and pasted in parse_ship_values() 2011-08-10 16:11:29 +00:00
Zacam 1c4dacdafc Logging update: Major/Minor/Build update so that "Build" will always be available/log correctly even when "0" (ex: 3.7.0) without also needing "Revision" present. 2011-08-10 14:23:51 +00:00
Echelon9 f2f77ccc5f PVS-Studio fix: This if...then...else block was redundant in HudGaugeSupport::render(), as each 'then' block did the same thing 2011-08-10 14:01:15 +00:00
Echelon9 148c68b9f4 PVS-Studio fix: This if...then...else block was redundant in player_select_init(), as each 'then' block did the same thing 2011-08-10 13:58:25 +00:00
Echelon9 e7f07441f9 PVS-Studio fix: Incorrect logic within ping time colour indicator in multi_join_display_games() was overrepresenting yellow at the expense of red. Also replaced magic number with a definition. 2011-08-10 13:55:33 +00:00
Echelon9 913c4effe7 PVS-Studio fix: No need to set sinfo variable again immediately after first assignment to a different value in send_secondary_fired_packet() 2011-08-10 13:51:31 +00:00
Echelon9 283753bffa PVS-Studio fix: No need to set Current_stage variable again immediately after first assignment to a different hard coded value 2011-08-10 13:49:42 +00:00
Echelon9 139bb5afa9 PVS-studio fix: Ensure that both x and y of Player->current_target are reset correctly in hud_lock_determine_lock_point() 2011-08-10 13:47:06 +00:00
Echelon9 8531488d1b PVS-Studio fix: Remove duplicate if...then conditional within fs2netd_get_pilot_info() 2011-08-10 13:45:14 +00:00
Echelon9 127ac8d051 PVS-Studio fix: Remove duplicate if...then conditional within ai_process() 2011-08-10 13:43:18 +00:00
Echelon9 989916e0a7 PVS-Studio fix: Correct duplicate attempt to set the docker_aip->support_ship_signature in ai_do_objects_undocked_stuff() 2011-08-10 13:40:53 +00:00
IssMneur 973efc2865 From jg18: various polish details and a description clarification, based from descriptions within sandmanjack's launcher 2011-08-09 04:37:59 +00:00
Swifty f6ba2141b4 Shockwaves and death explosions will stay oriented independently of player's bank. 2011-08-07 09:55:18 +00:00
The_E abd7134e0e ALtered according to feedback from Valathil. 2011-08-06 19:11:43 +00:00
IssMneur 1c130bbc8a From Valathil: Fixes a problem with a min-max lifetime smart spawn weapons where it wouldn't fire except at close range 2011-08-06 18:20:34 +00:00
The_E 20346118c6 Another sprite rendering fix from Valathil 2011-08-05 21:39:14 +00:00
Swifty f35b322397 Ship-specific gauges will only get preprocessed once. 2011-08-05 09:06:31 +00:00
The_E 154f90823c Another sprite rendering fix from Valathil 2011-08-04 21:46:21 +00:00
The_E 55427f1690 Patch for sprite orientation from Valathil 2011-08-04 16:25:19 +00:00
Zacam 7cb68f6de2 Resolves MSVC complaint about "'i' : unreferenced local variable" for the size_t in "void game_render_hud(camid cid)" 2011-08-04 13:58:46 +00:00
The_E e6f0e0e956 Ooops, meant to use a pointer there. 2011-08-04 13:34:33 +00:00
The_E 4dd9021e9c Resolve an "uninitialized Variable" warning 2011-08-04 13:33:35 +00:00
The_E aa9bb91dd7 And another one. 2011-08-04 13:17:55 +00:00
The_E 300ee6f9e9 Slight correction to make nvidias GLSL compiler happy 2011-08-04 13:16:32 +00:00
The_E ac8b7c4c10 From m!m: Adds access to collision data to the Lua API. 2011-08-04 11:05:25 +00:00
Swifty 5283c36d34 Let's try this again without breaking the orb radar: Optimized BSG radar and cockpit displays. Fixed cockpit models not switching when changing ships. 2011-08-04 11:01:28 +00:00
The_E 47b1f57435 Adding the function "ship::addShipEffect(string name, int duration)" to the LUA API. 2011-08-04 10:58:28 +00:00
IssMneur bb75f7fc4e Move clear-subtitles to the camera subcategory in FRED. 2011-08-03 04:12:46 +00:00
The_E 4a488dd7f0 Reverting 7411 due to it breaking the standard 3D radar. 2011-08-02 13:02:34 +00:00
Swifty 043d56b3f7 For Diaspora: Optimized BSG radar rendering and cockpit displays. Fixed cockpit models not switching when changing ships. 2011-08-02 10:49:51 +00:00
The_E 43e220aa68 Fix for issue with the weapon select sound not playing when weapon_choice_3d was active 2011-08-01 20:39:31 +00:00
IssMneur 64ff2ba5a5 Complain correctly about pilot name length (actually say that the name is too long rather than just an assert). 2011-08-01 20:10:51 +00:00
The_E ab30a9662d Updating the internal shaders a bit 2011-08-01 18:38:04 +00:00
The_E 91e54218a7 Correcting a little oversight with the $Selection Effect: tbl entries 2011-08-01 18:06:58 +00:00
The_E fd29f15e12 Make external weapon models cloak when the mothership is cloaking. 2011-08-01 11:56:06 +00:00
The_E ebf412d9f4 From Valathil: Allow shader effects to be less wrong if the Post-processing framebuffer is not active 2011-07-31 20:37:42 +00:00
The_E d366751420 Request by MjnMixael: clear-subtitles sexp 2011-07-31 20:35:34 +00:00
The_E 245ed41f71 Moving ai_profiles parsing up a few lines to fix issue with $Default Weapon select effect 2011-07-31 20:21:35 +00:00
Echelon9 e4125bab11 Picked up by MSVC analyser: Lock down these cases of unsafe string operations 2011-07-31 13:41:13 +00:00
Echelon9 7d8ec67a99 Fix Apple support for vglDrawBuffers, part of the new shader code 2011-07-31 08:03:04 +00:00
The_E 43c6cd2539 Updating the sexp description 2011-07-30 23:21:28 +00:00
The_E 4c919f0a59 Fixes issue with post_processing.tbl parsing 2011-07-30 22:45:53 +00:00
The_E 2dc34f3e1f This is the correct version now. 2011-07-30 22:39:49 +00:00
The_E 7f219cad2c Reverting due to bugs 2011-07-30 22:32:09 +00:00
The_E 3a702bdc1a This should have been committed as well 2011-07-30 21:43:30 +00:00
The_E 32c5491d83 Adding support for the new cloaking effect. 2011-07-30 21:13:02 +00:00
The_E c1ed95995d Fixes issue regarding UI sounds and built-in retail ship/weapon effects being of different length. 2011-07-30 19:49:49 +00:00
karajorma 04348d856d Ignore-key SEXP and the changes needed to support it. 2011-07-30 18:54:02 +00:00
The_E 466441a58b Slight fix for issue with SSMs hitting the player ship 2011-07-30 07:31:24 +00:00
The_E 9e423a8bca Fixes issue with Default ship/weapon select ai_profiles entries. 2011-07-29 13:53:35 +00:00
The_E 23f7fcfd07 Woops, built-in shader was incorrect 2011-07-27 14:44:43 +00:00
The_E 8fb2085a9d Adding the realtime ship/weapon select effects by Valathil. 2011-07-26 22:02:12 +00:00
Zacam 9d212a5f07 From Plombo: sets "force_s3tc_enable" for some linux drivers to be able to render DDS textures.
http://www.hard-light.net/forums/index.php?topic=77196.0
2011-07-25 22:10:32 +00:00
The_E 83d1fe8f5f Update to FXAA 3.11 2011-07-23 10:14:36 +00:00
Echelon9 ea27c04867 Documentation: Resolve a Doxygen warning on the unpack_frame() and unpack_frame_from_file() functions 2011-07-23 04:38:16 +00:00
Zacam 96925143c1 Resolves SSE detection issues on #including <xmmintrin.h> for GCC/G++ and MSVC6.
GCC/G++ users (Apple, Linux) should look to adding intrinsics to their compile options. (-msse)
2011-07-23 02:07:19 +00:00
The_E 76dfdc4ba7 Another change to make compilers happy. This time, it's ATi's turn. 2011-07-22 20:54:46 +00:00
Zacam f2cc1239dd If we declare inv2A as a float up top, we no longer need to brace out any instances which resolves cross initialization as well as still allowing MSVC6 to remain operational (per 7372). Minor formating cleanup as well.
Thanks to Goober and Plombo for feedback.
2011-07-22 18:32:22 +00:00
Goober5000 96736a29ea fix compile problems on MSVC6 2011-07-22 05:56:46 +00:00
Goober5000 8dac846455 fix Mantis #2474 2011-07-22 05:55:04 +00:00
Goober5000 6422ac62e0 revert 7368: these are most certainly not graphics options 2011-07-22 05:13:28 +00:00
The_E 646046538c Small change to make nvidias' GLSL compiler happier 2011-07-21 20:44:26 +00:00
The_E 39a1a01a63 Moving the -window and -fullscreen_window cmdline options to the "Graphics" section 2011-07-21 16:29:49 +00:00
The_E bbae282db5 Update FXAA to 3.10. Also changes the fxaa preset selection method to recompile shaders when preset changes, should yield some speed improvements. 2011-07-21 12:18:37 +00:00
Zacam 6e8265278a This is not a repeat of 7340/7344. It is necessary however that we be able to tell users the value found before we reset it to zero, otherwise the warning will only ever return 0 instead of the bogus value. 2011-07-21 06:02:42 +00:00
The_E 7f5c3d343e Valathil's code cleanup patch. 2011-07-20 18:04:43 +00:00
The_E a61116b42b Remove unreferenced variable. 2011-07-20 15:54:28 +00:00
The_E 519819b550 More lighting patches from Valathil 2011-07-20 15:27:59 +00:00
The_E 60c4ca8eb3 Changing this Warning to an mprintf. We really do NOT want to generate warnings with retail data, don't we? 2011-07-19 22:00:27 +00:00
The_E 1d3aa79e6b Split the fxaa shader in two for better compiler compatibility 2011-07-19 21:51:37 +00:00
The_E 084465a613 Updating the built-in fxaa shaders to 3.9 2011-07-19 18:23:32 +00:00
Echelon9 c6d0f6170d For Valathil: Fix distance check in beam.cpp 2011-07-19 13:25:42 +00:00
The_E c57dd1ed07 From m!m: Gives scripting access to debris chunk size data 2011-07-18 17:58:49 +00:00
Sushi bbfc33eb40 Revert 7340 and 7344, since they derped hard. (Kept 7341) 2011-07-18 14:54:41 +00:00
Zacam 1e7caaccda Update:
libpng now at 1.5.2 (with update to pngutils)
zlib now at 1.2.5
(Files are in "LF" instead of "CRLF" this time around.)
MSVC6-2010 and XCode project updates included.
2011-07-17 05:46:14 +00:00
Zacam 1e7c5e65b3 Update to Post_Processing for split controls on Brightness and contrast.
Spacing/formatting clean-up.
2011-07-17 04:39:10 +00:00
Zacam 8cbffd6065 From Valathil: Beams now use Tube lighting. Updates to main shaders accordingly. 2011-07-17 04:36:00 +00:00
Swifty 6488b73b0a Corrected directive gauge to use both X and Y offsets. 2011-07-14 07:08:53 +00:00
The_E 7b2c8f7086 From Valathil: Do light sorting only once per object 2011-07-13 09:03:03 +00:00
Goober5000 a308e6f45f Valathil's fixes for #weak weapon variants
http://www.hard-light.net/forums/index.php?topic=77060.0
2011-07-13 07:33:29 +00:00
Zacam 513d2d7182 Copeh Pasteh does not make for al dente. 2011-07-11 19:09:10 +00:00
Goober5000 2eb4bb3aec deal with string truncation on MSVC6 2011-07-11 02:10:48 +00:00
Goober5000 bff6c5d16d Valathil's method will fail on a string that is less than 60 chars and does not contain a :, so use memset, which is the historical technique 2011-07-11 02:05:27 +00:00
Zacam cc46867722 Additional warning messaging for parsing the ai_profiles.tbl or -aip.tbm. 2011-07-10 17:21:33 +00:00
Zacam 8438530258 From Valathil: ai_profiles tbl/tbm will now parse set_flags and warn on unrecognized declarations when found.
Credits to Spoon and WoD for unveiling this over-sight.
2011-07-10 17:05:57 +00:00
The_E 53428e2b62 Reverting 7334 and 7333, following feedback from valathil 2011-07-09 13:14:49 +00:00
Echelon9 872f8589b7 Fix r7325: Asset() =/= Assertion() 2011-07-07 12:59:38 +00:00
Zacam 1dd78de5ff Directional Lights sorting probably should not have been flipped, the rest seem to be okay though.
(Sun facing sides of ships were going pitch dark when lots of beams were active)
2011-07-06 23:07:09 +00:00
Zacam a312b49bc9 From Valathil: Correction to commit 7292. Light sorting now takes place in the proper order. 2011-07-06 20:55:45 +00:00
The_E 4fdfd96b8f Major change to FXAA. Now doing a prepass to convert the main shaders' RGBA output into RGBL. Also enables minor speedup for OpenGL 4/4.1 capable chips. Default preset changed to 6. 2011-07-06 10:48:56 +00:00
Goober5000 0244c64214 a wee bit more is needed 2011-07-06 05:06:22 +00:00
Goober5000 b175a91843 make things compile 2011-07-06 04:44:25 +00:00
Goober5000 eeeb1a8898 don't assert on a benign conflict 2011-07-06 04:39:40 +00:00
IssMneur 2272fd28e2 From Valathil: Vary the intensity of lighting from warp fireballs (wormhole) based on the radius of the fireball. 2011-07-06 04:22:09 +00:00
The_E 4fa70b61db New FXAA shaders. These have an increased preset range, going from 0 to 9 inclusive. Presets 0 - 4 use the "Console" version of the algorithm, 5 - 9 get the "PC" version 2011-07-05 12:35:18 +00:00
The_E 9db07896e1 Wasn't supposed to change this 2011-07-04 14:59:12 +00:00
The_E 28bbbdab09 Reverting, due to unforeseen consequences 2011-07-04 14:55:07 +00:00
The_E 48610b1de5 Small update to the FXAA shaders. Also adds a function for shader uniform access that was previously missing. 2011-07-04 13:59:02 +00:00
karajorma d6767809b1 Add a separator between paste and add paste in the event editor. 2011-07-04 02:22:26 +00:00
Zacam c284047c36 I should sleep more. 7307 was to add a "{ "glUniform4fARB", 0 }," not another v. 2011-07-03 14:44:16 +00:00
The_E 5674ce0c3e Updating these to current official versions 2011-07-03 08:40:21 +00:00
The_E b6548dfb50 And -oldfire, which does nothing, goes to the grave. 2011-07-02 19:45:46 +00:00
The_E eaf03bb480 And -safeloading bites the dust too. 2011-07-02 19:43:02 +00:00
The_E e23da70624 Removing several deprecated/unused cmdline options. Victims this round are: -cell, -timerbar and -d3d_bad_tsys 2011-07-02 19:33:23 +00:00
Zacam e0ae11af61 Fix for SSM usage causing Assert. If warp lifetime must be 4 seconds or greater, how about we warn them (in parsing) before they try and use it (and thus set it to at least 4.0) instead?
Thanks to bigchunk1 for catching this one and to IssMneur for the assist and review.
2011-07-02 05:07:57 +00:00
Zacam c2452b69fa This is the right way to do it.
Correct version of 7304.
2011-07-02 01:02:26 +00:00
Zacam 54644adfb8 ...but apparently not that way. 2011-07-02 00:14:04 +00:00
Zacam 9f00e84edf OGL_UNIFORM4FV should be (and now is) preceded by OGL_UNIFORM4F. 2011-07-01 23:37:30 +00:00
The_E 5d210146e3 Built-in bloom shader adjusted for higher quality 2011-07-01 19:09:25 +00:00
The_E ff7b3cdaaf Minor typo correction. Thanks to Valathil for finding it. 2011-07-01 19:00:57 +00:00
The_E f768943284 Swifty's collision detection improvements. 2011-07-01 17:00:31 +00:00
The_E f22bef9b5e Another small change to the built-in shaders 2011-07-01 11:33:09 +00:00
The_E c806651d11 From Valathiel: enables light sorting. Reduces light flickering in some cases. 2011-07-01 10:00:55 +00:00
The_E 9d6e0936cd Minor adjustment to the built-in shaders 2011-06-30 10:06:01 +00:00
The_E a46de9340f Fix for Mantis 2395: Introduces troubleshooting flag to switch between using glDrawElements and glDrawRangeElements 2011-06-28 20:20:25 +00:00
The_E aaba640733 Fix for Mantis 1983: Do not process lightning info when in standalone mode 2011-06-28 19:48:20 +00:00
The_E d60e3787d1 Fix for Mantis 2424: Crashes in multiplayer when <Wingname> 1 is not a player ship 2011-06-28 19:24:13 +00:00
The_E 3a451f36b5 When will I get it right.... 2011-06-28 14:13:21 +00:00
The_E a955dfa6dc Aaaargh, messed up AGAIN. 2011-06-28 14:10:23 +00:00
The_E 28e82d9c5b Ooops, fucked this one up a bit. 2011-06-28 14:07:34 +00:00
The_E 28db0bfe1f How did these values start colliding all of a sudden? Must have been my fault, sorry. 2011-06-28 09:38:06 +00:00
The_E 59cbde3d9e Adds sexps to manipulate a ships' collision groups. If two objects are members of the same collision group, they will not collide with each other. 2011-06-28 08:36:54 +00:00
Goober5000 e4266af9cf add string-get-substring, string-set-substring, and string-get-length; needed for Blue Planet 2011-06-28 04:08:59 +00:00
Zacam 524099c68e Some "\n"'s to help with logging during multi. "Scoring:" wasn't using any, so it would run on the next item right at the end. 2011-06-28 01:03:03 +00:00
The_E c57ede0cc1 Adding a piece of sanity checking here, to avoid crashing the release build under certain strange circumstances 2011-06-27 22:16:41 +00:00
The_E a60d32e669 Disable warning that is meaningless ("why are G_predicted_pos and G_fire_pos the same?"), and only serves to confuse people. 2011-06-27 13:52:45 +00:00
The_E fb21bc4272 Patch for Mantis 2050: Renaming the log file may cause crashes 2011-06-27 13:45:19 +00:00
The_E 4b5d6f939a From m!m: Patch for Mantis 2459 (Calling ts.createParticle with an invalid effect handle causes an Int3()) 2011-06-27 12:49:42 +00:00
Sushi e661586a3f Add "wait for animation" turret flag (turret won't fire until associated animation completes) 2011-06-26 18:10:54 +00:00
The_E 590cbf0b2b Patch from m!m to give scripting access to debris metadata 2011-06-25 14:15:44 +00:00
Swifty a7383cba89 Introduced the preprocess() method in HudGauges. Allowed the HUD to peek at the HUD message buffer when HUD is disabled. 2011-06-25 09:30:47 +00:00
The_E f8fef5c56f Patch for Mantis 2326: Standalone server crashes when ship classes are changed in loadout.
I hope.
2011-06-25 08:03:52 +00:00
Zacam d15c9259cd Standalone execution now creates it's own log file (fs2_standalone.log) 2011-06-21 19:23:56 +00:00
The_E 503fa0d19b Fixes issue with padlock view messages not appearing 2011-06-19 12:57:26 +00:00
The_E bafed3f964 Fix compiler warnings re: signed/unsigned mismatch 2011-06-18 21:36:05 +00:00
Sushi 3a7c0f2cee Halleck's glide sound patch (mantis 2452) 2011-06-18 00:44:41 +00:00
The_E 2f01d3f0ce Bumping the max number of files CFile can handle to 2^16 2011-06-16 17:09:30 +00:00
Zacam 1b6bfd2c89 Adds "/MP" as an Additional compiler Option for MSVC 2008. 2011-06-16 15:59:59 +00:00
Sushi 83b4d80566 Added is-in-box SEXP 2011-06-16 02:59:44 +00:00
chief1983 0a06eff122 Update OS X Ogg libraries in the Frameworks archive. 2011-06-15 20:04:07 +00:00
karajorma 65d6013539 Get and set SEXPs for countermeasures. 2011-06-15 12:46:02 +00:00
The_E a5a34af86d Oops, small typo 2011-06-14 16:45:35 +00:00
The_E f187ed531e This will make various text boxes react correctly to changes in font height. 2011-06-14 16:40:20 +00:00
Goober5000 2bdaac8c52 add mjn.mixael's credits image specification feature 2011-06-13 03:42:24 +00:00
The_E 695db665e3 Adds "$disable weapon damage scaling for player:" AI profiles option, which does what it says on the tin. 2011-06-11 19:26:56 +00:00
Sushi 4f8e6da7b9 Halleck's pre-launch sound patch (mantis 2451) 2011-06-10 04:52:35 +00:00
Zacam 0801b6861f Back port from AP: removes a couple of Unreachable NULL returns 2011-06-07 02:30:00 +00:00
Sushi 4b6d7192a1 Merged from Diaspora: Slight bump in contrail limit and max reinforcements 2011-06-04 16:42:43 +00:00
Sushi ed340e193f Merged from Diaspora branch: Make "+Shield_Hit_ani" optional 2011-06-04 16:02:21 +00:00
Sushi 14717f3368 Turn Z-buffering back on for BSG warp effect. 2011-06-03 23:54:30 +00:00
The_E cd9663f015 A small change to make Apple's GLSL compiler happy 2011-06-03 18:02:29 +00:00
chief1983 f7c4aa5221 Fix a typo reported by ElGuillermo. 2011-06-03 16:53:39 +00:00
Zacam 6f4725b0d9 In crawling through XT Branch, noticed this.
"%sÀÄ%s" should be "%s:%s"
2011-06-03 05:18:10 +00:00
Sushi fcbce45a2c Fix nasty pointer bug 2011-06-03 03:02:48 +00:00
The_E 6037493ae9 Another Assert -> Assertion conversion to help in mission debugging. 2011-06-02 09:36:24 +00:00
The_E c71012a829 Patch for Mantis 2421 from m!m: Adds scripting controls for particles. 2011-06-01 19:41:07 +00:00
Goober5000 8d10c0864d extra small enhancement 2011-05-30 21:20:32 +00:00
Goober5000 5fb4a6db18 add ability to set the duration of the ship death roll 2011-05-30 21:06:11 +00:00
The_E 2eab7d90f2 From m!m: Patch for Mantis 2446: Scripts not pausing when game is paused. 2011-05-30 18:47:27 +00:00
Goober5000 c6b4fc32d3 fix sanity check for too-long messages (Mantis #2412) 2011-05-30 06:47:27 +00:00
Goober5000 600936b331 reverting 7211 because it is not a proper fix 2011-05-29 06:56:17 +00:00
The_E 5c628d2abd Adding a code comment here to remind people about necessary bumpings 2011-05-28 14:37:48 +00:00
Zacam e1c107a483 Back in r6952 "HUD_OBJECT_PING," was added to "static int retail_gauges[] = {" but "int num_default_gauges = 43;" was not bumped up, resulting in "HUD_OBJECT_FIXED_MESSAGES" not displaying. 2011-05-27 23:38:14 +00:00
Sushi 2106903cbc Fixing some HUDs showing from other ships when they shouldn't, take 2 2011-05-27 14:36:14 +00:00
The_E 23b121a108 Patch for Mantis 2441 (friendly-stealth-invisible" flag doesn't work) from pyro3d 2011-05-27 09:11:51 +00:00
The_E 649c0fb3c4 Reverting commit 7203. If you wish to exclude certain gauges from rendering depending on camera mode, you need to edit that gauges's constructor function, NOT the canRender() method. 2011-05-26 20:45:12 +00:00
Goober5000 358343b813 break strings into bite-size pieces for ease of compiler digestion 2011-05-26 03:58:00 +00:00
Goober5000 0a8f93d474 fix minor pierce-shields table flag bug (Mantis #2442) 2011-05-26 03:40:07 +00:00
Sushi 6f11196106 Added an Assertion to help track down a sound error 2011-05-24 15:03:09 +00:00
Sushi 368029ec59 Fix some HUD gauges being rendered while viewing other ships externally 2011-05-24 14:40:57 +00:00
Sushi 1d4d3c0b6f Update thruster rendering (consistently render based on acceleration instead of speed, don't render distant/tiny thrusters) 2011-05-21 20:25:14 +00:00
The_E 784da1e0d0 Adding the FSU main shaders, FSU post-processing.tbl, as well as the post-processing and FXAA shaders to def_files. 2011-05-21 17:07:41 +00:00
The_E 3cbf515fe3 Since bloom can now be changed in-game, we always need to compile the shaders. 2011-05-20 15:56:30 +00:00
The_E 6526b86bc5 Patch for bug encountered by Zacam: Ship model instance data was not being reset correctly when changing ship classes. 2011-05-19 21:32:02 +00:00
The_E 444936ec21 This will make the lab more useful, as it is now possible to adjust the bloom intensity on-the-fly by pressing b (for more bloom) or n (for less bloom). 2011-05-19 14:51:51 +00:00
Zacam 99cdc82be6 Stupidest typo ever. "GS_STATE_END_OF_CAMPAIGN" not "_EMD_" 2011-05-19 12:20:22 +00:00
Sushi 63444087e2 Fix BSG warp effect shockwave 2011-05-19 00:50:27 +00:00
The_E ad1297167d Adding a bit of configurability to the FXAA business. This alters the F3 Lab so that the number keys correspond to FXAA presets (with 0 being lowest and fastest, default being 3). Also adds the "-fxaa_preset" commandline argument, which accepts a single int parameter. New Shaders needed to take full advantage of this, see forum thread (http://www.hard-light.net/forums/index.php?topic=76145.0) for details. 2011-05-18 11:37:27 +00:00
The_E 814f9777c5 Adding an error message in case FXAA shader compilation fails. 2011-05-17 16:29:43 +00:00
The_E 41bfa86911 This will enable FXAA support in FSO (Read: Antialiasing as a post-process stage). In order to use it, the shaders found here: http://blueplanet.fsmods.net/E/stuff/FXAA-shaders.7z need to be in data/effects. 2011-05-17 14:57:33 +00:00
The_E c1c9096d82 Converting a few more Asserts to Assertions. Also added a graceful exit path. 2011-05-15 08:38:22 +00:00
Sushi 8c3150455a Fix clipping problems with deathcam and cutscene bars. 2011-05-14 16:58:29 +00:00
Echelon9 365bd811c2 Documentation: First pass of AI code functions 2011-05-12 13:44:20 +00:00
Echelon9 38257bead8 Documentation: 3D clipper functions 2011-05-12 13:43:42 +00:00
Echelon9 e1fa804c1c Documentation: Animation code function documentation 2011-05-12 13:43:00 +00:00
The_E 70d1c6f8b1 Fixes issue where both the 2D and 3D radars were visible at the same time. Code should now respet the commandline flags properly. 2011-05-10 15:26:46 +00:00
The_E c684705e01 This makes the "Form on Wing" AI order accessible to FREDers as an AI goal. 2011-05-08 11:17:34 +00:00
Sushi 4324ca87d6 Updated "alt1" path mode so that it respects the cap-waypoint-speed SEXP. 2011-05-07 11:31:30 +00:00
The_E 033f06ec20 Aargh, this might have been catastrophic 2011-05-01 15:05:01 +00:00
The_E c65a175d2c Fix compile warnings here. 2011-05-01 15:00:53 +00:00
Echelon9 e55068ccf1 ds.cpp: Back this change back out until the wholesale change can be made at once 2011-05-01 14:59:31 +00:00
Echelon9 f55260cc0e Fix Diaspora Mantis 772: Player is able to fire countermeasures when player-use-ai SEXP is used. Also document. 2011-05-01 13:03:39 +00:00
Echelon9 761266b768 Two small comment typo corrections for model.h and ship.cpp 2011-05-01 12:00:26 +00:00
Echelon9 8138efbcf9 Documentation: Commentary for modelanim.cpp|h 2011-05-01 11:59:40 +00:00
Echelon9 aa708f6d26 Fix Valgrind report: Use of uninitialised value &freq in alcGetIntergerv(); requires braces to address GCC crosses initialisation error due to the goto in this function 2011-05-01 11:07:26 +00:00
Echelon9 dab00c94bf Documentation: Help save some trees 2011-05-01 09:06:12 +00:00
Echelon9 4669a7613c As we don't do Unicode properly yet, this character corrupts. In French it still means Hat Back (joystick control) 2011-05-01 08:53:13 +00:00
Echelon9 5565e0ac8b Documentation: hud.cpp and hud.h files 2011-05-01 06:05:48 +00:00
Echelon9 aa1601bb36 Documentation: Fix a few syntax errors reported in Doxygen's log 2011-05-01 03:54:01 +00:00
The_E 744a247f67 Change syntax and help text of the set-jumpnode-model sexp, as it was rather broken before. 2011-04-30 16:23:05 +00:00
Echelon9 9a4d348bc0 Xcode project file: Generate debug builds with a DWARF plus dsym file, so that analysis tools can retrieve source code line numbers 2011-04-30 06:24:08 +00:00
Echelon9 09a360c284 Documentation: sound/ds.cpp 2011-04-30 06:18:03 +00:00
The_E a858e90a6d And now set-jumpnode-name is even multi compatible. 2011-04-29 14:54:38 +00:00
The_E 83bd54130b Added warning to the sexp help for set-jumpnode-name 2011-04-29 14:10:52 +00:00
The_E 6c5013760a set-jumpnode-name, as implemented by CommanderDJ 2011-04-29 14:05:45 +00:00
karajorma 68645bd224 Fix for Mantis 2427 (Directive-Is-Variable SEXP doesn't allow you to change the variable name. 2011-04-28 12:46:01 +00:00
Sushi 2992e88315 Add $Path Metadata and +departure rvec to ships.tbl 2011-04-27 14:22:22 +00:00
The_E b79a54b67a Okay. No more screwing around with this. 2011-04-26 11:13:56 +00:00
The_E a71d012ef6 Ooops, this armor type business isn't ready yet 2011-04-26 11:09:19 +00:00
The_E e821ae2ccd Fix for Mantis 2428: Decal parsing deprecation error 2011-04-26 09:24:54 +00:00
The_E d71a5d5b90 Fixes issue with custom HUD gauges not resetting to their default values between missions. 2011-04-24 17:19:21 +00:00
Wanderer 2eb06e1787 fixes to turret rotation handling (swarm issue) and to secondary turret angle checks 2011-04-23 21:53:19 +00:00
Wanderer 06a3381dd9 fix for mantis 2309's corkscrew issue 2011-04-23 12:18:30 +00:00
The_E 7e50611a02 Guarding against a null vec3D in vm_vec_normalize here. 2011-04-21 16:12:54 +00:00
Wanderer e04d475345 related to mantis 2406 - ai profiles option to make beams deal damage to weapons 2011-04-20 15:40:29 +00:00
Wanderer 94faf22283 Fix for mantis 2406 for weapon vs. weapon collisions (not beam vs. weapon collisions however) 2011-04-20 08:17:24 +00:00
IssMneur e6f43f6f0f Make this a more useful error message. 2011-04-20 04:16:42 +00:00
Sushi 39d6889f86 Add "$ai path mode:" to ai_profiles. This allows an alternate method of path following that works better in some cases, such as with high-damp ships. 2011-04-18 14:08:31 +00:00
karajorma 1bba558d70 Add a SEXP to allow variables to set the counter in a directive. 2011-04-18 05:34:18 +00:00
Echelon9 5d635a262b DOC: Amendment to frand_range() 2011-04-17 00:33:51 +00:00
Echelon9 e12f71c83d DOC: Documentation of floating.cpp 2011-04-17 00:18:59 +00:00
Wanderer 39e8a24663 fix for issue noticed by Zacam in the particle effect changes 2011-04-15 14:34:31 +00:00
The_E f4c90eff0c Woops, this shouldn't have gone in 2011-04-15 12:44:24 +00:00
The_E e5efa336c1 Fix for Mantis 2416 (Messages do not display when in padlock view) 2011-04-15 12:34:11 +00:00
The_E ceb68d44bd Fix for Mantis 2240 (HUD anis and training messages do not display if hud_disable_except_messages is active) 2011-04-15 12:16:17 +00:00
Wanderer bf66734ded adds table controls for various particle effects, and explosions related to ship death event. per ship class base deathroll time. 2011-04-14 18:59:06 +00:00
Zacam 973fab655e Reported by chief1983, adds closing brace to line 2346.
Mac's should be happy now.
2011-04-12 23:35:58 +00:00
The_E 5cbf11ff6b Of course, I did it wrong. However, this works now. 2011-04-12 13:32:27 +00:00
The_E b68ef9b9b0 Requested by Axem: Allow beams to tag targets. 2011-04-11 15:44:33 +00:00
Echelon9 362241cf22 Documentation: hud_sensors_ok() function comment 2011-04-10 13:09:24 +00:00
Echelon9 247ac6373e Second go at patch r7110 2011-04-08 13:00:51 +00:00
Echelon9 0a7e8be8f4 Fix two buffer overflows: missionweaponchoice.cpp(3580): warning C6386: Buffer overrun: accessing 'slot->wep', the writable size is '28' bytes, but '4194244' bytes might be written & missionweaponchoice.cpp(3585): warning C6386: Buffer overrun: accessing 'slot->wep_count', the writable size is '28' bytes, but '4194244' bytes might be written 2011-04-08 12:38:19 +00:00
The_E 9a6f8a8be7 Removing an Assert in favour of more elegant error handling. 2011-04-06 10:25:18 +00:00
The_E 092ea635c3 Fix for issue with the "no ETS" flag where subsystems were not getting recharged properly. 2011-04-05 12:05:32 +00:00
The_E 67175970a4 2011-04-05 09:44:43 +00:00
The_E 72287264e3 FSF's fix for Mantis 2371 (Hotkey selection does not work for additional wings) 2011-04-04 14:48:27 +00:00
The_E 9b580610ca Fix for Mantis 2409 (Directive gauge is rendered despite hud-disable-except-messages) 2011-04-04 13:07:17 +00:00
The_E 406b57e5b0 Fix for Mantis 2391 (Erroneous warning about missing assets due to changd HUD loading mechanisms) 2011-04-04 13:03:29 +00:00
The_E 42ff356ad2 Fix for Mantis 2422 (Target Shield indicator behaves like a duplicate of the player shield indicator) 2011-04-04 12:56:59 +00:00
The_E 0aa44e3b12 Correction: Previous commit broke AWACS behaviour. 2011-03-30 09:42:52 +00:00
The_E e635eb373b Add a sanity check here. 2011-03-29 18:06:04 +00:00
The_E ef2681eb69 Change an Assert to an Assertion for better debugging. 2011-03-29 17:17:15 +00:00
Zacam 223920ded6 7092/7093 were meant for Antipodes, not Trunk. 2011-03-29 13:55:04 +00:00
Zacam 8501ffa53f Reported by rsaxvc (Probably due to MAX_INT being used)
http://www.hard-light.net/forums/index.php?topic=75332.0
2011-03-29 13:50:17 +00:00
Zacam 9c0144dd96 Pull the "demo" dir out of the makefile. 2011-03-29 13:42:57 +00:00
Echelon9 6628e967b3 DOC: Update some documentation in missionbriefcommon.cpp 2011-03-24 12:53:44 +00:00
Wanderer db8b44191d feature commit - damage and impact particle spew controls, control for setting a multiplier for propagating explosion radius. 2011-03-19 22:37:32 +00:00
The_E a1acb0601d And more from m!m, as seen here: http://www.hard-light.net/forums/index.php?topic=44821.msg1487355#msg1487355 2011-03-19 21:49:42 +00:00
The_E 808a3dd1e0 A few tweaks and additions by nuke 2011-03-19 21:37:51 +00:00
The_E 9d8caf5f2a m!m's corrections to subsystem:fireWeapon() as seen here: http://www.hard-light.net/forums/index.php?topic=44821.msg1486751#msg1486751. Slightly adjusted to use model instances. Also tweaked ship_get_global_turret_gun_info() to use model instances. 2011-03-18 21:47:17 +00:00
Sushi 5469769936 Add "$Detail Distance Multiplier" 2011-03-18 14:33:50 +00:00
Goober5000 b9a1eca909 improved version of hud_squadmsg_wing_valid(); fixes Mantis #2415 2011-03-11 07:21:27 +00:00
karajorma a561ecc2a3 Remove a few annoying compilation warnings 2011-03-10 00:26:45 +00:00
Goober5000 af39be3120 add another ship class to the list of FSPort changed names 2011-03-09 04:04:33 +00:00
Goober5000 c6f40a74bb finish patching subsystem comparison 2011-03-03 07:00:42 +00:00
Swifty 225f16f754 Memory leaks involving Polymodel_instances plugged. 2011-03-02 14:08:22 +00:00
Goober5000 e765702121 use subsystem_stricmp where appropriate 2011-02-28 08:27:52 +00:00
Echelon9 444c6b293b Update SVN ignore keyword so we don't get documentation output in SVN 2011-02-26 01:18:16 +00:00
Echelon9 d52f90c076 First version of our Documentation system, using automated Doxygen source code comments 2011-02-26 01:15:51 +00:00
Echelon9 2c8dc2722d Effective STL: Use Container.empty() instead of Container.size() == 0 in if() statements 2011-02-25 14:38:28 +00:00
Goober5000 b0dcbfbc56 change the subsystem warning to an nprintf, since it's a pretty benign notification and sexps don't notify you anyway 2011-02-23 05:09:24 +00:00
Echelon9 d549d06728 DOC: Further instructions on initialisation of the pseudo random number generator 2011-02-22 12:05:31 +00:00
Echelon9 634dcc7e23 Accompanying changes to aicode.cpp following staticrand.cpp 2011-02-21 14:15:34 +00:00
Echelon9 80d622f56f A couple of other small changes to staticrand.cpp|h to address readability 2011-02-21 14:13:23 +00:00
Echelon9 1c687e4b4e Initial testing of something very exciting for the coders... 2011-02-21 12:50:16 +00:00
Goober5000 750df36303 add slash and backslash 2011-02-19 04:51:02 +00:00
karajorma 92be430fdb Add the Num-Valid-Arguments SEXP. 2011-02-15 08:18:58 +00:00
Goober5000 315bd423dc rename subsystem type fields so as to better distinguish them
some consistency checks
add "no aggregate" flag to exclude a subsystem from aggregate hitpoint calculations
2011-02-14 08:33:23 +00:00
The_E 9f9a294e9d More lua stuff from m!m 2011-02-13 19:45:12 +00:00
Sushi 5a9202910f Fix a bug with friendly shield manage/cm usage 2011-02-12 17:02:23 +00:00
Goober5000 dbd13bba38 activate the OF_IMMOBILE flag, and clean up the obj_move_all loop slightly 2011-02-12 05:00:13 +00:00
Goober5000 a5cd0f8de0 gaaaah, fix a whole bunch of bugs with the no-ets flag:
checkbox ui settings were incorrect
checkbox wasn't hooked into the event loop
resource #define's overlapped
FRED never saved the ship flag
ship flag did not have an equivalent parse flag
sexp(s) to modify ship flag did not use the existing ship flag sexp architecture
2011-02-07 09:08:39 +00:00
Goober5000 9b0b26b643 fixed compilation error 2011-02-06 08:18:26 +00:00
The_E 13ade13402 More fixes for Mantis 2372. Should now allow longer descriptions. 2011-02-05 09:18:04 +00:00
The_E fe51ef9df0 Minor whoopsie. This shouldn't have been committed just yet. 2011-02-05 08:59:26 +00:00
The_E ebab2d44ff Adding patch for Mantis 2385. This adds a "+sub_name" option to the animation code, which comes after/replaces "+sub_type" for a few triggers, such as the "weapon fired" trigger. 2011-02-04 17:18:39 +00:00
The_E e36d312d73 Adding a bit of verification here to catch a very strange bug 2011-02-04 17:12:48 +00:00
The_E 0b9429b9ea Adding a few error messages 2011-02-04 17:02:49 +00:00
Echelon9 9ec0215ad8 Remove last references to the redundant Intel_anim_filenames array 2011-02-04 15:31:44 +00:00
Zacam 720ad2127a Nukes Particle Code update (for more particle types)
http://www.hard-light.net/forums/index.php?topic=74165.0
2011-02-04 14:10:59 +00:00
Zacam bed42975da Karajorma's "Clean up" code. (Not for credit, but because I'm trying to reduce the "open" number of "Code Reviews" so that we don't get too backlogged with them)
http://www.hard-light.net/forums/index.php?topic=74066.0
2011-02-03 07:41:16 +00:00
FUBAR-BDHR c0df5578c8 Add node-targeted sexp 2011-02-02 06:26:21 +00:00
Goober5000 f570348ee2 --the behavior of cargo index -1 (which can only happen for capships) and cargo index 0 is substantially the same, so let's standardize on index 0... this prevents crazy stuff happening with bitwise operators on negative numbers :-/
--also, remove the restriction on capship cargo where ships must have the "scannable" flag
--because of the above constraints, "nothing" cannot be a meaningful subsys cargo, but then again, scanning a subsystem with "nothing" didn't do anything in the old code, so this doesn't change anything
2011-01-31 10:04:37 +00:00
Goober5000 c77551181c fix for Mantis #2390
errors in handling the CARGO_NO_DEPLETE flag for ship subsystems
2011-01-31 09:18:21 +00:00
Goober5000 9df7a37f3f fix some errors with sexp numbering that free up 2 Change slots
merge the Nav operators into other categories
add the new Change2 category and set up hacks so that its operators will display in Change's menu
2011-01-30 09:17:15 +00:00
Goober5000 eae11de29b commit the "immobile" flag, requested by Black Wolf, Diaspora, etc. This is just the infrastructure; the flag doesn't actually do anything yet. 2011-01-30 08:19:17 +00:00
Goober5000 e68c34eb90 fix ship flag dlg layout, which got messed up in The E's commit 2011-01-30 08:12:42 +00:00
Goober5000 32c70d3f96 someone made a bug here! 2011-01-30 07:55:05 +00:00
Goober5000 3a9ed93730 fix compilation 2011-01-30 07:07:33 +00:00
Zacam 398523e3cc It would have been NICE if Tortoise had actually _deleted_ the files when it asked if I wanted them removed. Stupid !@$^*&# Tortoise. 2011-01-30 06:09:42 +00:00
Zacam 9254dae233 Resolves LNK4221 under MSVC. multi_oo and psnet are not actually linked/used, so references pointing to them now go to multi_obj and psnet2 respectively. (Same as Antipodes 6881)
http://www.hard-light.net/forums/index.php?topic=73147.0
2011-01-30 05:59:36 +00:00
Zacam 4517320ffd Microsoft Visual Studio 6/2005/2008/2010 project updates to use newer libjpeg code committed on 6980. 2011-01-30 01:40:18 +00:00
Echelon9 fb8910635e Update libjpeg in source to v8c (16-Jan-11) from 6b (27-Mar-98). For more details see http://www.hard-light.net/forums/index.php?topic=74110.0 2011-01-30 01:33:52 +00:00
Goober5000 d03d5b95e7 this should fix the weird crashes in localization 2011-01-29 09:41:13 +00:00
IssMneur a468eeb878 Allow a primary or secondary weapon shot be substituted with any other weapon in any arbitrary pattern.
http://www.hard-light.net/wiki/index.php/Weapons.tbl#.24Substitute:
2011-01-27 05:35:13 +00:00
Echelon9 f9fd5807d8 Resolve circa 800 warnings that occur on Xcode due to symbol visibility scoping issue. 2011-01-26 11:30:56 +00:00
Echelon9 4be2c7e94d Small fix: Correct the spelling of a NavPoint function 2011-01-25 14:37:43 +00:00
Echelon9 04fe584c87 Chase down radardradis.h from the same location in Xcode 2011-01-25 13:10:37 +00:00
Echelon9 55c3409cf8 What's radardradis.cpp doing in that spot of the Xcode project file? 2011-01-25 13:05:58 +00:00
Echelon9 b1be9e56e0 We don't need a specific Copy Bundle Resources stage to put the Info.plist file in the Mac .app bundle, as well as setting the INFOPLIST_FILE setting. Using Copy Bundle Resources doesn't use the C preprocessor and then puts the file in the wrong location anyway. 2011-01-25 13:03:00 +00:00
Echelon9 89102e2c31 shipfx_large_blowup_init() function can have the void return type, as the caller never checks. 2011-01-25 12:25:59 +00:00
Zacam df749e6d45 A tiny over-sight. Now incorrect values on "hud_speed_multiplier" will actually report as such. 2011-01-25 07:51:02 +00:00
The_E 4a414205a3 Fix for Mantis 2372 (+Description field in Ships.tbl is being ignored) 2011-01-23 21:20:04 +00:00
The_E 824dd0cae8 Fix for Mantis 2380 (Setting target subsystem through scripting doesn't work) 2011-01-23 17:10:53 +00:00
The_E 34b7cbe0b7 Resolves a few signed/unsigned warnings 2011-01-23 17:06:58 +00:00
The_E 76e7f656d1 Adds "no ets" ships.tbl flag. 2011-01-23 16:03:04 +00:00
Echelon9 7d7ca9eb15 Fix: warning C6246: Local declaration of 'i' hides declaration of the same name in outer scope. 2011-01-23 12:47:08 +00:00
Echelon9 e09dea7a79 Revert this change to size_t; will require the wholesale update of the weapon code indices at the same time 2011-01-23 12:30:06 +00:00
FUBAR-BDHR 9f29b454b5 Fix for FRED not compiling with new nebula lightning from r6958 2011-01-23 06:56:01 +00:00
FUBAR-BDHR 41b1476b23 Fix bug in sexp_ship_set_damage_type() 2011-01-22 06:52:43 +00:00
Echelon9 a8db22bc65 Refactored nebula lightning & removed limits on Lightning.tbl 2011-01-22 05:35:43 +00:00
Sushi b38fa48e7e Add "starts locked" subsystem flag (that turret starts out locked by default and needs to be turret-freed before it will fire) 2011-01-22 00:44:44 +00:00
Goober5000 110cd3bccc add turret-protect-ship and turret-unprotect-ship 2011-01-21 08:55:26 +00:00
Goober5000 ab8808e35a get-object-speed-* are status sexps, not change sexps! 2011-01-21 08:49:54 +00:00
IssMneur efff8a5d83 get-object-speed-{x,y,z} added. 2011-01-21 06:28:37 +00:00
Swifty 6e52dbd299 Resolved some issues involving the Ping Indicator not displaying. 2011-01-19 09:21:22 +00:00
karajorma b742eac806 LuaPineapple's fix for Mantis 2322.
Some comment clean up.
2011-01-19 08:24:26 +00:00
The_E b4db3b3ecf FUBAR's damage type sexps. Tested ad nauseum by BP. 2011-01-18 16:21:36 +00:00
Goober5000 34fd0c53ad make subsystem-vanish consistent with ship-vanish
clarify sexp help and fix name (using deprecation, so that old missions will still work)
2011-01-16 08:20:08 +00:00
Goober5000 42fc6e461c add if-then-else and perform-actions 2011-01-16 08:18:09 +00:00
Echelon9 6c4bed411e Fix Mantis 2379: Last available nebula storm type in Lightning.tbl wouldn't be used in game 2011-01-15 03:54:50 +00:00
Echelon9 400331d4ec Cleanup cmeasure.*: Remove dead code, use size_t as for loop array index not a signed int 2011-01-15 03:05:01 +00:00
Echelon9 822110405a Prevent potential overflow of Escort_ships[] array 2011-01-15 02:33:34 +00:00
Sushi 95a713128c Add "hide from radar" weapon flag to force bombs not to show up on radar 2011-01-12 16:51:38 +00:00
Goober5000 eafc0ca82e fix a return value error
also, cut down on the number of warning messages shown for background bitmap loading
2011-01-12 10:03:45 +00:00
Goober5000 230da289d2 change xor (but not bitwise-xor) to use any number of arguments, not just 2
enhance string-to-int to ignore non-numeric characters (so turret07 becomes 7)
2011-01-12 02:10:22 +00:00
Goober5000 330fee1b3b commit string-concatenate and int-to-string 2011-01-12 01:37:03 +00:00
Swifty 98b65e2dba Eliminated pesky bug involving some gauges not being properly updated with necessary HUD config data. Took a while to figure out. 2011-01-11 07:58:03 +00:00
Goober5000 0cc190e9f1 stupid brain fart
fix Mantis #2375
2011-01-11 01:03:48 +00:00
The_E ebff760cca There is no function with the signature "double pow(int, int)" in math.h 2011-01-10 16:10:54 +00:00
Goober5000 8370567747 remove for-each-of
add a note regarding string-to-int to for-counter
supernova-start takes a positive argument
2011-01-10 11:55:15 +00:00
Goober5000 2f0324048b Added the following sexps:
pow (power function)
xor (logical operator)
set-bit, unset-bit, is-bit-set (for working with individual bits in integers)
bitwise-and, bitwise-or, bitwise-not, bitwise-xor
2011-01-10 11:29:24 +00:00
FUBAR-BDHR 55de86a47d Add the ability to define detail distances for weapons. 2011-01-09 22:35:02 +00:00
FUBAR-BDHR c07f1a1c1d Fix for Mantis 2368. Subsystems with vanish flag still play sound from player ship 2011-01-07 22:01:36 +00:00
Goober5000 ea4cc1e870 the repeated messages get really annoying, so log them and display one message 2011-01-07 10:16:10 +00:00
Goober5000 66c82d58c1 added two awesome sexps, for-each-of and for-counter
as part of the sexp infrastructure, add test_argument_vector_for_condition so that argument sources are not limited to sexp nodes
2011-01-07 09:11:02 +00:00
chief1983 5ffb61b26c Fix for #2365: Assert to Assertion so we can tell the user a little more about the crash. 2011-01-06 05:07:51 +00:00
Swifty 4a9e605e56 Support for PNG/JPG/TGA based EFFs for the HUD and other graphics that previously required ANI/PCX. 2011-01-05 08:54:14 +00:00
Zacam 5b9ceff06a GLSL version Detection fix.
http://www.hard-light.net/forums/index.php?topic=73712.0
2011-01-05 07:12:48 +00:00
FUBAR-BDHR 1529f948f2 Add flag that applies damage to subsystem as if it were the hull. 2011-01-05 00:12:01 +00:00
Goober5000 0ee79b269f resolve a conversion warning pointed out by FUBAR 2011-01-02 00:35:05 +00:00
Goober5000 08e86d0192 re-add Echelon9's commit, with proper logging, and also with parallel fix to bmpman.cpp 2011-01-01 09:17:36 +00:00
Sushi 65f7c760d8 Add "$ai aims from ship center:" and "$allow primary link delay:" AI profiles flags 2010-12-31 20:03:16 +00:00
Goober5000 6d4b0efd39 add sexps for object orientation 2010-12-31 07:41:01 +00:00
Goober5000 4f7f79732e missed one file 2010-12-31 04:28:37 +00:00
Goober5000 d57ab51162 change fl_radian to fl_radians so as to be consistent 2010-12-31 04:02:41 +00:00
chief1983 34d11f1295 Fix the DirectInput commit r6902 breaking compiling on nix 2010-12-29 18:18:44 +00:00
Echelon9 337786ef26 Remove from Xcode project file two non-existant source code files 2010-12-29 07:45:10 +00:00
Zacam 5ae8d90656 Thanks to Goober5000, this is the correct way to be doing this. 2010-12-28 04:49:05 +00:00
Zacam 802d5956f3 Fixes the index so that Player Main Hall changes will actually save properly. Should have caught this back in 6860. 2010-12-27 20:59:16 +00:00
Sushi 9a71e9b080 Add -disable_di_mouse command-line option to force the game to use Windows mouse input instead of DirectInput. For some people, this results in more reliable mouse input. 2010-12-27 16:17:54 +00:00
Zacam 900fd755b1 Fixes reports of Retail data showing "0 ms" for ships Velocity in Ship Selection Screen. When multiplying an INT by a FLOAT, setting the fl2i() on the float is a good idea. 2010-12-27 15:27:48 +00:00
Swifty aa71f4a817 Clear the active display list when this ship is beleeted. 2010-12-27 09:28:17 +00:00
Echelon9 0da3dff1c1 Fix a small typo in Diaspora feature's comment 2010-12-27 08:26:04 +00:00
Echelon9 0557c1e4cd Correct 2 comment typos 2010-12-27 08:18:39 +00:00
Echelon9 9410909ee1 Fix: Mantis 2351 - Animated subsystems not counted as rotating allowing max to be exceeded 2010-12-27 08:00:31 +00:00
Echelon9 db1e2a891e This check can go back in, the real cause was fixed in r6893. Good work Assert() 2010-12-27 07:48:31 +00:00
Swifty 0c67dd9abc Get Lua ray tests to use model_instances for collision detection. Fixes the failed assertion associated with this. 2010-12-27 07:36:49 +00:00
Echelon9 7fa59778c5 Fix a comment typo 2010-12-27 06:47:03 +00:00
Swifty a5be8facf6 Limit the setup of cockpit displays to only the player ship. 2010-12-27 05:52:33 +00:00
Swifty 4d3bf36f48 Fixes the weapons list gauge bug where a blank space would render when no secondaries are loaded. 2010-12-27 05:43:52 +00:00
Zacam fdd529621a Revert 6884. Not a good thing to do apparently. 2010-12-26 19:46:00 +00:00
The_E 38d2da68a3 Fix for Mantis 2350 (Sound assignments get lost/become bogus when changing ship class) 2010-12-25 15:15:28 +00:00
Zacam f98be5dcde Fix: MSVC signed/unsigned mismatch. 2010-12-25 13:15:55 +00:00
FUBAR-BDHR c3550e55dc Fix for mantis 2356: Turret-free-all in an every-time acts as turret-lock-all
Fixed turret-free, beam-free-all, and beam-free as well
Removed generic subsystem argument from those as well as turret-tagged-specific as they do not have code to process it.
2010-12-22 18:39:40 +00:00
The_E 083a84feff Swifty's go-swift stuff. Makes collision detection slightly less insane. 2010-12-22 14:42:21 +00:00
The_E 1f1640d47d 2010-12-20 19:53:52 +00:00
Sushi c7eac88eec Fix oversight from AI.tbl overhaul a while ago 2010-12-20 16:57:13 +00:00
Echelon9 08eeeedff3 A further two spots where the MSVC 2008 compiler doesn't like SAFE_STRINGS changes 2010-12-20 07:50:23 +00:00
Echelon9 cd7da4d94e Mantis 1889: Utilise all three hud target box rendering styles (inclusion of a rendering style with proper lighting) 2010-12-20 07:46:38 +00:00
Echelon9 f3359d1547 MSVC compiler doesn't like some of these SAFE_STRINGS changes, GCC does... 2010-12-20 06:14:08 +00:00
Echelon9 eb129200a1 Fix: Convert a further subset of strcpy() to the SAFE_STRINGS strcpy_s() version 2010-12-20 04:28:01 +00:00
Echelon9 7b9d36e105 Guarding against array out of bounds error, ahead of conversion to STL type 2010-12-20 03:04:54 +00:00
Echelon9 10dd0c57d5 Clean up redundant checks 2010-12-19 02:03:41 +00:00
Echelon9 25b199c25c Two further cases of typo referenced in r6861 fixed 2010-12-19 01:28:38 +00:00
Echelon9 1a98990c3c Remove redundant Invalid_demo_keys[] and associated control_config_valid_action() 2010-12-19 01:24:50 +00:00
Echelon9 78496b1953 Remove redundant #ifdef check 2010-12-19 01:09:38 +00:00
Echelon9 f278ca0e85 Correct typo in comments 2010-12-19 01:06:58 +00:00
Echelon9 b19fc28a7e Fix: Local declaration of 'i' hides declaration of the same name in outer scope. For additional information, see previous declaration at line '786' 2010-12-15 12:51:51 +00:00
Echelon9 91fbebd307 Fix: Local declaration of 'i' hides declaration of the same name in outer scope. 2010-12-15 12:48:24 +00:00
Echelon9 178963e78a Clear out commented #IFDEF INTERPLAYQA section 2010-12-15 12:39:11 +00:00
Echelon9 bacb819e5f Fix: Local declaration of 'retail_gauge_loaded' hides declaration of the same name in outer scope. For additional information, see previous declaration at line '392' 2010-12-15 12:27:14 +00:00
Goober5000 2e7dea0018 set certain flags that used to be in ship_info via ship_set and change_ship_type, which is the correct thing to do, rather than in the middle of parsing, which was a red herring
(fixes Mantis #2169)
2010-12-13 07:33:35 +00:00
Goober5000 c8dd5e1bab bypass weird compiler error 2010-12-13 07:24:38 +00:00
Zacam 81bf3cec47 Reverts commits 6681, 6683 and 6684. Adds C4101 Warning suppression for Release Builds (only) so that "catch" doesn't cause an unreferenced parameter warning. 2010-12-13 05:51:49 +00:00
The_E 0b292a1652 Fix for Mantis 2349 (Invalid number of arguments not detected by FRED). This adds a new function to sexp.cpp (check_operator_argument_count()), which can be used to handle cases like send-message-list.
Also adds a warning to change-iff-color in case the FREDer supplied an invalid rgb argument (Mantis 2256)
2010-12-13 04:10:08 +00:00
Zacam 09fad95070 Antipodes 7 Merge: HUD Overhaul, by Swifty. 2010-12-12 20:34:15 +00:00
Echelon9 b1c2a85faa Fix: Local declaration of 'template_id' hides declaration of the same name in outer scope. For additional information, see previous declaration at line '1062' 2010-12-12 01:09:02 +00:00
Echelon9 06d24df914 Clean up up logic check on packet length overrun 2010-12-12 01:08:10 +00:00
Echelon9 6c50ba90ba Fix: Local declaration of 'wip' hides declaration of the same name in outer scope. For additional information, see previous declaration at line '5444' 2010-12-12 01:07:03 +00:00
Echelon9 ebc0d3b6f4 Fix: Local declaration of 'rship' hides declaration of the same name in outer scope. For additional information, see previous declaration at line '6450' 2010-12-11 13:49:06 +00:00
Echelon9 d0e05d5417 Fix: Buffer overrun: accessing 'struct NavPoint * Navs', the writable size is '352' bytes, but '396' bytes might be written: Lines: 1597, 1600 2010-12-11 12:54:02 +00:00
The_E 214e0daf00 Fix for Mantis 1647 (Message brackets linger around when player turns traitor) 2010-12-11 06:03:45 +00:00
Goober5000 257f92441f use standard font to output the "more" indicator 2010-12-10 08:39:21 +00:00
FUBAR-BDHR 17776c091e Fix for mantis 0002337: lock-rotating-subsystem affects more than it should 2010-12-09 23:30:04 +00:00
The_E e38b68bee5 Partial fix for Mantis 2277. This moves the "Turret Firing" animation trigger so that it only triggers when the turret really is firing. 2010-12-09 23:13:46 +00:00
The_E 5db4e2a6b3 Fix for Mantis 2306 (Destroy subsystem cheat does not work in release builds) 2010-12-09 20:28:16 +00:00
The_E bf578e51ef Genghis' fix for Mantis 2164 (Better feedback and error handling for invalid muzzleflash definitions) 2010-12-09 19:55:46 +00:00
The_E 254cd2f2d2 Aaaand done. Now it's fixed. 2010-12-09 18:54:28 +00:00
The_E dc91321cba Fix for Mantis 2111 (Bank indicator alignment issues in weapon loadout select screen) 2010-12-09 18:07:44 +00:00
The_E 649f1ff6c3 Fix for Mantis 2055 (Allow/break/never/fix-warp sexps don't work on the AI) 2010-12-09 16:24:54 +00:00
The_E 82efd3434b Fixes issue with "external model launcher" flag, where secondary weapons would use the models for primary weapons noticed y Droid803 2010-12-08 20:08:25 +00:00
The_E 109f962350 What in the nine hells is happening here? Did noone ever use set-armor-type to reset an armor type? 2010-12-08 04:25:14 +00:00
The_E 8f1f95c273 Fix for Mantis 2257. This adds the options "+HUD Message:" (Boolean, whether or not firing this SSM generates a notification on the HUD), and "+Custom Message:" (if you want to use something other than "Firing Artillery!") to ssm.tbl. 2010-12-07 16:33:58 +00:00
Goober5000 32dd5f9306 follow-up to 6804... fix secondary as well as primary 2010-12-07 07:57:00 +00:00
FUBAR-BDHR ce8024ce15 Oops on the use of /n instead of \n. Good catch IssMneur 2010-12-07 06:31:53 +00:00
The_E 5dcdc79c4e Fix for Mantis 2336 (Countermeasure type assignment doesn't survive ship class change) 2010-12-06 23:27:46 +00:00
FUBAR-BDHR a79d51b357 Fix backward LOD warning message. 2010-12-06 22:00:14 +00:00
The_E 0b4fb309ae Turning this assert to an Error, after feedback from Goober 2010-12-05 18:07:28 +00:00
The_E 4925eb8412 Turning these Warnings into Assertions, as it's something that really needs to be fixed. 2010-12-03 23:27:58 +00:00
The_E 3f21f1fe5e Converting this Assert() to an Assertion() for better feedback 2010-12-03 22:41:44 +00:00
The_E 60ac096301 Taylor's fix for Mantis 2172 2010-12-03 17:44:23 +00:00
Sushi 1389b67bd4 Fix an additive weapon velocity bug (main symptom: collision detection going wonky sometimes). 2010-12-03 15:37:44 +00:00
The_E 9441cc7eef Okay, I'm disabling this Int3(). It's far too easy to hit, even with perfectly valid data. 2010-12-02 21:06:32 +00:00
Echelon9 b8f3fe13bc Fix 2339: Intermittent crashes in add_sexps 2010-11-29 10:28:47 +00:00
Goober5000 e20b95bba4 add_data_dup when we're working with a temporary string 2010-11-29 08:36:31 +00:00
The_E c52d8a4763 Adding a break here 2010-11-27 08:13:53 +00:00
Goober5000 2afc961a62 bump number of misc anims to 32 2010-11-26 04:03:56 +00:00
Goober5000 4faa94a9e3 add feature to select a random animation from a miscellaneous animation group 2010-11-25 23:51:22 +00:00
The_E 04e252c1ea Thanks to Goober for noticing the right way to do this. 2010-11-25 20:48:07 +00:00
Goober5000 81607f7ddc move the error nprintf to a place where it will trigger before the crash it tests for
fix a loop boundary check
2010-11-25 20:10:13 +00:00
The_E 8726f7e0fb Fix for Mantis 2344 (Post-processing sexps don't show correctly in FRED) 2010-11-25 18:48:00 +00:00
The_E 507631cf86 Moving post processing flag back to graphics section 2010-11-25 15:11:04 +00:00
The_E e978adbbdf Adding a return and Warning in case of a null pointer here 2010-11-24 11:35:21 +00:00
Goober5000 04c5416de9 add error detection for arrays that exceed maximum
num door sounds = num door animations
(how did that ever work before?)
2010-11-24 07:18:05 +00:00
Goober5000 5214560f70 how was that accidentally deleted? 2010-11-24 06:39:22 +00:00
Goober5000 2eda13c3e8 remove #defines that were obsolete since after FS1
fix an nprintf bug
change the method of pausing anims so that more than one anim can play in the same spot
(this means that the first frame of an anim won't be drawn until the anim actually starts playing but I think that's okay; it is really only noticeable for the crane animation in the Bastion main hall when the "new player tips" box appears)
2010-11-24 06:33:53 +00:00
Goober5000 d069b8ede7 ugh; formatting ftw 2010-11-24 04:53:41 +00:00
Goober5000 b3db43f54c slight cleanup 2010-11-24 04:35:10 +00:00
FUBAR-BDHR 31853b77de Fix issue with beams not doing damage due to the traitor beam fix. 2010-11-24 02:22:46 +00:00
Goober5000 0c945c210d revert Echelon9's commit 6754 which needs to be discussed first 2010-11-23 08:27:18 +00:00
The_E f02e83320d Fix two instances where an object instance number was used as an index into Weapon_info[] 2010-11-23 08:20:56 +00:00
Goober5000 2b01993d64 corrected Echelon9's correction of Zacam's ... correction?
Anyway, sexp variables are only ints or strings, not floats. Therefore we need to print them to the file correctly.
2010-11-23 08:11:16 +00:00
Goober5000 10d6e21c9d fix some things that Zacam noticed 2010-11-23 07:30:36 +00:00
chief1983 e7e1a07a4b Finish matching vm_mallocs and vm_frees 2010-11-22 17:21:12 +00:00
Echelon9 4ccc6ba9a0 MAGIC numbers aren't for hiding in code... 2010-11-22 13:01:41 +00:00
Echelon9 e4e5775b63 Fix: Local declaration of 'i' hides declaration of the same name in outer scope. 2010-11-22 12:51:59 +00:00
The_E 66596f519c Fix for commit 6756: -1 is a perfectly valid value for current_secondary_bank at that point. 2010-11-22 06:14:11 +00:00
FUBAR-BDHR e818f7840f Fix for Mantis 2190 - Player beams do not cause traitor. 2010-11-21 06:34:27 +00:00
Echelon9 8bc8deffd6 Fix: Local declaration of 'num_lines' hides declaration of the same name in outer scope. 2010-11-20 18:45:34 +00:00
Echelon9 8ba4f6c3c6 Corrected sprintf format, as 'Changed from 'int' to 'float' by Zacam 10/2010' 2010-11-20 17:27:45 +00:00
Echelon9 184b004e19 Fix: Use of swp->current_secondary_bank when equal to -1 as an array index. Very broken. 2010-11-20 16:25:33 +00:00
Echelon9 f96d7fc1be Fix: Invalid data: accessing 'Text_line_size', the readable size is '80' bytes, but '4194244' bytes might be read; Invalid data: accessing 'Text_lines', the readable size is '80' bytes, but '4194244' bytes might be read 2010-11-20 15:10:14 +00:00
Echelon9 5bf9697227 Fix a range of potential NULL dereferences 2010-11-20 12:22:03 +00:00
Echelon9 9f361b791d Fix a few malloc/vm_malloc changes to properly track memory usage; fix a potential NULL dereference in parse/lua.cpp 2010-11-20 08:25:16 +00:00
IssMneur 318d3f032b Back to how the no configure worked before, because it does work just IssMneur is a dummy. Thank you ni1s for pointing it out :P
Added a clarifying comment to autogen.sh.
2010-11-15 21:13:53 +00:00
IssMneur c898573e58 Modify autogen.sh so that it can be run without running configure. To run autogen.sh without running configure pass --noconfigure as first parameter. 2010-11-15 20:40:25 +00:00
Goober5000 b7acaf9177 remove the mprintf per discussion with taylor 2010-11-14 05:42:47 +00:00
Goober5000 8ba6a7035c add SCP_string variants of sprintf, sexp_replace_variable_names_with_values, replace_one, replace_all, and lcl_replace_stuff
change the death message to use an SCP_string
change the set-death-message sexp to accept actual messages
2010-11-14 02:07:45 +00:00
Goober5000 91fd779f86 add missing files to MSVC 2005 project 2010-11-14 01:53:21 +00:00
Goober5000 a1f6c70318 Bad IssMneur! No biscuit! 2010-11-13 22:49:22 +00:00
IssMneur 9ce801e175 Remove redundant weapon_name_lookup().
Make the parameter to weapon_info_lookup a const char* (like it should be).
2010-11-13 07:27:45 +00:00
FUBAR-BDHR f7f6e0e94b Fix for mantis 2174: ERANGE: String error in multiui.cpp 2010-11-12 23:46:24 +00:00
The_E 52529f597a Reverting that again to help tr5ack this down further 2010-11-11 09:54:18 +00:00
The_E 142649e968 Adding proper FRED-side support for special message source "<none>" 2010-11-11 08:45:25 +00:00
The_E 09f9dca972 Replacing a few asserts with proper error handling (in this case, simply CLAMPing the offending values to valid ranges). 2010-11-11 08:41:34 +00:00
The_E 1b00dda9dd Fix for Mantis 2333 (Random crashes caused by snd_get_duration()) 2010-11-08 23:04:34 +00:00
The_E 60eda39ca7 Adding a few checks here to guard/catch Mantis 2333 2010-11-08 01:36:43 +00:00
The_E 727da9031c Fix for Mantis 2329 (Malloc fail on invalid sound files) 2010-11-06 04:44:17 +00:00
The_E 371307eb1f Woops. This fixes screwed up test for MOI validity 2010-11-05 00:34:29 +00:00
FUBAR-BDHR 367ff95e79 Remove sexp_turret_subsystem_targeting_disable() and sexp_turret_subsystem_targeting_enable() and changes them to use the new generic function. 2010-11-04 05:28:39 +00:00
FUBAR-BDHR 09e6972731 4 new sexps to control Wanderer's subsystem flags from r6581
Fix for Mantis 2330 subsystem targetable/untargetable in multi.
2010-11-04 05:17:52 +00:00
chief1983 7192a2d8fe More compatibility fixes for Solaris 2010-11-02 21:20:09 +00:00
The_E afcf923c43 Remove bogus debug warning from the :V: days 2010-11-01 15:25:27 +00:00
The_E d5b15a0567 Adding check for invalid MOI values 2010-11-01 15:24:07 +00:00
chief1983 4ccadf51fe This should fix a OS X 10.5 crash, possibly others. 2010-10-29 19:09:26 +00:00
The_E c4fe142f3a Woops. How did I screw this up? 2010-10-29 04:14:13 +00:00
The_E 7c58abb9eb Fix for faulty check 2010-10-29 02:44:14 +00:00
The_E 09343bfa46 Adding a warning and proper error handling to the "/" operator in order to catch div-by-zero scenarios. 2010-10-29 02:22:51 +00:00
The_E 5f5cea2c6a Patch for minor snafu, from FUBAR 2010-10-29 01:10:19 +00:00
The_E 7fada6171a 2010-10-26 23:42:14 +00:00
The_E e11fe6515a Changing this sanity check to pop up a warning in FRED, but print to log in FS. 2010-10-26 22:56:58 +00:00
The_E 339ba7cca3 Fixes issue with the wrong mainhall being loaded on startup. Note: If a value gets initialized to -1, don't change it to a ubyte and init it to 0, even if that fixes a conversion warning. In this case, casting explicitly is a valid course of action, and should be taken. Here endeth the lesson on refactoring. 2010-10-26 22:23:56 +00:00
The_E 4e2fb80608 Removing lua.c from the VS2010 project 2010-10-25 15:09:17 +00:00
chief1983 416e725e22 Let's get rid of lua.c for Xcode then too 2010-10-25 14:57:53 +00:00
karajorma f5ff35c3bf Looks like we forgot to update the save functions when we changed the special_explosion to use floats. 2010-10-25 13:53:31 +00:00
Zacam c45f22ff98 ...and then it helps to actually initialize it to something. 2010-10-25 03:59:15 +00:00
Zacam 252f2b4e6c Should have paid more attention on that last one, need to define what 'err' is outside of where it is. 2010-10-25 03:54:48 +00:00
Zacam 3e613ff431 Let see how unreachable all this really was. 2010-10-25 03:48:01 +00:00
Zacam b64d1991e1 Fix for Release Build warning for 'err' 2010-10-25 03:43:02 +00:00
Zacam 984df3b5ec 'lua.c' not needed for liblua. 2010-10-25 03:34:33 +00:00
Zacam 0050b48e80 Clears up the rest of the type conversion warnings listed in MSVC. 2010-10-25 03:26:03 +00:00
Zacam a58a8b21af Warnings Resolutions: 'int' to 'ubyte' conversion warnings.
Some formatting cleanup done on the affected files.
While not necessary, some {} put in by suggestion of output from GCC and to improve readability.
2010-10-25 00:03:29 +00:00
karajorma 284fd79740 Not 100% a bug fix but this will have the effect of making it harder to hit the bug and will warn when it hits it. See http://www.hard-light.net/forums/index.php?topic=72160.0 for more details 2010-10-24 05:28:30 +00:00
Wanderer 724c77afc2 adding blank scripting state to the game 2010-10-23 19:54:39 +00:00
The_E c885611291 Adding special message source "<none>" 2010-10-22 23:17:44 +00:00
Echelon9 a8d31d4ae4 Update project file listing 2010-10-22 22:53:48 +00:00
The_E 89ae5cf458 m!m's function to access the "affected by gravity" flag 2010-10-22 20:43:27 +00:00
The_E 26ac4b804a Fix for Mantis 2171 (documentation out of sync for gr.getVectorFromCoords) 2010-10-22 13:45:33 +00:00
The_E 332f94886b Thank you code analysis. This could have been ugly.... 2010-10-20 20:06:55 +00:00
The_E 0f38bee49b Change an Assert to a more elegant way of handling this. 2010-10-20 19:38:34 +00:00
Sushi c9b6c3a4ee Fix bug where changing AI goals while gliding can cause them to get stuck in glide 2010-10-20 05:21:51 +00:00
chief1983 d731767ea6 Wrong way with this fix, should have gone from trunk to antipodes 2010-10-19 22:16:26 +00:00
chief1983 1d9c341c07 Use appropriate line endings 2010-10-19 22:14:52 +00:00
Zacam 6e46c4668d From FUBAR: Turret ROF Sexp
http://www.hard-light.net/forums/index.php?topic=71884.0
2010-10-18 21:23:16 +00:00
chief1983 b0bd068e4d Pedantically correct a comment 2010-10-18 21:18:10 +00:00
Zacam 2b44f6325b The hell...? Missed one somehow. 2010-10-18 20:55:08 +00:00
The_E 2349ec5695 Warnings done properly. Thanks, chief 2010-10-18 20:17:01 +00:00
The_E 770953a051 This case shouldn't ever be hit, but it's still bad form to Int3() there. 2010-10-18 19:57:12 +00:00
Zacam 59a360a139 Sun OS compatibility: "Sun" is a reserved word, so (*sun) becomes (*sun_ptr), (bool sun) becomes (bool is_a_sun), etc.
Also: void stars_delete_instance_FRED is now void stars_delete_entry_FRED in the CPP to better match the H.
White-space clean-up took place too.
2010-10-18 19:29:38 +00:00
Zacam 75043ff5b1 go_faster from Antipodes 6. Everybody, say "Thank you, taylor!" 2010-10-18 18:32:37 +00:00
chief1983 0cbb97861b FORCE:MULTIPLE for VC6 in advance of Antipodes 6 2010-10-18 18:08:52 +00:00
chief1983 d0e20484ee FORCE:MULTIPLE for VS2005 in advance of Antipodes 6 2010-10-18 18:03:10 +00:00
IssMneur 253a4b4dc9 Reimplement VerifyEx to soothe any concerns about the WinAssert use and remove any potential problems for non-VC. 2010-10-18 06:33:54 +00:00
IssMneur 3292e4eee4 Extended Verify to allow a developer to give a more detailed message. 2010-10-17 22:27:04 +00:00
Goober5000 b8736c0c0b sanity check +Team: values, because older versions of FRED saved crazy values like 1301728 2010-10-17 20:12:09 +00:00
karajorma f5065880dd Fix the camera-shudder SEXP to work in multiplayer. 2010-10-17 09:33:08 +00:00
karajorma ffd9b2cdac Add the -parse_cmdline_only option to prevent the command line being parsed in FRED (and FSO for that matter). 2010-10-16 05:17:46 +00:00
The_E b352e39494 m!m's team:getColor() function for scripting. 2010-10-15 19:45:02 +00:00
IssMneur 85c4032ef7 Added a couple of mprintf lines to help diagnose where exactly Openal fails to load. 2010-10-15 17:20:50 +00:00
IssMneur 1482cac08b Fix a crash that occurs when the player turns off auto-targeting. 2010-10-15 16:39:43 +00:00
chief1983 1f61ee9025 Add the FORCE:MULTIPLE option to the linker for VS2008 and VS2010, in advance of the Antipodes 6 merge 2010-10-13 16:47:12 +00:00
karajorma baf028bdb7 Mantis 2324 (Missiontime-msecs gives the wrong value after SHORT_MAX milliseconds) 2010-10-13 06:18:36 +00:00
karajorma 9bcf6d9521 Change Alt_Type into an int to fix a compiler warning.
Move the multi_sexp_ship_change_callsign function (Multi_ functions should sit directly below the server side function that calls them so that they can be updated at the same time).
2010-10-13 02:16:34 +00:00
Zacam 7d8fae55f0 Output name updated to "fred2_open_3_6_13" in MSVC2005. 2010-10-12 23:40:48 +00:00
Zacam 52b5f2fbb1 Project Synchronization: Trunk vs Antipodes
2005: Set PDB and Map Exports to explicitly FALSE on Release builds.
Removed <File Configuration> lines (save for in the case of phrases.xml) as they are unnecessary bloat.
2008: Set PDB and Map Exports to explicitly FALSE on Release builds.
2010-10-12 22:37:50 +00:00
chief1983 d4bfce509e Pull this fix for VC6 from Antipodes since it's unrelated to go_faster 2010-10-12 16:06:27 +00:00
IssMneur 39e516af3f Add some variable verification to hud_cease_subsystem_targeting. 2010-10-12 04:27:17 +00:00
Zacam 93c819e215 Warning Fix: in "opengl_make_gamma_ramp"
'int' to 'ushort' conversion addressed.
2010-10-08 23:32:54 +00:00
Zacam 53a78a859b Warning Fix: (audiostr.cpp "WaveFile::Read" / ds.cpp "ds_load_buffer")
Sets 'float **pcm' to start as NULL
2010-10-08 23:30:15 +00:00
Zacam 55cb3c209a Warning Fix: in "bool message_filename_is_generic"
signed/unsigned mismatch
2010-10-08 23:24:36 +00:00
Wanderer 57a2f2955c feature commit - diaspora subsystem options 2010-10-08 21:32:48 +00:00
Wanderer caae28adfa feature commit - diaspora turret related patch 2010-10-08 21:05:40 +00:00
The_E 4bb193a519 Patch for Mantis 1963 (Optional argument for set-object-facing and set-object-facing-object doesn't work) 2010-10-08 12:01:11 +00:00
The_E cf04d1b6de Fix for Mantis 1817 & 2323 (Glide does not get reset on mission restart/player respawn) 2010-10-08 10:15:40 +00:00
Zacam f14b184c81 Warning Fix: "sexp_show_subtitle_text"/"sexp_show_subtitle_image"
No more 'float' to 'int'. (not the best way, but it is expedient and doesn't risk breaking things)
2010-10-07 02:21:15 +00:00
Zacam 95a89874e8 Warning Fix: in "void beam_get_binfo"
"miss_factor" is a 'float', not an 'int'.
(some odd 'tab' spacing cleaned up in the function as well)
2010-10-06 20:03:05 +00:00
Zacam 76c4083cbd Warning Fix: for "set_special_explosion"
Corrects conversion of 'float' to 'int', by setting set_special_explosion related entries to 'float'
2010-10-06 19:18:38 +00:00
Zacam 7acab9ba98 Warning Fix: in "object *ship_find_repair_ship"
"min_time_till_available" is a 'float', not an 'int' and so is "howlong" that it is compared to.
2010-10-06 18:45:58 +00:00
karajorma 42fba98066 FUBAR's fix to allow the callsign SEXP to work properly in multiplayer. 2010-10-06 08:53:28 +00:00
Goober5000 2e4143013a fix some old fat-fingering from r1601 (Mantis #2226) 2010-10-06 03:58:21 +00:00
Wanderer 2200196cd5 fix to corkscrew missile emitted particles issue 2010-10-05 08:01:23 +00:00
karajorma 4bf6dc5201 Missed one. 2010-10-05 06:45:51 +00:00
karajorma 4e40f145db Some minor future-proofing/magic number removal. 2010-10-05 06:44:02 +00:00
karajorma 3a578fa70d Fix Mantis 2321 (Weird values for Team when saving events). 2010-10-05 06:08:31 +00:00
Zacam 8c4e0e9614 Double-Trouble: Noted by FUBAR, somebody made a copy-paste mistake 2010-10-04 23:14:27 +00:00
IssMneur 134abc8f09 Make VS2010 copy *every time* that it rebuilds the binaries, not just when a change is made to a file in Freespace2 or Fred2 projects (ie. when it inserts code changes from code.lib into the binary). 2010-10-04 04:27:55 +00:00
The_E b192612b57 More checking to guard against Mantis 2205 2010-10-03 20:35:48 +00:00
Echelon9 f54e6a1c86 Second case of mprintf fubar this week. MSVC thought this was valid? 2010-10-03 09:06:47 +00:00
Wanderer 4b26c34625 Feature commit - option to adjust turret ROF by multiplier or by the number of firepoints. 2010-10-03 07:19:43 +00:00
The_E 4ee64c07f1 Adding a better explanation here. 2010-10-03 03:45:01 +00:00
Echelon9 0968f851bf Correction to r6555 to use mprintf correctly 2010-10-02 07:06:17 +00:00
The_E 4512219c9f Adding the ad.stopMusic() function to scripting 2010-10-01 22:27:37 +00:00
The_E 2d062ff380 Print warning here as well. 2010-10-01 19:14:24 +00:00
The_E fe38a382f9 Adding a deprecation warning to the log 2010-10-01 19:09:17 +00:00
The_E 97634e590a Readding parsing for decals so we don't break stuff unnecessarily. 2010-10-01 18:12:31 +00:00
taylor ecc9c970fd allow duplicate when same file exists as both 2D and 3D in sounds.tbl 2010-10-01 16:42:06 +00:00
taylor a06e48966b easier to follow debug messages for sound loading 2010-10-01 16:42:05 +00:00
taylor f7d8b9ef26 only need half size for mono buffer memory 2010-10-01 16:42:04 +00:00
taylor 3b5f674ba6 remove decal files 2010-10-01 16:42:03 +00:00
The_E 6c059f30c4 Adding a sanity check here. 2010-10-01 07:53:03 +00:00
Sushi 6500943b41 Get rid of compiler warnings 2010-10-01 04:20:40 +00:00
Zacam db96e9fa26 Removed "grammar.h" and added to 'ignore' list. Also added phrases.cfg to 'ignore' list. 2010-10-01 04:10:03 +00:00
The_E e8aa478524 Another compilation warning fix. 2010-10-01 03:06:09 +00:00
The_E 05e68890f4 Fix compilation warning 2010-10-01 01:36:44 +00:00
The_E 044df34584 Adding the "force-glide" sexp by request of Axem 2010-10-01 00:38:58 +00:00
The_E 93b1740848 Fix for Mantis 2289 (Invalid commandline arguments passed to FRED) 2010-09-30 17:22:58 +00:00
Zacam b9b5237123 Purging of the Decal system. Includes Projects updates for codeblocks, MSVC 6-2010 and Xcode. 2010-09-30 05:50:04 +00:00
The_E c6fe7ad5a0 Bumping MAX_SPOOLED_MUSIC to 50. 2010-09-30 00:00:49 +00:00
The_E 4f6fcc566e Removing an Int3() that isn't as impossible to hit as expected. Since we can exit gracefully here, we should. 2010-09-29 19:01:04 +00:00
Wanderer 9a10b6b0b4 Fix for mantis 2304 - 2nd take 2010-09-27 11:55:21 +00:00
Goober5000 2d3f566691 use the warning loop, same as the other half of the if() block 2010-09-27 05:51:28 +00:00
Goober5000 46f48ee3a6 fix redefinition of local variable 'i'
remove unused local variable 'wip'
2010-09-27 05:27:27 +00:00
The_E 6fccf9f790 Ooops. Now this is a proper sanity check. 2010-09-27 04:46:08 +00:00
The_E f5d8a1354d Hopefully fixes an Int3() encountered by FUBAR, where the AI submode of a ship was set incorrectly. 2010-09-27 04:03:06 +00:00
The_E 55d7ca153e Better error checking for adjust-audio-volume, fixes Mantis 2314. Thanks to Echelon9 for noticing this. 2010-09-26 15:54:19 +00:00
Wanderer 2a6727136e Fix for mantis 2303 and related issue in lua.cpp 2010-09-26 11:32:18 +00:00
The_E acf8f56b41 Reverting 6513 due to errors found in the implementation 2010-09-25 21:38:37 +00:00
Wanderer eb660e86c1 Fix to prevent global damage (shockwaves etc) from creating debris shards that spawn in empty space 2010-09-25 20:50:33 +00:00
Wanderer 1015cfe7e9 Fix for mantis 2304 - non standard uvec/fvec turrets did not have proper collision detection 2010-09-25 20:49:05 +00:00
The_E 536203d7e3 Adding the "On Weapon Selected", "On Weapon Deselected", "On Weapon Equipped" and "On Weapon Fired" scripting actions. 2010-09-25 19:43:45 +00:00
The_E 18e539c27b Moving this assert to a better place 2010-09-25 19:08:27 +00:00
The_E 5daf4591b7 Less ugly hacks is good as well. Why compute the object index, when it's passed as a function argument? 2010-09-24 06:31:52 +00:00
The_E 78f7d9f737 Added an Assertion() to further narrow down the cause of the "ai_find_path tries to find path that doesn't exist" bug 2010-09-24 06:29:46 +00:00
The_E fa7d8cb479 Avoiding a possible Int3() due to invalid data being passed; since the documentation for get-object-* doesn't specify that you need to give all 3 "relative coordinate" arguments, this needs to be checked. 2010-09-24 06:28:25 +00:00
Zacam 4465400d13 Add a description to config.h as to what 4290 is. (Thanks Goober for catching that) 2010-09-22 22:59:06 +00:00
Zacam bdcb906c6c Adding 4290 to the pragma warning(disable:) list for easier testing of some code changes. 2010-09-22 21:13:10 +00:00
IssMneur 730ac54217 Fix bug in the new support ship sexp noted by Goober5000. 2010-09-22 03:05:57 +00:00
The_E 4b1dd8e719 Same here. 2010-09-22 00:41:52 +00:00
The_E a9f02aab7b And another variable declaration overwriting a declaration in an outer scope. 2010-09-22 00:38:08 +00:00
The_E a92b28abdf Moving this counter variable to be declared as local for the loops. 2010-09-22 00:32:39 +00:00
The_E f421af5016 Another potential var name collision. Thankfully, this one's part of the decal code, so it's likely it never was a problem. 2010-09-22 00:25:01 +00:00
The_E 667a557e15 Avoiding a name collision between a global and a local variable 2010-09-22 00:15:29 +00:00
The_E 3efcad84a7 Flags are bitfields, so an "&" needs to be used instead of an "&&" 2010-09-22 00:06:20 +00:00
IssMneur 654be5a6e7 Removes the hard restriction (compile time) on the maximum number of "active" support ships per team. Controlled by an optional seventh argument to set-support-ship. Also fixes glitch where only "max concurrent ships" number of support ships would actually respond to support requests. 2010-09-21 05:16:23 +00:00
The_E 3617bb9809 Another Assert()->Assertion(). 2010-09-17 20:59:39 +00:00
IssMneur e852ecf115 I thought I fixed that typo before committing. 2010-09-17 03:59:11 +00:00
IssMneur a29ca275a7 Converted 4 Asserts into Warnings. 2010-09-17 03:54:46 +00:00
The_E d98efc0675 Changing a string literal to the proper XSTR lookup 2010-09-17 00:01:58 +00:00
The_E 467c7d1e39 Fixing typos noticed by FUBAR 2010-09-16 21:41:10 +00:00
The_E 99dff69a3f Another assert->Assertion conversion. 2010-09-15 22:00:51 +00:00
Sushi 26c2725ccd Fix a typo 2010-09-15 05:06:23 +00:00
karajorma d181d77744 Mantis 2159 - Add the last of Ghengis' code with a switch from debug output to a warning. 2010-09-15 00:53:15 +00:00
karajorma d4e8bd4bf3 Fix Mantis 2278 (Adding a variable can mess up team loadout variables) 2010-09-15 00:50:28 +00:00
karajorma eb1889327f More SEXPs fixed for multiplayer. 2010-09-15 00:49:14 +00:00
karajorma e960a14280 Add the has-primary/secondary-weapon SEXPs 2010-09-15 00:47:08 +00:00
The_E e7fa7f021d Averting a potential div by zero 2010-09-14 23:56:26 +00:00
Sushi 8c6895a029 Re-added collision physics, added basic landings support (still needs some work) 2010-09-13 14:27:42 +00:00
The_E e76761a84a ...For real 2010-09-12 19:38:48 +00:00
The_E fe50ee7231 Fix for is-facing (hopefully) 2010-09-12 19:30:10 +00:00
The_E 3e390ecfdc ... right this time. 2010-09-11 16:55:10 +00:00
The_E 14ae54ad3c Adding ship:getEMP() for scripting. 2010-09-11 16:52:36 +00:00
Goober5000 c4a337e391 partial revert on 6444... don't forget, someone recently fixed a five-year-old bug in the countermeasures code :) 2010-09-11 00:08:57 +00:00
The_E 439c2c78cd Adding object:getrvec() and object:getuvec() for completeness' sake 2010-09-10 23:11:28 +00:00
The_E d863626f26 Adding the vector:getNormalized() and object:getfvec() functions 2010-09-10 20:51:55 +00:00
karajorma 8b1460aa30 Fix sexp_show_subtitle_image to work properly in multiplayer. 2010-09-10 10:42:12 +00:00
The_E 840d11d53d ....And another fix for is-facing. 2010-09-08 16:42:58 +00:00
The_E a41728df77 Thanks to Goober for the warning. 2010-09-08 14:58:41 +00:00
The_E 820fa1dc73 Two more Asserts turned into Assertions() for better explaining 2010-09-08 10:56:31 +00:00
The_E 67a5ae2d27 Another int3() -> Assertion() conversion 2010-09-07 15:14:36 +00:00
The_E a31d34a991 Bah, stupid typo (!= is != <!) 2010-09-07 15:11:01 +00:00
The_E a1ef957423 Adding the is-facing sexp, as per Axem's request 2010-09-06 22:11:25 +00:00
The_E c28989e121 2010-09-04 13:56:02 +00:00
Goober5000 e40cef7e4f make the if check simpler, cause part of it was redundant 2010-09-04 06:55:10 +00:00
Goober5000 a129508de7 made the AWACS hack less ugly, by making the filename replacement much more efficient
--this also allows stuff to be added past the #End of messages.tbl
improve message_filename_is_generic to consider #Simulated Speech Overrides specified in messages.tbl
2010-09-04 06:51:50 +00:00
Goober5000 3cab590e03 none.wav is redundant in this check 2010-09-04 06:40:46 +00:00
The_E a5cd35a1b9 Ooops. 2010-09-03 22:51:42 +00:00
The_E 5d625a2473 More cleanup 2010-09-03 22:45:18 +00:00
The_E 5249397161 More dead code be gone. 2010-09-03 22:41:08 +00:00
The_E b7c9f0e8dd Dead code removal 2010-09-03 22:31:25 +00:00
Goober5000 ef46114a12 disable the warning about Assertion since it clutters the build output 2010-09-03 21:44:54 +00:00
chief1983 682a517129 MSVC, why on FSM's green earth does this compile? 2010-09-03 15:04:05 +00:00
Goober5000 8733ab557a don't simply assume that something is a ship! 2010-09-03 02:57:49 +00:00
Goober5000 455b7f9d81 no need to check if other_objp is a capital ship in these if statements, since the first capital+ check would have already returned the function
this also removes the assumption that other_objp is always a ship!  it isn't!
2010-09-03 02:50:54 +00:00
Goober5000 61f66f13d6 yeah, asteroids and debris are pretty much the same thing 2010-09-03 01:26:49 +00:00
Goober5000 8e5dfc2d33 maintain the original hull, shield, and subsystem percentages when changing ship class, since we might be changing it from a briefing loadout (Mantis #2301) 2010-09-03 00:34:38 +00:00
Goober5000 31db1efaff partial revert (just one file) of Sushi's collision physics feature as it causes all kinds of crashes in asteroid fields 2010-09-03 00:16:45 +00:00
Goober5000 39f3d1d663 fix polymodel gettage since heavy_obj could be an asteroid 2010-09-03 00:14:10 +00:00
The_E 25c80ca56f ...and here. 2010-09-03 00:08:31 +00:00
The_E 83bb23a989 ...and here... 2010-09-03 00:07:50 +00:00
The_E 931cd6bf3a Better feedback here, as well 2010-09-03 00:06:52 +00:00
The_E 431b8955e8 Another Assert() redirected to more useful things 2010-09-03 00:06:01 +00:00
The_E bae585b910 ...Aaaaand another Assert()->Assertion() to make modellers happy 2010-09-02 21:48:53 +00:00
The_E e282c07427 And another int3() turned to something more useful 2010-09-02 21:25:54 +00:00
The_E 2bf6c518ac A useless int3() turned into a useful Assertion() 2010-09-02 20:27:33 +00:00
The_E ccd0401a02 More asserts turned to assertions. 2010-09-02 19:57:18 +00:00
The_E 314c4dfdc3 Removing game_load_palette(). It was useless and commented out anyway. 2010-09-02 07:47:09 +00:00
Goober5000 30feeae3d0 fix the passengers tag so that it works more like the cargo tag 2010-09-01 06:43:08 +00:00
Zacam 273be5d221 -timerbar now has the same message as -decals and is a disabled launcher command. Launcher will (or should) no longer list it as an available command and a msgbox will pop-up if in an existing command line anywhere. 2010-09-01 03:17:10 +00:00
The_E 8458f75d76 weapon_info::subtype is not a bitfield 2010-08-31 22:40:30 +00:00
chief1983 5b775e7a88 Fix Assertion on GCC to support 2 arguments, and revert hacked calls to their 2 argument state 2010-08-31 21:09:15 +00:00
Goober5000 5f85e34b3f update project file 2010-08-31 19:55:12 +00:00
Goober5000 972bdcfd15 don't generate debug information on release builds 2010-08-31 18:18:15 +00:00
chief1983 0fbcb2a2b6 Actually fix the Assertion instead of just disabling it. 2010-08-31 17:41:50 +00:00
The_E 2bfd50b5dc Change assert to assertion. Also allowed usage of non-anis or effs as muzzleflashes. 2010-08-31 13:12:45 +00:00
The_E ca37eeaf8e Changing Assert() to Assertion() again. 2010-08-31 12:52:50 +00:00
The_E c0fc384c8a Change Assert() to Assertion() for better feedback to modders 2010-08-31 12:43:04 +00:00
The_E a5c10c3ce9 Several minor touchups. 2010-08-31 12:42:39 +00:00
Goober5000 12e4d3713b add +Tech title for ships.tbl 2010-08-29 06:07:22 +00:00
Goober5000 fa1f780227 fix compile errors 2010-08-29 04:51:15 +00:00
Goober5000 cc46e18d68 handle clearing alt-name too 2010-08-29 04:45:51 +00:00
Goober5000 6bd68fdeaf add a #define 2010-08-29 04:30:21 +00:00
Goober5000 3445ce4cb8 FUBAR's change-callsign patch 2010-08-29 03:46:48 +00:00
The_E 9fbe036484 Ooops, slight typo 2010-08-26 23:42:04 +00:00
The_E 3397d3a21e From FUBAR: Patch to redirect a warning popup to the log when in standalone mode. 2010-08-26 22:56:36 +00:00
The_E ee27823042 Change Assert() to Assertion(), again to better explain why it fails. 2010-08-26 12:17:51 +00:00
The_E 3d3fbb3002 Fixes a crash when "Test Load Ship" was used with a ship that has turrets with rotation sounds defined. 2010-08-25 20:24:34 +00:00
The_E 17b4aeac33 Change Int3() to assertion for better explaining and stuff. 2010-08-22 12:59:01 +00:00
The_E e5416e3506 Remove hardcoded piece of interface code in favour of something generated dynamically. Fixes issue with too many pilot names being displayed in the pilot select screen if a custom font is in use. 2010-08-21 20:19:48 +00:00
Sushi f045a26eed Updated random sidethrust ($Random Sidethrust Percent) to include strafing attacks vs big ships, as well as making it a bit more situational for fighter vs fighter. 2010-08-21 19:55:44 +00:00
The_E a47698230b Adding a bit of sanity checking here... 2010-08-21 16:22:57 +00:00
The_E ffe6397e66 Fix issue reported by droid803 where non-player ships that have an afterburner need shield icons as well, causing debug warnings. Changed the check so that it only triggers on player ships. 2010-08-20 23:13:44 +00:00
The_E a1ecfe158b Adding the adjust-audio-volume sexp. 2010-08-19 19:45:28 +00:00
IssMneur 5dac806c8e Adds support to Voice Acting Manager in FRED for putting the speaker's name into the generated file name.
Also makes the "Generate Filename" function set the modified flag for FRED if any file names get changed.
2010-08-17 23:52:20 +00:00
IssMneur 26ae5efb0f Fixes mantis 2275: Improving remove-background-bitmap and remove-sun-bitmap so that they issue an Error if an invalid index is passed via the sexp. 2010-08-17 05:42:55 +00:00
IssMneur ad9759d2fa Clarify the help text for set-object-speed-x, set-object-speed-y, and set-object-speed-z 2010-08-17 05:37:38 +00:00
The_E 31b88687d0 And of course, I screwed it up a bit. Reading the documentation is A1 SUPAR. 2010-08-16 23:18:10 +00:00
The_E 0ac5a17102 Allow scripting to override turret AI target selection 2010-08-16 22:04:23 +00:00
The_E bde583461f Fix for assertion encountered with the warp-effect sexp. Also updated sexp help to indicate correct usage. 2010-08-11 13:08:51 +00:00
The_E 6032c0b463 Remove requirement for SM3. While this will not allow cards that are only capable of SM2 to use the standard shaders, now shaders can be written for them. 2010-08-10 18:41:12 +00:00
Sushi b64303a19e Support for allowing bombs to be destroyed by weapon blast and/or shockwaves. Weapon flags are "takes blast damage" and "takes shockwave damage" 2010-08-05 14:17:20 +00:00
chief1983 19319a4835 Whoops hangovers and VNC don't go well together, did not mean to commit this at all. 2010-08-04 19:38:29 +00:00
chief1983 f5e236e408 2010-08-04 19:33:54 +00:00
karajorma 47f157a9f7 Fix 4 more SEXPs for multiplayer. 2010-08-04 17:44:40 +00:00
Sushi 679430d654 Added to ships.tbl:
$Collision Physics: 
+Bounce 
+Both Small Bounce
+Friction
+Rotation Factor
2010-08-04 02:08:14 +00:00
taylor 25987a680d various FS2NetD fixes:
- increase sleep time during reconnect
 - better handling of disconnects from connection errors
 - proper disconnect in case of login failure
 - log stats request calls
 - don't try to read stats from packet when there aren't any to read
 - allow proper connection resetting with standalone
 - change auto-reconnect timeout from 30 minutes to 5
 - count server traffic among activity instead of just client traffic
 - reduce uneccessary client->server traffic
2010-08-03 08:22:02 +00:00
taylor e27d61bbae fix debug message 2010-08-03 08:21:59 +00:00
Goober5000 b48eb270f9 don't generate debug/pdb/map info for release builds on VC6 2010-08-02 04:07:28 +00:00
Goober5000 b00b61ccd2 revert using motion debris in asteroid fields 2010-08-02 03:52:16 +00:00
Zacam 342640920a This is the same as 6335, but for FRED. 2008 and 2010. 2010-07-30 16:21:21 +00:00
Zacam 7185348ea9 Removes /DEBUG from the Linker Properties, no longer Generating PDB files for Release builds. This should also resolve the "no disk in drive" issues. MSVC 2008 and 2010. 2010-07-30 16:13:46 +00:00
The_E 063dea2f89 Patch for issue with ai-waypoints not working correctly. The ship's goals were accidentally cleared after a single run through the waypoint path. 2010-07-29 22:30:02 +00:00
Sushi d391e3f093 Changed "big ships manage shields" to "all ships manage shields." No difference in behavior, just named more accurately. 2010-07-29 00:30:57 +00:00
The_E c6589187e4 Fix/Workaround for Mantis 2272 (Int3() in hudtarget.cpp) 2010-07-27 15:28:09 +00:00
The_E dd60442914 Change short to ushort to avoid issues with high-poly models. 2010-07-25 23:30:18 +00:00
Echelon9 b7c1dcff02 Fix for reinforcement menu bug - Mantis 2246 2010-07-25 05:04:14 +00:00
Goober5000 7df3e81080 add feature requested by BWO: group send-message-list messages at beginning of script 2010-07-22 07:51:32 +00:00
chief1983 e691fa8f94 Should allow INT_MAX to be visible on POSIX-compliant systems 2010-07-21 18:50:19 +00:00
chief1983 e9e3333c73 IssMneur's fix for Mantis #2240, allow gaps after the hardcoded retail sound entries. 2010-07-20 21:59:36 +00:00
chief1983 2d43f0b847 Per IssMneur, fix the root directory detection on *nix systems. 2010-07-19 15:50:50 +00:00
The_E d12eec674f Fix for the "is-ai-class" sexp. Previously, the sexp would compare the given AI class against the ship class' tbl default AI class, which produced erroneous results. 2010-07-19 02:12:43 +00:00
The_E dc54a7d11d No wonder it didn't really work. I was looking in the wrong array. 2010-07-18 02:18:40 +00:00
chief1983 3aba1b9f73 Bump to MAX_SHIP_FLAGS and a subtle reminder for posterity 2010-07-17 22:27:14 +00:00
chief1983 251fe9a34a One more autopilot fix for 3.6.12, per IssMneur 2010-07-17 22:18:20 +00:00
The_E 4d5008fcc1 Fix for Mantis 2263 (Objectives list is still displayed despite disable-hud-except-messages being active) 2010-07-17 14:59:32 +00:00
The_E 4f2942e440 Slight cockup on my part here. Pain flashes were not supposed to be gone for everyone. 2010-07-16 18:35:13 +00:00
The_E 3c412bef42 Updated the credits after god knows how long 2010-07-16 16:16:27 +00:00
The_E 7bcd8d162b Reverting the revert (Yay for feedback), as the ships flag solution seems to be what people really want. 2010-07-15 14:55:59 +00:00
chief1983 b60eb681e6 Fix an Assertion usage issue on *nix platforms. 2010-07-14 15:31:17 +00:00
chief1983 cbe541598e IssMneur's autopilot fixes (hooray\!) 2010-07-13 22:45:54 +00:00
The_E c1f1c47fa8 Patch for Mantis 2205 (Division by zero in do_random_sidethrust()) 2010-07-10 15:06:33 +00:00
Sushi 9c766c1315 Added "$big ships manage shields:" AI profile/AI class flag 2010-07-09 13:11:37 +00:00
Zacam 58d378134d Added the following (recursively) to the svn:ignore: .ncb, .suo, .user, desktop.ini, thumbs.db. 2010-07-08 03:51:39 +00:00
Zacam 7ad97943fd From blowfish: Mac Icon update based on: http://www.hard-light.net/forums/index.php?topic=44371.0 2010-07-08 03:35:57 +00:00
The_E 52f424a0b0 While the other code that was commented out might be unnecessary, this fvec still needs to be set up properly 2010-07-07 15:27:37 +00:00
The_E 854ff6cff9 If lock-perspective is active, the perspective should stay locked. 2010-07-07 02:19:06 +00:00
The_E 3b93ad2ba9 Reverting 6279, and making it more intelligently (Thanks Goober for the heads-up) 2010-07-07 00:04:32 +00:00
Goober5000 3cdf9d3f12 fix a bug noticed by The_E: object types are not bitfields 2010-07-05 05:43:08 +00:00
Goober5000 131805bb51 use motion debris in asteroid fields, per Galemp 2010-07-05 05:41:57 +00:00
The_E 7a8973eade Introducing new SIF2 flag ("no pain flash") to turn off the pain flash. I guess all the peeps who want to do capship missions can rejoice now. 2010-07-05 02:28:48 +00:00
Echelon9 8383d11490 Update Lua interpreter to 5.1.4 (patch 2) to fix the following bugs http://www.lua.org/bugs.html#5.1.4 2010-07-03 02:48:03 +00:00
The_E 437b27c460 A few more dialogues added 2010-06-27 21:46:50 +00:00
Goober5000 51f9cbb20a make FRED be intelligent about mission directory (Mantis #2236) 2010-06-27 08:30:45 +00:00
Goober5000 c8ef8d38ef remove unreferenced variables 2010-06-27 07:13:33 +00:00
Goober5000 614f60968c use 2_ animations in the tech room, just as in the command brief (Mantis #2231) 2010-06-27 07:05:01 +00:00
Goober5000 af2ac0a7eb remove a bit of code that should no longer be necessary due to previous upgrades/fixes 2010-06-27 06:04:48 +00:00
Backslash 5263673023 Add a $Max Directives: option to hud_gauges.tbl -- works just like $Max Escort Ships 2010-06-26 19:34:59 +00:00
Wanderer 0718bc2921 fix for potential null vec issue when using limited base rotation turrets 2010-06-24 18:21:31 +00:00
Wanderer 999ec32353 fix for salvo + check hull bug found by fubar 2010-06-24 17:56:19 +00:00
Sushi 6d29c1a462 Removed unpopular circle strafe changes to make circle-strafing AI more aggressive (like in RC2) 2010-06-24 02:33:48 +00:00
Goober5000 7edfdb32ad this is just a bit cleaner 2010-06-23 06:56:45 +00:00
Goober5000 06216fce4f remove not-kamikaze, since it was never implemented, and since its behavior is incorporated into the kamikaze sexp 2010-06-23 06:19:43 +00:00
Goober5000 be6ea31534 fix for Mantis #2056 (sexps may not want to process every ship)
also, account for the fact that Command may not be "#Command"
2010-06-23 03:05:26 +00:00
Goober5000 6966b3a57d fix a silly bug noticed by karajorma
also, slightly compact the knossos check
2010-06-22 02:29:53 +00:00
The_E 1ae587f819 Fix for null vec3d error mentioned in Mantis 1888 by Woolie Wool 2010-06-22 00:51:12 +00:00
Wanderer fd6c3a84f6 allow lua to track if ship is 'dying' during the frame (bugfix for flashy deaths script) 2010-06-21 22:06:49 +00:00
Wanderer 4d1f5f6a1c fix for the ai profile issue (mantis 2228) 2010-06-21 19:25:00 +00:00
chief1983 6284da4654 Fix the Assertion to not break Macs and Linux. 2010-06-21 17:12:23 +00:00
chief1983 eed85feae9 IssMneur's fix for #1888 (finally): Much better autopilot behavior. 2010-06-21 14:59:36 +00:00
Goober5000 f8efafb0f2 minor modification of karajorma's warp effect so that Knossos can be used for both warpin and warpout; Babylon5 still switches appropriately 2010-06-21 07:41:26 +00:00
Goober5000 5141cf6dab fix some problems with set-explosion-option (viz. all options need to be set if a special explosion is being used) 2010-06-21 07:14:54 +00:00
Goober5000 f8e3aee161 add set-explosion-option to edit explosions (needed after karajorma's new special-exp code) 2010-06-21 01:21:40 +00:00
Wanderer e047ba0155 Fix lua ray collision checks against debris pieces 2010-06-20 14:07:30 +00:00
Wanderer c0862e47bc add a null vec check - hit by fubar 2010-06-20 14:06:34 +00:00
The_E 6ead2d8d87 Stopgap fix for Mantis 2224 (Black text is unreadable in the multiplayer chat). Turned black into pink (as that colour wasn't used before). 2010-06-18 18:18:27 +00:00
karajorma 725ce08f38 Remove the -tbp command line. 2010-06-18 05:03:32 +00:00
Zacam d50cb3841c Commit of PNG Data fix as suggested and supplied by Armchair Commander and marvn.
(Read: http://www.hard-light.net/forums/index.php?topic=68405.0)
2010-06-17 19:46:46 +00:00
Goober5000 33f47d53c7 add awesome logical operators
(I wonder why nobody added these until now)
2010-06-16 02:38:24 +00:00
Goober5000 db2e20e59a add mission-time-msecs 2010-06-16 02:10:48 +00:00
The_E 67e89bdd8d Fix for Mantis 2212 (Interface animations start at frame 1, not 0) 2010-06-15 17:24:03 +00:00
The_E c0e55de8f0 Fix for Mantis 2210 (Ship models in ship selection do not always show up properly) 2010-06-15 12:04:50 +00:00
Echelon9 0d2c96ba09 Project file update to include bitarray.h 2010-06-14 14:12:45 +00:00
The_E 02e76c00e9 Project file update to include bitarray.h 2010-06-14 07:36:07 +00:00
Goober5000 7b8c035320 revert portej05's removal of the bitstring code 2010-06-14 06:56:52 +00:00
The_E d41fa67715 Don't increase the total number of loaded menu music files if a tbm with +nocreate is loaded.
This also neatly fixes the somewhat screwed up music selection list in FRED (remember all those empty lines?), albeit not completely.
2010-06-14 01:59:15 +00:00
Goober5000 7cfdf27b78 sync file for proper string length 2010-06-12 21:23:56 +00:00
Goober5000 5cc6f5e4fd sync case 2010-06-12 20:47:22 +00:00
Wanderer 4b66b6e42c related to mantis 2187 - fix to improve autoaim accuracy if additive velocity is enabled 2010-06-12 16:10:31 +00:00
The_E 8edeb00886 Some stuff for wxFRED. Slowly making progress. 2010-06-10 01:29:17 +00:00
Wanderer c01b067c1a better handling of 'dying' weapons for lua scripting.cpp
added lua controls for accessing beams
2010-06-09 16:49:20 +00:00
Goober5000 9940f9a752 add OPF_SOUND_ENVIRONMENT for Taylor's sexps
also, some tweaks for sexp checks and for SEXP_NONE_STRING
2010-06-09 07:38:27 +00:00
Wanderer 9d75c04e99 fix for target priorities and sif2 flags issue 2010-06-09 05:19:54 +00:00
The_E 56c1699aee Project File for wxFRED. 2010-06-09 05:18:45 +00:00
Wanderer a9e043f156 fixes for the external weapons patch (accidentally uploaded outdated patch) 2010-06-07 12:48:53 +00:00
Wanderer 2296b885b5 changes to external weapon model handling 2010-06-07 12:22:54 +00:00
The_E 36f1acb0ae Not quite sure how this one went broken for so long....( FSO specific .libs were not loaded on non-SSE2 configurations, leading to broken builds.) 2010-06-07 11:10:11 +00:00
Wanderer add696869b mantis 1988 - error checking for the targeting priorities 2010-06-07 10:53:34 +00:00
Goober5000 a6066d79a9 ignore generated file 2010-06-07 07:02:18 +00:00
Goober5000 bbeba26c70 adjust coordinates for The E's latest 640x480 art 2010-06-07 06:35:40 +00:00
Goober5000 b59580e84c FUBAR's feature for LOD naming: http://www.hard-light.net/forums/index.php?topic=68901.0 2010-06-07 03:58:47 +00:00
Goober5000 a992f0687c tweak fiction viewer coordinates 2010-06-07 02:13:44 +00:00
The_E 5d5b377ad8 A missing ) is bad for parsing. 2010-06-06 18:12:29 +00:00
taylor a971f3d768 make sure to stop deathroll effect too (Mantis #2215) 2010-06-06 14:50:38 +00:00
taylor 5e943b843c add some missing safety checks for Snds[] (Mantis #2216) 2010-06-06 14:50:36 +00:00
Echelon9 67a5d89d47 Removed defined but unused variables 2010-06-06 08:35:19 +00:00
taylor f80dcd4a87 make sure to always close context and device when searching through valid devices 2010-06-06 03:10:40 +00:00
taylor 96d93607dd fix OS X compile issue 2010-06-06 03:10:38 +00:00
The_E 03d0b66214 Same here. 2010-06-05 02:45:13 +00:00
The_E 719eb41cd8 Remove unused files from the project file 2010-06-05 02:36:41 +00:00
Goober5000 f37ff6da68 minor fix to the -wcs flag removal 2010-06-03 06:28:06 +00:00
karajorma 3005e447d3 Kill the -wcs flag. Should have done this years ago. 2010-06-02 12:01:13 +00:00
The_E 1dbe105933 Fix for Mantis 2214 (toparc2 and toparc3 hud anis [The Enemy Missile threat and Enemy Missile lock indicators] may have a length > 2 now, instead of being fixed at 3 frames) 2010-06-02 11:49:24 +00:00
taylor 04cac71fe9 revert r6151
Per source doppler factor is part of the EFX spec, which means all full 1.1 implementations.
2010-06-01 02:44:15 +00:00
The_E 4bee746897 According to the OpenAL programmer's guide, AL_DOPPLER_FACTOR is not a valid parameter for alSourcef 2010-05-31 10:38:00 +00:00
Wanderer 4b34460f06 Certain fixes for Bobs animation code issues. Please report if this renders any current anims invalid. 2010-05-30 19:28:21 +00:00
Echelon9 af574dacff codec1.cpp and codec1.h included in Xcode project file when no such source files present 2010-05-30 05:14:00 +00:00
The_E e101736d8f Project file update for new sound code. 2010-05-30 02:17:21 +00:00
taylor f06ef36ca6 more sane memory reserve 2010-05-29 15:53:28 +00:00
taylor 1491795451 fix endless loop 2010-05-29 15:53:27 +00:00
taylor 0a17554c4f disable doppler for the time being 2010-05-29 15:53:24 +00:00
taylor b287ecfef9 new sound code
- Mantis #58
 - Mantis #1769
 - many other fixes and improvements
2010-05-29 15:53:18 +00:00
taylor a7bac8679c fix view skew math issue (Mantis #2213) 2010-05-29 14:55:04 +00:00
taylor f72d0a4cd5 bah! remove debug code that slipped in with safety fixes 2010-05-29 10:55:33 +00:00
taylor d3e750edf7 support for newer versions of automake (Mantis #2145) 2010-05-29 10:55:30 +00:00
The_E 7f9df9c09e Fictionviewer interface adjusted for new, official interface art found here: http://blueplanet.fsmods.net/E/FictionViewer.7z 2010-05-28 20:07:05 +00:00
Wanderer 89d7a512af add read access for lua to weapon and ship info index. enable to check 'weapon_armed' status 2010-05-28 19:15:05 +00:00
karajorma 61af589c21 Swap the engage enemies messages over. 2010-05-28 06:09:53 +00:00
Sushi 270734b6f3 Fixed a parsing bug in AI.tbl that scaled Glide Attack Percent, Glide Strafe Percent, Circle Strafe Percent, and Random Sidethrust percent between 0 and 1 instead of 0 and 100 (as is the case for AI profiles.tbl) 2010-05-25 18:09:59 +00:00
Sushi 5704dce248 Fix a bug where additive weapon velocity would sometimes cause primary shots to pass through a target 2010-05-25 16:25:41 +00:00
The_E f993f7ced1 Altered the project file to allow FRED release compilation on VS2010 2010-05-25 01:11:46 +00:00
Goober5000 04436d634f remove message from queue the correct way, thus fixing the training message crash 2010-05-19 04:28:43 +00:00
Sushi e63505510b Added $Random Sidethrust Percent to AI Profiles and AI.tbl. Allows ships with sidethrust capability to sometimes randomly use it in dogfighting situations to make life more miserable for the player. 2010-05-17 19:10:34 +00:00
Goober5000 c5e3600bef reverted fix. It has problems, which is why I'm going over it first. 2010-05-16 22:26:58 +00:00
The_E acdc56272b Committing IssMneur's fix for Mantis 2183. 2010-05-16 15:40:11 +00:00
Goober5000 7a44b33152 better handling of missing models 2010-05-15 22:53:41 +00:00
Goober5000 ec2542fa1e misc silly fixes 2010-05-15 21:48:23 +00:00
Goober5000 1eb544da58 fix subsystem alignment on ship class change (Mantis #1181)
fix a bug with Bobboau's external missiles feature
2010-05-15 21:31:32 +00:00
Sushi 71ba95081c Added $No extra collision avoidance vs player flag. Makes the AI less likely to didder around like an idiot at close range. 2010-05-14 20:43:32 +00:00
Sushi b01b4a1778 Small fix for circle strafe 2010-05-14 18:57:58 +00:00
Sushi e46ba43891 Fix for Mantis 2099 2010-05-12 19:40:09 +00:00
The_E e2c5ff679c Swarm weapons should respect "$Free flight time" as well 2010-05-10 17:17:49 +00:00
The_E 132ba60085 Patch for Mantis 2202 (Children of swarm weapons do not inherit parent target) 2010-05-09 14:53:29 +00:00
Echelon9 fdb7de88da Remove commented out code (still in SVN history if needed) and the overhead of an empty function call every frame 2010-05-09 06:12:06 +00:00
Echelon9 44886e1ba5 Benefit from our use of STL vectors be removing a now unnecessary variable in cutscenes.cpp and making code cleaner and easier to read 2010-05-08 15:09:08 +00:00
Sushi 63b9efeb3a Some fixes/updates for the Circle Strafe behavior. The AI should use it a bit more effectively now. 2010-05-07 17:03:23 +00:00
chief1983 e702ce2267 Quick fix for the WarningEx breakage on *nix 2010-05-05 16:47:12 +00:00
karajorma de0c889d10 Fix compilation under OSX and Linux with WarningEx 2010-05-04 12:34:05 +00:00
The_E e2fbbb5e19 Genghis' fix for Mantis 2162 (Thruster cones have collision detection) 2010-05-03 12:32:42 +00:00
karajorma 27f58de890 Add the (in)validate-all-arguments SEXPs 2010-05-03 12:03:57 +00:00
karajorma c07d555346 Genghis' fix for Mantis 2159 (Certain parsing errors are never reported) 2010-05-02 10:24:48 +00:00
karajorma 2f635ad879 Genghis' fix for Mantis 2157 (Invalid subsystems not properly detected on mission parse). 2010-05-02 06:00:50 +00:00
karajorma 10d6940145 GencGenghis' fix for Mantis 2155 (No error checking for certain ship problems in the lab that FRED does pick up). 2010-05-02 05:54:26 +00:00
karajorma c6b8d515a4 Genghis' fix for Mantis 2151 (No error checking for incorrect engine wash entries). 2010-05-02 05:53:02 +00:00
Sushi 34c61a7caa Reverted commit 5656, due to side effect of changing AI behavior (see mantis 1982) 2010-05-01 20:39:41 +00:00
Goober5000 39d5580651 prevent HUD formatting from destroying subsystem names - Mantis #2195
also made hud_targetbox_truncate_subsys_name return void to lessen the chance of people making the mistake in the future
2010-04-30 06:33:38 +00:00
Goober5000 0d75839a9d fix rounding formula (Mantis #2194) 2010-04-30 04:03:24 +00:00
karajorma 35ac7d6afa Fix Mantis 2194 (FRED incorrectly calculates the wrong number used in wings). 2010-04-30 03:24:30 +00:00
Sushi b48b7f76ac Fix for bug causing AI to not fire secondaries, as well as a fix for other minor AI bugs 2010-04-29 18:56:11 +00:00
karajorma a2afa2b67a Switch to using the Macros for Multiplayer modes whenever possible. 2010-04-27 13:42:59 +00:00
Sushi 0889d77f9f Fix for Dynamic Glide Cap so that the cap ramps max speed in the same way as normal flight when turning afterburners on/off or changing the overclock (what it should have done in the first place). Also removed some old, unused glide code. 2010-04-26 13:38:36 +00:00
Sushi b72514fbaa Fix for 6057 (game sometimes crashes if $Turret Max Aim Update Delay not set) 2010-04-26 13:36:08 +00:00
The_E 475853afa3 Fix for Mantis 2189 (camera FOV may get corrupted by malformed commandline argument) 2010-04-21 21:14:08 +00:00
karajorma 047ae70637 FUBAR's Fix to allow Explosion-Effect to use any explosion in fireball.tbl 2010-04-20 13:05:29 +00:00
Goober5000 2e58278eba make sure Fred knows its base directory before loading the command line... this will allow it to load cmdline_fso.cfg which will allow Fred to recognize mods (Mantis #2185) 2010-04-20 05:37:34 +00:00
Goober5000 26f33cba24 fix parsing of miss factors (Mantis #2185) 2010-04-20 04:37:44 +00:00
chief1983 7846af6c24 No 2-arg asserts on Linux. 2010-04-19 23:32:52 +00:00
Goober5000 aa0c39cb7d add beam miss factor by team, requested by Blue Planet 2010-04-19 05:17:57 +00:00
Goober5000 63909095f5 merge Iss_Mneur's fix for Mantis #2173 (better error message in cmdline.cpp) 2010-04-19 03:51:05 +00:00
Goober5000 e537b1e133 merge Iss_Mneur's fix for Mantis #2178 (Assertion in missiontraining.cpp) 2010-04-19 03:49:09 +00:00
Goober5000 09602a9ffa merge The E's fix for Mantis #2182 (NaN propagation leading to rendering wonkiness) 2010-04-19 03:40:13 +00:00
Sushi f7ebd3c636 Added $Turret Max Aim Update Delay (same as $Max Aim Update Delay, but affecting turrets instead). 2010-04-15 20:03:01 +00:00
chief1983 52fb26169c Add a VS2010 project file, made from VS2010 Ultimate RC1. Added tweaks after conversion from 2008 to make the output file names and target names more dynamic. This should be the basis for getting FRED release builds to compile. The three other executables per config work fine. 2010-04-14 20:07:08 +00:00
karajorma ff7f028e0e Fix the end-mission SEXP to make it possible to test if the player is alive or not. 2010-04-13 11:15:18 +00:00
karajorma 1362e16c4c Remove a hack which wouldn't allow players to skip the penultimate FS2 mission if they failed it 5 times. 2010-04-13 11:14:20 +00:00
karajorma 4178c4b65c Iss Mneur's mission-set-subspace and hud-display-gauge SEXPs 2010-04-13 11:12:28 +00:00
Goober5000 f59fd543c9 fix Mantis #1953 (departure locations and anchors destroyed by ship editor dialog) 2010-04-13 06:51:06 +00:00
Goober5000 0dddfbca74 consolidate and fix the resetting of time compression (Mantis #2180) 2010-04-13 03:54:30 +00:00
Sushi 0c025d96f6 Fixes a bug where paths generated by exit paths aren't garbage collected. This can cause the game to crash in missions where a lot of ships launch from fighterbays. 2010-04-11 18:36:30 +00:00
746 changed files with 202876 additions and 148780 deletions

No files matched your search

+2 -14
View File
@@ -32,7 +32,7 @@ EXTRA_DIST = \
AM_CXXFLAGS = -I./code @D_CFLAGS@
AM_LDFLAGS = @D_LDFLAGS@
EXTRA_PROGRAMS = cfilearchiver cfileextractor cryptstring scramble
EXTRA_PROGRAMS = cfilearchiver cfileextractor
###############################################################################
##
@@ -47,20 +47,8 @@ cfilearchiver_SOURCES = \
cfileextractor_SOURCES = \
code/cfileextractor/cfileextractor.cpp
# cryptstring -- to encrypt strings that are used as cheat codes
cryptstring_SOURCES = \
code/cryptstring/cryptstring.cpp
# scramble -- to encrypt tables
scramble_SOURCES = \
code/parse/encrypt.cpp \
code/scramble/scramble.cpp \
code/scramble/scramble.h
# catch all to build utilitites
tools: cfilearchiver cfileextractor cryptstring scramble
tools: cfilearchiver cfileextractor
# cleaning
clean-tools:
+4 -1
View File
@@ -1,7 +1,10 @@
The "projects" directory contains ready projects for:
Microsoft Visual C++ 6
Microsoft Visual C++ 2005
Anjuta 1 (please see README with project before using)
Microsoft Visual C++ 2008
Micrsofot Visual C++ 2010
Apple Xcode
Code::Blocks
See the ChangeLog to see what's new.
+4 -2
View File
@@ -49,7 +49,7 @@ DIE=0
DIE=1
}
for AM in automake-1.9 automake-1.8 automake-1.7 automake-1.6 automake; do
for AM in automake-1.11 automake-1.10 automake-1.9 automake-1.8 automake-1.7 automake-1.6 automake; do
(check_version "$AM" 1 6 1) && {
AUTOMAKE="$AM"
break
@@ -67,7 +67,7 @@ fi
# if no automake, don't bother testing for aclocal
test -z "$AUTOMAKE" || {
for ACL in aclocal-1.9 aclocal-1.8 aclocal-1.7 aclocal-1.6 aclocal; do
for ACL in aclocal-1.11 aclocal-1.10 aclocal-1.9 aclocal-1.8 aclocal-1.7 aclocal-1.6 aclocal; do
(check_version "$ACL" 1 6 1) && {
ACLOCAL="$ACL"
break
@@ -128,6 +128,8 @@ done
#conf_flags="--enable-maintainer-mode --enable-compile-warnings" #--enable-iso-c
# to not run configure, call autogen.sh as,
# NOCONFIGURE=1 ./autogen.sh
if test x$NOCONFIGURE = x; then
echo Running $srcdir/configure $conf_flags "$@" ...
$srcdir/configure $conf_flags "$@" \
+56 -68
View File
@@ -191,7 +191,10 @@ AM_LDFLAGS = @D_LDFLAGS@ @FS2_LDFLAGS@
noinst_LIBRARIES = libcode.a
noinst_PROGRAMS = @FS2_BINARY@
EXTRA_PROGRAMS = fs2_open_r fs2_open_d wxFRED2_r wxFRED2_d fs2_open_INF_r fs2_open_INF_d wxFRED2_INF_r wxFRED2_INF_d
EXTRA_PROGRAMS = fs2_open_@PACKAGE_VERSION@ fs2_open_@PACKAGE_VERSION@_NOINF \
fs2_open_@PACKAGE_VERSION@_DEBUG fs2_open_@PACKAGE_VERSION@_NOINF_DEBUG \
wxFRED2_@PACKAGE_VERSION@ wxFRED2_@PACKAGE_VERSION@_NOINF \
wxFRED2_@PACKAGE_VERSION@_DEBUG wxFRED2_@PACKAGE_VERSION@_NOINF_DEBUG
###############################################################################
##
@@ -258,10 +261,6 @@ FS2_SOURCES = \
debugconsole/dbugfile.h \
debugconsole/timerbar.cpp \
debugconsole/timerbar.h \
decals/decals.cpp \
decals/decals.h \
demo/demo.cpp \
demo/demo.h \
exceptionhandler/exceptionhandler.cpp \
exceptionhandler/exceptionhandler.h \
external_dll/externalcode.h \
@@ -283,12 +282,16 @@ FS2_SOURCES = \
gamehelp/gameplayhelp.h \
gamesequence/gamesequence.cpp \
gamesequence/gamesequence.h \
gamesnd/eventmusic.cpp \
gamesnd/eventmusic.h \
gamesnd/gamesnd.cpp \
gamesnd/gamesnd.h \
globalincs/alphacolors.cpp \
globalincs/alphacolors.h \
globalincs/crypt.cpp \
globalincs/crypt.h \
globalincs/def_files.cpp \
globalincs/def_files.h \
globalincs/fsmemory.cpp \
globalincs/fsmemory.h \
globalincs/globals.h \
globalincs/linklist.h \
globalincs/pstypes.h \
@@ -355,7 +358,6 @@ FS2_SOURCES = \
hud/hudobserver.h \
hud/hudparse.cpp \
hud/hudparse.h \
hud/hudresource.h \
hud/hudreticle.cpp \
hud/hudreticle.h \
hud/hudshield.cpp \
@@ -524,7 +526,6 @@ FS2_SOURCES = \
network/multi_obj.h \
network/multi_observer.cpp \
network/multi_observer.h \
network/multi_oo.h \
network/multi_options.cpp \
network/multi_options.h \
network/multi_pause.cpp \
@@ -550,8 +551,6 @@ FS2_SOURCES = \
network/multi_voice.h \
network/multi_xfer.cpp \
network/multi_xfer.h \
network/psnet.cpp \
network/psnet.h \
network/psnet2.cpp \
network/psnet2.h \
network/stand_gui.cpp \
@@ -572,6 +571,8 @@ FS2_SOURCES = \
object/object.h \
object/objectshield.cpp \
object/objectshield.h \
object/objectsnd.cpp \
object/objectsnd.h \
object/objectsort.cpp \
object/parseobjectdock.cpp \
object/parseobjectdock.h \
@@ -609,6 +610,8 @@ FS2_SOURCES = \
popup/popupdead.h \
radar/radar.cpp \
radar/radar.h \
radar/radardradis.cpp \
radar/radardradis.h \
radar/radarorb.cpp \
radar/radarorb.h \
radar/radarsetup.cpp \
@@ -634,6 +637,30 @@ FS2_SOURCES = \
ship/shiphit.cpp \
ship/shiphit.h \
ship/subsysdamage.h \
sound/audiostr.cpp \
sound/audiostr.h \
sound/acm.cpp \
sound/acm.h \
sound/ds.cpp \
sound/ds.h \
sound/ds3d.cpp \
sound/ds3d.h \
sound/dscap.cpp \
sound/dscap.h \
sound/fsspeech.cpp \
sound/fsspeech.h \
sound/openal.cpp \
sound/openal.h \
sound/rtvoice.cpp \
sound/rtvoice.h \
sound/sound.cpp \
sound/sound.h \
sound/speech.cpp \
sound/speech.h \
sound/voicerec.cpp \
sound/voicerec.h \
sound/ogg/ogg.cpp \
sound/ogg/ogg.h \
species_defs/species_defs.cpp \
species_defs/species_defs.h \
starfield/nebula.cpp \
@@ -707,44 +734,6 @@ JOY_SOURCES = \
io/joy-unix.cpp
endif
## sound support sources
if FS2_SOUND
SOUND_SOURCES = \
gamesnd/eventmusic.cpp \
gamesnd/eventmusic.h \
gamesnd/gamesnd.cpp \
gamesnd/gamesnd.h \
object/objectsnd.cpp \
object/objectsnd.h \
sound/ogg/ogg.cpp \
sound/ogg/ogg.h \
sound/audiostr-openal.cpp \
sound/audiostr.cpp \
sound/audiostr.h \
sound/acm-openal.cpp \
sound/acm.h \
sound/ds.cpp \
sound/ds.h \
sound/ds3d.cpp \
sound/ds3d.h \
sound/dscap.cpp \
sound/dscap.h \
sound/rbaudio.cpp \
sound/rbaudio.h \
sound/rtvoice.cpp \
sound/rtvoice.h \
sound/sound.cpp \
sound/sound.h \
vcodec/codec1.cpp \
vcodec/codec1.h \
sound/fsspeech.cpp \
sound/fsspeech.h \
sound/speech.cpp \
sound/speech.h \
sound/voicerec.cpp \
sound/voicerec.h
endif
## Win32-specific sources
if FS2_OS_WIN32
WIN32_SOURCES = \
@@ -755,7 +744,6 @@ WIN32_SOURCES = \
directx/vdplay.h \
directx/vdplobby.h \
directx/vdsetup.h \
directx/vdsound.h \
directx/vdvp.h \
globalincs/windebug.cpp \
graphics/gl/GLAUX.H \
@@ -787,8 +775,8 @@ endif
## libcode.a
libcode_a_SOURCES = ${FS2_SOURCES} ${JOY_SOURCES} ${SOUND_SOURCES} \
${WIN32_SOURCES} ${UNIX_SOURCES}
libcode_a_SOURCES = ${FS2_SOURCES} ${JOY_SOURCES} ${WIN32_SOURCES} \
${UNIX_SOURCES}
##
## End CODE library
@@ -806,22 +794,22 @@ FS2OPEN_SOURCES = \
freespace2/levelpaging.cpp \
freespace2/levelpaging.h
fs2_open_d_SOURCES = \
fs2_open_@PACKAGE_VERSION@_DEBUG_SOURCES = \
${FS2OPEN_SOURCES}
fs2_open_r_SOURCES = \
fs2_open_@PACKAGE_VERSION@_SOURCES = \
${FS2OPEN_SOURCES}
fs2_open_INF_d_SOURCES = \
fs2_open_@PACKAGE_VERSION@_NOINF_DEBUG_SOURCES = \
${FS2OPEN_SOURCES}
fs2_open_INF_r_SOURCES = \
fs2_open_@PACKAGE_VERSION@_NOINF_SOURCES = \
${FS2OPEN_SOURCES}
fs2_open_d_LDADD = libcode.a
fs2_open_r_LDADD = libcode.a
fs2_open_INF_d_LDADD = libcode.a
fs2_open_INF_r_LDADD = libcode.a
fs2_open_@PACKAGE_VERSION@_DEBUG_LDADD = libcode.a
fs2_open_@PACKAGE_VERSION@_LDADD = libcode.a
fs2_open_@PACKAGE_VERSION@_NOINF_DEBUG_LDADD = libcode.a
fs2_open_@PACKAGE_VERSION@_NOINF_LDADD = libcode.a
##
## End MAIN binary
@@ -841,22 +829,22 @@ wxFRED_SOURCES = \
wxfred2/wxfred_xrc.cpp \
wxfred2/wxfred_xrc.h
wxFRED2_d_SOURCES = \
wxFRED2_@PACKAGE_VERSION@_DEBUG_SOURCES = \
${wxFRED_SOURCES}
wxFRED2_r_SOURCES = \
wxFRED2_@PACKAGE_VERSION@_SOURCES = \
${wxFRED_SOURCES}
wxFRED2_INF_d_SOURCES = \
wxFRED2_@PACKAGE_VERSION@_NOINF_DEBUG_SOURCES = \
${wxFRED_SOURCES}
wxFRED2_INF_r_SOURCES = \
wxFRED2_@PACKAGE_VERSION@_NOINF_SOURCES = \
${wxFRED_SOURCES}
wxFRED2_d_LDADD = libcode.a
wxFRED2_r_LDADD = libcode.a
wxFRED2_INF_d_LDADD = libcode.a
wxFRED2_INF_r_LDADD = libcode.a
wxFRED2_@PACKAGE_VERSION@_DEBUG_LDADD = libcode.a
wxFRED2_@PACKAGE_VERSION@_LDADD = libcode.a
wxFRED2_@PACKAGE_VERSION@_NOINF_DEBUG_LDADD = libcode.a
wxFRED2_@PACKAGE_VERSION@_NOINF_LDADD = libcode.a
##
## End wxFRED2 binary
+26 -19
View File
@@ -7,23 +7,26 @@
*
*/
// The code in here is just for bookeeping, allocating
// ai slots and linking them to ships.
// See AiCode.cpp for the actual AI code.
/**
* @file
* The code in here is just for bookeeping, allocating AI slots and linking them to ships.
* See AiCode.cpp for the actual AI code.
*/
#include "ai/ai.h"
#include "object/object.h"
#include "ship/ship.h"
int Total_goal_ship_names = 0;
char Goal_ship_names[MAX_GOAL_SHIP_NAMES][NAME_LENGTH];
int Total_goal_target_names = 0;
char Goal_target_names[MAX_GOAL_TARGET_NAMES][NAME_LENGTH];
ai_info Ai_info[MAX_AI_INFO];
ai_info *Player_ai;
// Return index of free AI slot.
// Return -1 if no free slot.
/**
* @brief Returns index of free AI slot.
* @return Return -1 if no free slot.
*/
int ai_get_slot(int shipnum)
{
int i;
@@ -40,8 +43,10 @@ int ai_get_slot(int shipnum)
return -1;
}
// Releases an AI slot to be used by someone else.
// Only modifies in Ai_info struct. Does not modify hook in ship.
/**
* @brief Frees a currently used AI slot.
* @details Only modifies in ::Ai_info struct. Does not modify hook in ship.
*/
void ai_free_slot(int ai_index)
{
Assert( (ai_index >= 0) && (ai_index < MAX_AI_INFO) );
@@ -77,20 +82,22 @@ void set_wingnum(int objnum, int wingnum)
Ai_info[ai_index].wing = wingnum;
}
char *ai_get_goal_ship_name(char *name, int *index)
char *ai_get_goal_target_name(char *name, int *index)
{
Assert(name != NULL);
Assert(index != NULL);
int i;
for (i=0; i < Total_goal_ship_names; i++)
if (!stricmp(name, Goal_ship_names[i])) {
for (i=0; i < Total_goal_target_names; i++)
if (!stricmp(name, Goal_target_names[i])) {
*index = i;
return Goal_ship_names[i];
return Goal_target_names[i];
}
Assert(Total_goal_ship_names < MAX_GOAL_SHIP_NAMES);
Assert(strlen(name) < NAME_LENGTH - 1);
i = Total_goal_ship_names++;
strcpy_s(Goal_ship_names[i], name);
Assert(Total_goal_target_names < MAX_GOAL_TARGET_NAMES);
Assertion(strlen(name) <= NAME_LENGTH - 1, "Goal target name %s is too long. Needs to be 31 characters or less.", name);
i = Total_goal_target_names++;
strcpy_s(Goal_target_names[i], name);
*index = i;
return Goal_ship_names[i];
return Goal_target_names[i];
}
+69 -42
View File
@@ -17,10 +17,12 @@
#include "globalincs/systemvars.h"
#include "ai/ai_profiles.h"
#include "physics/physics.h"
#include "object/waypoint.h"
struct ship_weapon;
struct ship_subsys;
struct object;
struct ship_info;
#define AI_DEFAULT_CLASS 3 // default AI class for new ships (Fred)
@@ -31,11 +33,11 @@ struct object;
#define AIF_SEEK_LOCK (1 << 4) // set if should focus on gaining aspect lock, not hitting with lasers
#define AIF_FORMATION_OBJECT (1 << 5) // Fly in formation off a specific object.
#define AIF_TEMPORARY_IGNORE (1 << 6) // Means current ignore_objnum is only temporary, not an order from the player.
#define AIF_USE_EXIT_PATH (1 << 7) // Used by path code, to flag path as an exit path
#define AIF_USE_STATIC_PATH (1 << 8) // Used by path code, use fixed path, don't try to recreate
#define AIF_USE_EXIT_PATH (1 << 7) // Used by path code, to flag path as an exit path
#define AIF_USE_STATIC_PATH (1 << 8) // Used by path code, use fixed path, don't try to recreate
#define AIF_TARGET_COLLISION (1 << 9) // Collided with aip->target_objnum last frame. Avoid that ship for half a second or so.
#define AIF_UNLOAD_SECONDARIES (1 << 10) // Fire secondaries as fast as possible!
#define AIF_ON_SUBSYS_PATH (1 << 11) // Current path leads to a subsystem
#define AIF_ON_SUBSYS_PATH (1 << 11) // Current path leads to a subsystem
#define AIF_AVOID_SHOCKWAVE_SHIP (1 << 12) // Avoid an existing shockwave from a ship.
#define AIF_AVOID_SHOCKWAVE_WEAPON (1 << 13) // Avoid an expected shockwave from a weapon. shockwave_object field contains object index.
#define AIF_AVOID_SHOCKWAVE_STARTED (1 << 14) // Already started avoiding shockwave, don't keep deciding whether to avoid.
@@ -47,7 +49,7 @@ struct object;
#define AIF_AVOIDING_BIG_SHIP (1 << 20) // Avoiding a large ship.
#define AIF_BIG_SHIP_COLLIDE_RECOVER_1 (1 << 21) // Collided into a big ship. Recovering by flying away.
#define AIF_BIG_SHIP_COLLIDE_RECOVER_2 (1 << 22) // Collided into a big ship. Fly towards big ship sphere perimeter.
#define AIF_STEALTH_PURSUIT (1 << 23) // Ai is trying to fight stealth ship
#define AIF_STEALTH_PURSUIT (1 << 23) // AI is trying to fight stealth ship
// Goober5000
#define AIF_UNLOAD_PRIMARIES (1 << 24) // Fire primaries as fast as possible!
@@ -58,7 +60,7 @@ struct object;
// dock_orient_and_approach() modes.
#define DOA_APPROACH 1 // Approach the current point on the path (aip->path_cur)
#define DOA_DOCK 2 // Dock with goal object.
#define DOA_DOCK 2 // Dock with goal object.
#define DOA_UNDOCK_1 3 // Begin undocking with goal object. Just move away.
#define DOA_UNDOCK_2 4 // Secondary undocking. Move away.
#define DOA_UNDOCK_3 5 // Tertiary undocking. Move away and orient away.
@@ -72,7 +74,7 @@ struct object;
// Submodes for seeking safety.
#define AISS_1 41 // Pick a spot to fly to.
#define AISS_2 42 // Flying to spot.
#define AISS_3 43 // Gotten near spot, fly about there.
#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
@@ -81,8 +83,8 @@ struct object;
// 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_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
@@ -95,7 +97,7 @@ struct object;
#define AIGF_GOAL_OVERRIDE (1<<4) // paired with AIG_TYPE_DYNAMIC to mean this goal overrides any other goal
#define AIGF_PURGE (1<<5) // purge this goal next time we process
#define AIGF_GOALS_PURGED (1<<6) // this goal has already caused other goals to get purged
#define AIGF_DOCK_SOUND_PLAYED (1<<7) // Goober5000 - replacement for AL's hack ;)
#define AIGF_DEPART_SOUND_PLAYED (1<<7) // Goober5000 - replacement for AL's hack ;)
#define AIGF_DOCK_INDEXES_VALID (AIGF_DOCKER_INDEX_VALID|AIGF_DOCKEE_INDEX_VALID)
@@ -125,10 +127,12 @@ typedef struct ai_goal {
int 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
char *ship_name; // name of the ship that this goal acts upon
int ship_name_index; // index of ship_name in Goal_ship_names[][]
int wp_index; // index into waypoints list of waypoints that this ship might fly.
int weapon_signature; // signature of weapon this ship might be chasing. Paired with above value to get target.
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)
@@ -145,7 +149,7 @@ typedef struct ai_goal {
} ai_goal;
#define MAX_GOAL_SHIP_NAMES 100
#define MAX_GOAL_TARGET_NAMES 100
#define AIM_CHASE 0
#define AIM_EVADE 1
@@ -155,25 +159,25 @@ typedef struct ai_goal {
#define AIM_GUARD 5 // Guard an object
#define AIM_AVOID 6 // Avoid an object
#define AIM_WAYPOINTS 7 // Fly waypoints
#define AIM_DOCK 8 // Dock with ship.
#define AIM_NONE 9 // Uh, do nothing.
#define AIM_DOCK 8 // Dock with ship.
#define AIM_NONE 9 // Uh, do nothing.
#define AIM_BIGSHIP 10 // Like a capital ship, doesn't focus on one ship.
#define AIM_PATH 11 // Follow path on ship
#define AIM_PATH 11 // Follow path on ship
#define AIM_BE_REARMED 12 // Allow self to be rearmed
#define AIM_SAFETY 13 // Seek safety at periphery of battle
#define AIM_EVADE_WEAPON 14 // Evade a weapon.
#define AIM_STRAFE 15 // attack a big ship by strafing it
#define AIM_STRAFE 15 // Attack a big ship by strafing it
#define AIM_PLAY_DEAD 16 // Play dead. Get it? Don't move, fire, etc.
#define AIM_BAY_EMERGE 17 // Emerging from a fighter bay, following path to do so
#define AIM_BAY_DEPART 18 // Departing to a fighter bay, following path to do so
#define AIM_SENTRYGUN 19 // AI mode for sentry guns only (floating turrets)
#define AIM_BAY_EMERGE 17 // Emerging from a fighter bay, following path to do so
#define AIM_BAY_DEPART 18 // Departing to a fighter bay, following path to do so
#define AIM_SENTRYGUN 19 // AI mode for sentry guns only (floating turrets)
#define AIM_WARP_OUT 20 // Commence warp out sequence. Point in legal direction. Then call John's code.
#define AIM_FLY_TO_SHIP 21 // [Kazan] Fly to a ship, doesn't matter if it's hostile or friendly -- for Autopilot usage
#define AIM_FLY_TO_SHIP 21 // [Kazan] Fly to a ship, doesn't matter if it's hostile or friendly -- for Autopilot usage
#define MAX_AI_BEHAVIORS 22 // Number of AIM_xxxx types
#define MAX_AI_BEHAVIORS 22 // Number of AIM_xxxx types
#define MAX_WAYPOINTS_PER_LIST 20
#define MAX_ENEMY_DISTANCE 2500.0f // maximum distance from which a ship will pursue an enemy.
#define MAX_ENEMY_DISTANCE 2500.0f // Maximum distance from which a ship will pursue an enemy.
#define AI_GOAL_NONE -1
@@ -205,12 +209,16 @@ typedef struct ai_class {
float ai_glide_attack_percent[NUM_SKILL_LEVELS];
float ai_circle_strafe_percent[NUM_SKILL_LEVELS];
float ai_glide_strafe_percent[NUM_SKILL_LEVELS];
float ai_random_sidethrust_percent[NUM_SKILL_LEVELS];
float ai_stalemate_time_thresh[NUM_SKILL_LEVELS];
float ai_stalemate_dist_thresh[NUM_SKILL_LEVELS];
int ai_chance_to_use_missiles_on_plr[NUM_SKILL_LEVELS];
float ai_max_aim_update_delay[NUM_SKILL_LEVELS];
float ai_turret_max_aim_update_delay[NUM_SKILL_LEVELS];
int ai_profile_flags; //Holds the state of flags that are set
int ai_profile_flags_set; //Holds which flags are set and which are just left alone
int ai_profile_flags2;
int ai_profile_flags2_set;
//SUSHI: These are optional overrides to an AI class to prevent the automatic scaling based on AI class index
int ai_aburn_use_factor[NUM_SKILL_LEVELS];
@@ -246,13 +254,12 @@ typedef struct ai_class {
#define AIS_CHASE_CIRCLESTRAFE 19 // Attempt a circle-strafe on the target
// Submodes for docking behavior
#define AIS_DOCK_0 21
#define AIS_DOCK_1 22
#define AIS_DOCK_2 23
#define AIS_DOCK_3 24
//#define AIS_DOCK_3A 25
#define AIS_DOCK_4 26 // Only for rearm/repair.
#define AIS_DOCK_4A 27 // Only for not rearm/repair. MK, 7/15/97
#define AIS_DOCK_0 20
#define AIS_DOCK_1 21
#define AIS_DOCK_2 22
#define AIS_DOCK_3 23
#define AIS_DOCK_4 24 // Only for rearm/repair.
#define AIS_DOCK_4A 25 // Only for not rearm/repair. MK, 7/15/97
#define AIS_UNDOCK_0 30
#define AIS_UNDOCK_1 31
#define AIS_UNDOCK_2 32
@@ -350,10 +357,9 @@ typedef struct ai_info {
int ai_class; // Class. Might be override of default.
// Probably become obsolete, to be replaced by path_start, path_cur, etc.
int wp_list; // waypoint list index
int wp_index; // waypoint index in list
waypoint_list *wp_list; // waypoint list being followed
SCP_list<waypoint>::iterator wp_index; // waypoint index in list
int wp_flags; // waypoint flags, see WPF_xxxx
int wp_dir; // 1 or -1, amount to add to get to next waypoint index.
int waypoint_speed_cap; // -1 no cap, otherwise cap - changed to int by Goober5000
// Path following information
@@ -371,6 +377,7 @@ typedef struct ai_info {
fix path_next_check_time; // Last time checked to see if would collide with model.
int path_goal_dist; // minimum distance to first path point to consider path reached
int path_subsystem_next_check; // timestamp to next check if subsystem is still visible
vec3d path_depart_orient; //Rotational orientation associated with the path
int submode;
int previous_submode; // previous submode, get it?
@@ -435,11 +442,14 @@ typedef struct ai_info {
float ai_glide_attack_percent;
float ai_circle_strafe_percent;
float ai_glide_strafe_percent;
float ai_random_sidethrust_percent;
float ai_stalemate_time_thresh;
float ai_stalemate_dist_thresh;
int ai_chance_to_use_missiles_on_plr;
float ai_max_aim_update_delay;
float ai_turret_max_aim_update_delay;
int ai_profile_flags; //Holds AI_Profiles flags (possibly overriden by AI class) that actually apply to AI
int ai_profile_flags2;
union {
@@ -453,9 +463,6 @@ typedef struct ai_info {
float aspect_locked_time; // Time towards acquiring lock for current_target
// ship_subsys *targeted_subobject; // subsystem to attack
// int attack_subsystem_parent; // objnum of the object containing the attack_subsystem
// Goober5000
int support_ship_objnum; // objnum of support ship docking with us, or (if we're a support ship) object we're docking to
int support_ship_signature; // signature of the same
@@ -501,7 +508,7 @@ typedef struct ai_info {
int self_destruct_timestamp; // Time at which to self-destruct, probably due to being disabled.
int ok_to_target_timestamp; // Time at which this ship can dynamically target.
float kamikaze_damage; // some damage value used to produce a shockwave from a kamikaze ship
int kamikaze_damage; // some damage value used to produce a shockwave from a kamikaze ship
vec3d big_attack_point; // Global point this ship is attacking on a big ship.
vec3d big_attack_surface_normal; // Surface normal at ship at big_attack_point;
int pick_big_attack_point_timestamp; // timestamp at which to pick a new point to attack on a big ship.
@@ -531,6 +538,17 @@ typedef struct ai_info {
int ai_override_timestamp; // mark for when to end the current override
} ai_info;
// Goober5000
typedef struct {
vec3d docker_point;
vec3d dockee_point;
int dock_mode;
int submodel;
vec3d submodel_pos;
float submodel_r;
float submodel_w;
} rotating_dockpoint_info;
#define MAX_AI_INFO MAX_SHIPS
// SUBSYS_PATH_DIST is used as the distance that a subsystem path should terminate from the actual
@@ -543,8 +561,8 @@ typedef struct ai_info {
#define BURST_DURATION 500 // decay time over which Player->damage_this_burst falls from MAX_BURST_DAMAGE to 0
extern int Mission_all_attack; // !0 means all teams attack all teams.
extern int Total_goal_ship_names;
extern char Goal_ship_names[MAX_GOAL_SHIP_NAMES][NAME_LENGTH];
extern int Total_goal_target_names;
extern char Goal_target_names[MAX_GOAL_TARGET_NAMES][NAME_LENGTH];
extern void update_ai_info_for_hit(int hitter_obj, int hit_obj);
extern void ai_frame_all(void);
@@ -586,7 +604,7 @@ void ai_process( object * obj, int ai_index, float frametime );
int get_wingnum(int objnum);
void set_wingnum(int objnum, int wingnum);
char *ai_get_goal_ship_name(char *name, int *index);
char *ai_get_goal_target_name(char *name, int *index);
extern void init_ai_system(void);
extern void ai_attack_object(object *attacker, object *attacked, ship_subsys *ssp);
@@ -597,7 +615,7 @@ extern void ai_dock_with_object(object *docker, int docker_index, object *dockee
extern void ai_stay_still(object *still_objp, vec3d *view_pos);
extern void ai_set_default_behavior(object *obj, int classnum);
extern void ai_do_default_behavior(object *obj);
extern void ai_start_waypoints(object *objp, int waypoint_list_index, int wp_flags);
extern void ai_start_waypoints(object *objp, waypoint_list *wp_list, int wp_flags);
extern void ai_ship_hit(object *objp_ship, object *hit_objp, vec3d *hitpos, int shield_quadrant, vec3d *hit_normal);
extern void ai_ship_destroy(int shipnum, int method);
extern void ai_turn_towards_vector(vec3d *dest, object *objp, float frametime, float turn_time, vec3d *slide_vec, vec3d *rel_pos, float bank_override, int flags, vec3d *rvec = NULL, int sexp_flags = 0);
@@ -632,6 +650,7 @@ extern ship_subsys *set_targeted_subsys(ai_info *aip, ship_subsys *new_subsys, i
extern void ai_rearm_repair( object *objp, int docker_index, object *goal_objp, int dockee_index );
extern void ai_add_rearm_goal( object *requester_objp, object *support_objp );
extern void create_model_path(object *pl_objp, object *mobjp, int path_num, int subsys_path=0);
extern int ai_find_goal_index( ai_goal* aigp, int mode, int submode = -1, int priority = -1 );
// Goober5000
extern void ai_do_safety(object *objp);
@@ -672,6 +691,10 @@ extern void ai_do_objects_docked_stuff(object *docker, int docker_point, object
extern void ai_do_objects_undocked_stuff( object *docker, object *dockee );
extern void ai_do_objects_repairing_stuff( object *repaired_obj, object *repair_obj, int how );
// Goober5000
// Move to a position relative to a dock bay using thrusters.
extern float dock_orient_and_approach(object *docker_objp, int docker_index, object *dockee_objp, int dockee_index, int dock_mode, rotating_dockpoint_info *rdinfo = NULL);
extern int find_danger_weapon(object *sobjp, float dtime, float *atime, float dot_threshhold);
void ai_set_mode_warp_out(object *objp, ai_info *aip);
@@ -694,4 +717,8 @@ void init_aip_from_class_and_profile(ai_info *aip, ai_class *aicp, ai_profile_t
//SUSHI: Updating AI aim
void ai_update_aim(ai_info *aip, object* En_Objp);
//SUSHI: Random evasive sidethrust
void do_random_sidethrust(ai_info *aip, ship_info *sip);
#endif
+103 -7
View File
@@ -12,6 +12,8 @@
#include "ai/ai_profiles.h"
#include "parse/parselo.h"
#include "localization/localize.h"
#include "weapon/weapon.h"
#include "ship/ship.h"
// global stuff
@@ -46,13 +48,32 @@ void set_flag(ai_profile_t *profile, char *name, int flag, int type)
}
}
char *AI_path_types[] = {
"normal",
"alt1",
};
int Num_ai_path_types = sizeof(AI_path_types)/sizeof(char*);
int ai_path_type_match(char *p)
{
int i;
for(i = 0; i < Num_ai_path_types; i++)
{
if(!stricmp(AI_path_types[i], p))
return i;
}
return -1;
}
void parse_ai_profiles_tbl(char *filename)
{
int i, rval;
bool no_create = false;
char profile_name[NAME_LENGTH];
ai_profile_t dummy_profile;
char *saved_Mp = NULL;
char buf[NAME_LENGTH];
// open localization
lcl_ext_open();
@@ -84,6 +105,7 @@ void parse_ai_profiles_tbl(char *filename)
{
ai_profile_t *profile = &dummy_profile;
ai_profile_t *previous_profile = NULL;
bool no_create = false;
// get the name
required_string("$Profile Name:");
@@ -238,10 +260,10 @@ void parse_ai_profiles_tbl(char *filename)
parse_float_list(profile->glide_attack_percent, NUM_SKILL_LEVELS);
//Percent is nice for modders, but here in the code we want it betwwen 0 and 1.0
//While we're at it, verify the range
for (int i = 0; i < NUM_SKILL_LEVELS; i++) {
for (i = 0; i < NUM_SKILL_LEVELS; i++) {
if (profile->glide_attack_percent[i] < 0.0f || profile->glide_attack_percent[i] > 100.0f) {
profile->glide_attack_percent[i] = 0.0f;
Warning(LOCATION, "$Glide Attack Percent should be between 0 and 100.0 (read %f). Setting to 0.", profile->glide_attack_percent[i]);
profile->glide_attack_percent[i] = 0.0f;
}
profile->glide_attack_percent[i] /= 100.0;
}
@@ -251,10 +273,10 @@ void parse_ai_profiles_tbl(char *filename)
parse_float_list(profile->circle_strafe_percent, NUM_SKILL_LEVELS);
//Percent is nice for modders, but here in the code we want it betwwen 0 and 1.0
//While we're at it, verify the range
for (int i = 0; i < NUM_SKILL_LEVELS; i++) {
for (i = 0; i < NUM_SKILL_LEVELS; i++) {
if (profile->circle_strafe_percent[i] < 0.0f || profile->circle_strafe_percent[i] > 100.0f) {
profile->circle_strafe_percent[i] = 0.0f;
Warning(LOCATION, "$Circle Strafe Percent should be between 0 and 100.0 (read %f). Setting to 0.", profile->circle_strafe_percent[i]);
profile->circle_strafe_percent[i] = 0.0f;
}
profile->circle_strafe_percent[i] /= 100.0;
}
@@ -264,15 +286,28 @@ void parse_ai_profiles_tbl(char *filename)
parse_float_list(profile->glide_strafe_percent, NUM_SKILL_LEVELS);
//Percent is nice for modders, but here in the code we want it betwwen 0 and 1.0
//While we're at it, verify the range
for (int i = 0; i < NUM_SKILL_LEVELS; i++) {
for (i = 0; i < NUM_SKILL_LEVELS; i++) {
if (profile->glide_strafe_percent[i] < 0.0f || profile->glide_strafe_percent[i] > 100.0f) {
profile->glide_strafe_percent[i] = 0.0f;
Warning(LOCATION, "$Glide Strafe Percent should be between 0 and 100.0 (read %f). Setting to 0.", profile->glide_strafe_percent[i]);
profile->glide_strafe_percent[i] = 0.0f;
}
profile->glide_strafe_percent[i] /= 100.0;
}
}
if (optional_string("$Random Sidethrust Percent:")) {
parse_float_list(profile->random_sidethrust_percent, NUM_SKILL_LEVELS);
//Percent is nice for modders, but here in the code we want it betwwen 0 and 1.0
//While we're at it, verify the range
for (i = 0; i < NUM_SKILL_LEVELS; i++) {
if (profile->random_sidethrust_percent[i] < 0.0f || profile->random_sidethrust_percent[i] > 100.0f) {
Warning(LOCATION, "$Random Sidethrust Percent should be between 0 and 100.0 (read %f). Setting to 0.", profile->random_sidethrust_percent[i]);
profile->random_sidethrust_percent[i] = 0.0f;
}
profile->random_sidethrust_percent[i] /= 100.0;
}
}
if (optional_string("$Stalemate Time Threshold:"))
parse_float_list(profile->stalemate_time_thresh, NUM_SKILL_LEVELS);
@@ -309,6 +344,12 @@ void parse_ai_profiles_tbl(char *filename)
if (optional_string("$Max Aim Update Delay:"))
parse_float_list(profile->max_aim_update_delay, NUM_SKILL_LEVELS);
if (optional_string("$Turret Max Aim Update Delay:"))
parse_float_list(profile->turret_max_aim_update_delay, NUM_SKILL_LEVELS);
if (optional_string("$Detail Distance Multiplier:"))
parse_float_list(profile->detail_distance_mult, NUM_SKILL_LEVELS);
set_flag(profile, "$big ships can attack beam turrets on untargeted ships:", AIPF_BIG_SHIPS_CAN_ATTACK_BEAM_TURRETS_ON_UNTARGETED_SHIPS, AIP_FLAG);
set_flag(profile, "$smart primary weapon selection:", AIPF_SMART_PRIMARY_WEAPON_SELECTION, AIP_FLAG);
@@ -373,9 +414,64 @@ void parse_ai_profiles_tbl(char *filename)
set_flag(profile, "$turrets ignore targets radius in range checks:", AIPF2_TURRETS_IGNORE_TARGET_RADIUS, AIP_FLAG2);
set_flag(profile, "$no extra collision avoidance vs player:", AIPF2_NO_SPECIAL_PLAYER_AVOID, AIP_FLAG2);
set_flag(profile, "$perform less checks for death screams:", AIPF2_PERFORM_LESS_SCREAM_CHECKS, AIP_FLAG2);
set_flag(profile, "$advanced turret fov edge checks:", AIPF2_ADVANCED_TURRET_FOV_EDGE_CHECKS, AIP_FLAG2);
set_flag(profile, "$require turrets to have target in fov:", AIPF2_REQUIRE_TURRET_TO_HAVE_TARGET_IN_FOV, AIP_FLAG2);
set_flag(profile, "$all ships manage shields:", AIPF2_ALL_SHIPS_MANAGE_SHIELDS, AIP_FLAG2);
set_flag(profile, "$ai aims from ship center:", AIPF2_AI_AIMS_FROM_SHIP_CENTER, AIP_FLAG2);
set_flag(profile, "$allow primary link delay:", AIPF2_ALLOW_PRIMARY_LINK_DELAY, AIP_FLAG2);
set_flag(profile, "$allow beams to damage bombs:", AIPF2_BEAMS_DAMAGE_WEAPONS, AIP_FLAG2);
set_flag(profile, "$disable weapon damage scaling for player:", AIPF2_PLAYER_WEAPON_SCALE_FIX, AIP_FLAG2);
profile->ai_path_mode = AI_PATH_MODE_NORMAL;
if(optional_string("$ai path mode:"))
{
stuff_string(buf, F_NAME, NAME_LENGTH);
int j = ai_path_type_match(buf);
if(j >= 0) {
profile->ai_path_mode = j;
} else {
Warning(LOCATION, "Invalid ai path mode '%s' specified", buf);
}
}
if (optional_string("$Default weapon select effect:")) {
char effect[NAME_LENGTH];
stuff_string(effect, F_NAME, NAME_LENGTH);
if (!stricmp(effect, "FS1"))
Default_weapon_select_effect = 1;
if (!stricmp(effect, "off"))
Default_weapon_select_effect = 0;
}
if (optional_string("$Default ship select effect:")) {
char effect[NAME_LENGTH];
stuff_string(effect, F_NAME, NAME_LENGTH);
if (!stricmp(effect, "FS1"))
Default_ship_select_effect = 1;
if (!stricmp(effect, "off"))
Default_ship_select_effect = 0;
}
// if we've been through once already and are at the same place, force a move
if ( saved_Mp && (saved_Mp == Mp) )
{
char buf[60];
memset(buf, 0, 60);
strncpy(buf, Mp, 59);
mprintf(("WARNING: Unrecognized parameter in ai_profiles: %s\n", buf));
Mp++;
}
// find next valid option
skip_to_start_of_string_either("$", "#");
+19
View File
@@ -52,7 +52,20 @@
// flags2
#define AIPF2_TURRETS_IGNORE_TARGET_RADIUS (1 << 0)
#define AIPF2_NO_SPECIAL_PLAYER_AVOID (1 << 1)
#define AIPF2_PERFORM_LESS_SCREAM_CHECKS (1 << 2)
#define AIPF2_ALL_SHIPS_MANAGE_SHIELDS (1 << 3)
#define AIPF2_ADVANCED_TURRET_FOV_EDGE_CHECKS (1 << 4)
#define AIPF2_REQUIRE_TURRET_TO_HAVE_TARGET_IN_FOV (1 << 5)
#define AIPF2_AI_AIMS_FROM_SHIP_CENTER (1 << 6)
#define AIPF2_ALLOW_PRIMARY_LINK_DELAY (1 << 7)
#define AIPF2_BEAMS_DAMAGE_WEAPONS (1 << 8)
#define AIPF2_PLAYER_WEAPON_SCALE_FIX (1 << 9)
// AI Path types
#define AI_PATH_MODE_NORMAL 0
#define AI_PATH_MODE_ALT1 1
#define MAX_AI_PROFILES 5
typedef struct ai_profile_t {
@@ -93,9 +106,11 @@ typedef struct ai_profile_t {
float glide_attack_percent[NUM_SKILL_LEVELS]; // SUSHI: The likelihood (0.0-1.0) of the AI to use the "glide attack" move
float circle_strafe_percent[NUM_SKILL_LEVELS]; // SUSHI: The likelihood (0.0-1.0) of the AI to use the "circle strafe" move
float glide_strafe_percent[NUM_SKILL_LEVELS]; // SUSHI: The likelihood (0.0-1.0) of the AI to use glide when strafing capships
float random_sidethrust_percent[NUM_SKILL_LEVELS]; // SUSHI: The likelihood (0.0-1.0) of the AI to randomly use sidethrust while dogfihthing
float stalemate_time_thresh[NUM_SKILL_LEVELS]; // SUSHI: The amount of time required for the AI to detect (and try to break) dogfight stalemate
float stalemate_dist_thresh[NUM_SKILL_LEVELS]; // SUSHI: The maximum distance the AI and target must be within for a stalemate
float max_aim_update_delay[NUM_SKILL_LEVELS]; // SUSHI: The maximum delay before the AI updates their aim against small ships
float turret_max_aim_update_delay[NUM_SKILL_LEVELS]; // SUSHI: As above, but for turrets updating their aim
// Multiplicative delay factors for increasing skill levels.
float ship_fire_delay_scale_hostile[NUM_SKILL_LEVELS];
@@ -124,6 +139,10 @@ typedef struct ai_profile_t {
// the chance (x/7) that ship is allowed to fire missiles at player ship.
int chance_to_use_missiles_on_plr[NUM_SKILL_LEVELS];
float detail_distance_mult[MAX_DETAIL_LEVEL + 1]; //MAX_DETAIL_LEVEL really needs to be 4
int ai_path_mode;
} ai_profile_t;
+29 -17
View File
@@ -173,6 +173,7 @@ done_1:
}
mc_info mc;
mc.model_instance_num = Ships[objp->instance].model_instance_num;
mc.model_num = sip->model_num;
mc.orient = &objp->orient;
mc.pos = &objp->pos;
@@ -376,7 +377,12 @@ int ai_big_maybe_follow_subsys_path(int do_dot_check)
float dist;
pm = model_get( Ship_info[Ships[Pl_objp->instance].ship_info_index].model_num );
//Necessary sanity check
polymodel *pm_t;
pm_t = model_get(Ship_info[Ships[Objects[aip->target_objnum].instance].ship_info_index].model_num);
Assertion(aip->targeted_subsys->system_info->path_num <= pm_t->n_paths, "Invalid Path number %d for subsystem %s on ship %s (Model: %s)\n", aip->targeted_subsys->system_info->path_num, aip->targeted_subsys->system_info->name, Ship_info[Ships[Objects[aip->target_objnum].instance].ship_info_index].name, pm_t->filename );
if (aip->targeted_subsys->system_info->path_num > pm_t->n_paths)
return 0;
// If attacking a subsystem, ensure that we have an unobstructed line of sight... if not, then move
// towards path linked to subsystem
subsys_in_sight = 0; // assume Pl_objp doesn't have line of sight to subys
@@ -420,7 +426,7 @@ int ai_big_maybe_follow_subsys_path(int do_dot_check)
aip->path_goal_dist = 5;
subsys_path_num = aip->targeted_subsys->system_info->path_num;
if ( (aip->path_start) == -1 || (aip->mp_index != subsys_path_num) ) {
if ( ((aip->path_start) == -1 || (aip->mp_index != subsys_path_num)) && subsys_path_num <= pm->n_paths ) {
// maybe create a new path
if ( subsys_path_num >= 0 ) {
Assert(aip->target_objnum >= 0);
@@ -466,7 +472,6 @@ int ai_big_maybe_follow_subsys_path(int do_dot_check)
// for now, only follow the path to the first point
if ( aip->path_cur < (aip->path_start+aip->path_length-1) ) {
if ( aip->goal_objnum != aip->target_objnum ) {
//Int3(); // what is going on here? - Get Alan
aip->previous_mode = aip->mode;
aip->mode = AIM_NONE;
aip->submode = -1;
@@ -547,7 +552,7 @@ void ai_big_chase_attack(ai_info *aip, ship_info *sip, vec3d *enemy_pos, float d
object *objp;
for ( objp = GET_FIRST(&obj_used_list); objp !=END_OF_LIST(&obj_used_list); objp = GET_NEXT(objp) ) {
if ((objp->type == OBJ_WEAPON) && (iff_x_attacks_y(Ships[Pl_objp->instance].team, Weapons[objp->instance].team)))
if (Weapon_info[objp->instance].subtype == WP_LASER) {
if (Weapon_info[Weapons[objp->instance].weapon_info_index].subtype == WP_LASER) {
vec3d in_vec;
float dist;
@@ -694,7 +699,7 @@ void ai_big_maybe_fire_weapons(float dist_to_enemy, float dot_to_enemy, vec3d *f
ship_weapon *tswp = &temp_shipp->weapons;
if ( tswp->num_primary_banks > 0 ) {
Assert(tswp->current_primary_bank < tswp->num_primary_banks);
Assertion(tswp->current_primary_bank < tswp->num_primary_banks, "AI tried to select primary bank %d. Might be a model error\n", tswp->current_primary_bank);
weapon_info *wip = &Weapon_info[tswp->primary_bank_weapons[tswp->current_primary_bank]];
if (dist_to_enemy < MIN((wip->max_speed * wip->lifetime), wip->weapon_range)){
@@ -821,15 +826,12 @@ void ai_big_chase()
ship_info *sip = &Ship_info[Ships[Pl_objp->instance].ship_info_index];
ship *shipp = &Ships[Pl_objp->instance];
ai_info *aip = &Ai_info[shipp->ai_index];
int enemy_ship_type;
vec3d predicted_enemy_pos;
Assert(aip->mode == AIM_CHASE);
maybe_cheat_fire_synaptic(Pl_objp, aip);
enemy_ship_type = Ship_info[Ships[En_objp->instance].ship_info_index].flags;
ai_set_positions(Pl_objp, En_objp, aip, &player_pos, &enemy_pos);
player_pos = Pl_objp->pos;
@@ -1161,12 +1163,13 @@ void ai_big_attack_get_data(vec3d *enemy_pos, float *dist_to_enemy, float *dot_t
float weapon_speed;
// Compute position of gun in absolute space and use that as fire position.
if (po->n_guns > 0) {
if (po->n_guns > 0 && !(The_mission.ai_profile->flags2 & AIPF2_AI_AIMS_FROM_SHIP_CENTER)) {
pnt = po->gun_banks[0].pnt[0];
vm_vec_unrotate(&gun_pos, &pnt, &Pl_objp->orient);
vm_vec_add2(&gun_pos, &Pl_objp->pos);
} else {
gun_pos = Pl_objp->pos;
//Use the convergence offset, if there is one
vm_vec_copy_scale(&pnt, &Ship_info[shipp->ship_info_index].convergence_offset, 1.0f);
}
weapon_speed = ai_get_weapon_speed(&shipp->weapons);
@@ -1245,7 +1248,6 @@ void ai_big_strafe_attack()
vec3d target_pos;
vec3d rand_vec;
float target_dist, target_dot, accel, t;
object *target_objp;
aip = &Ai_info[Ships[Pl_objp->instance].ai_index];
@@ -1257,11 +1259,8 @@ void ai_big_strafe_attack()
if ( ai_big_strafe_maybe_retreat(target_dist, &target_pos) )
return;
target_objp = &Objects[aip->target_objnum];
if (aip->ai_flags & AIF_KAMIKAZE) {
if (target_dist < 1200.0f) {
//nprintf(("AI", "Kamikaze: %7.3f %7.3f\n", target_dot, target_dist));
ai_turn_towards_vector(&target_pos, Pl_objp, flFrametime, Ship_info[Ships[Pl_objp->instance].ship_info_index].srotation_time, NULL, NULL, 0.0f, 0);
accelerate_ship(aip, 1.0f);
if ((target_dist < 400.0f) && ai_maybe_fire_afterburner(Pl_objp, aip)) {
@@ -1297,7 +1296,6 @@ void ai_big_strafe_attack()
aip->submode = AIS_STRAFE_AVOID;
aip->submode_start_time = Missiontime;
// nprintf(("Alan","Ship %s entering AIS_STRAFE_AVOID at frame %d\n", Ships[aip->shipnum].ship_name, Framecount));
if (ai_maybe_fire_afterburner(Pl_objp, aip)) {
afterburners_start(Pl_objp);
@@ -1431,7 +1429,7 @@ void ai_big_strafe_glide_attack()
if (aip->submode_parm1 == 1) {
accelerate_ship(aip, 1.0f);
//Use afterburners if we have them and are pointed the right way
if (dot_to_goal > 0.99f && ai_maybe_fire_afterburner(Pl_objp, aip)) {
if (dot_to_goal > 0.99f) {
afterburners_start(Pl_objp);
aip->afterburner_stop_time = Missiontime + 3*F1_0;
}
@@ -1640,6 +1638,20 @@ void ai_big_strafe()
Int3(); // Illegal submode for AIM_STRAFE
break;
}
//Maybe apply random sidethrust, depending on the current submode
//The following are valid targets for random sidethrust (circle strafe uses it too, but that is handled separately)
if (aip->submode == AIS_STRAFE_ATTACK ||
aip->submode == AIS_STRAFE_AVOID ||
aip->submode == AIS_STRAFE_RETREAT1 ||
aip->submode == AIS_STRAFE_RETREAT2 ||
aip->submode == AIS_STRAFE_POSITION)
{
//Re-roll for random sidethrust every 2 seconds
if (static_randf((Missiontime + static_rand(aip->shipnum)) >> 17) < aip->ai_random_sidethrust_percent) {
do_random_sidethrust(aip, &Ship_info[Ships[Objects[aip->target_objnum].instance].ship_info_index]);
}
}
}
// See if Pl_objp should enter strafe mode (This is called from maybe_evade_dumbfire_weapon(), and the
@@ -1753,7 +1765,7 @@ void ai_big_strafe_maybe_attack_turret(object *ship_objp, object *weapon_objp)
// Approx 1/4 chance we'll go after the other ship's beam.
bool attack_turret_on_different_ship = (aip->ai_profile_flags & AIPF_BIG_SHIPS_CAN_ATTACK_BEAM_TURRETS_ON_UNTARGETED_SHIPS)
&& (Weapon_info[weapon_objp->instance].wi_flags & WIF_BEAM) && (frand()*100 < 25.0f);
&& (Weapon_info[Weapons[weapon_objp->instance].weapon_info_index].wi_flags & WIF_BEAM) && (frand()*100 < 25.0f);
// unless we're making an exception, we should only attack a turret if it sits on the current target
if ( !attack_turret_on_different_ship )
+1570 -2131
View File
File diff suppressed because it is too large. Load diff
+140 -159
View File
@@ -131,18 +131,9 @@ char *Ai_goal_text(int goal)
}
// function to maybe add the form on my wing goal for a player's starting wing. Called when a player wing arrives.
// Goober5000 - made more generic
void ai_maybe_add_form_goal( wing *wingp )
{
int j;
char *wing_leader;
// if the wing leader isn't available (ie, dead/departed) then go ahead and bail now
if (wingp->ship_index[wingp->special_ship] < 0)
return;
// Goober5000 - the wing leader is now not necessarily the player
wing_leader = Ships[wingp->ship_index[wingp->special_ship]].ship_name;
// iterate through the ship_index list of this wing and check for orders. We will do
// this for all ships in the wing instead of on a wing only basis in case some ships
@@ -152,20 +143,15 @@ void ai_maybe_add_form_goal( wing *wingp )
Assert( wingp->ship_index[j] != -1 ); // get Allender
// don't process wing leader
if (j == wingp->special_ship)
continue;
aip = &Ai_info[Ships[wingp->ship_index[j]].ai_index];
// don't process Player_ship
if ( aip == Player_ai )
continue;
// it is sufficient enough to check the first goal entry to see if it has a valid goal
if ( aip->goals[0].ai_mode == AI_GOAL_NONE ) {
// need to add a form on my wing goal here
ai_add_ship_goal_player( AIG_TYPE_PLAYER_SHIP, AI_GOAL_FORM_ON_WING, -1, wing_leader, aip );
// need to add a form on my wing goal here. Ships are always forming on the player's wing.
ai_add_ship_goal_player( AIG_TYPE_PLAYER_SHIP, AI_GOAL_FORM_ON_WING, -1, Player_ship->ship_name, aip );
}
}
}
@@ -173,38 +159,28 @@ void ai_maybe_add_form_goal( wing *wingp )
void ai_post_process_mission()
{
object *objp;
/*
// Goober5000 - considering that this is also done in parse_wing_create_ships,
// it's redundant (and possibly premature for some wings) here
int i;
// Check ships in player starting wings. Those ships should follow these rules:
// (1) if they have no orders, they should get a form on my wing order
// (2) if they have an order, they are free to act on it.
//
// So basically, we are checking for (1)
if ( !Fred_running )
{
int i;
if ( !Fred_running ) {
// MK, 5/9/98: Used to iterate through MAX_STARTING_WINGS, but this was too many ships forming on player.
// Goober5000 - MK originally iterated on only the first wing; now we iterate on only the player wing
// because the player wing may not be first
for ( i = 0; i < MAX_STARTING_WINGS; i++ ) {
if ( Starting_wings[i] == Player_ship->wingnum ) {
wing *wingp;
// Goober5000 - make all wings form on their respective leaders
for ( i = 0; i < Num_wings; i++ )
{
ai_maybe_add_form_goal( &Wings[i] );
wingp = &Wings[Starting_wings[i]];
ai_maybe_add_form_goal( wingp );
}
}
// for ( i = 0; i < 1; i++ ) { // MK, 5/9/98: Used to iterate through MAX_STARTING_WINGS, but this was too many ships forming on player.
// if ( Starting_wings[i] != -1 ) {
// wing *wingp;
//
// wingp = &Wings[Starting_wings[i]];
//
// ai_maybe_add_form_goal( wingp );
//
// }
// }
}
*/
// for every valid ship object, call process_mission_orders to be sure that ships start the
// mission following the orders in the mission file right away instead of waiting N seconds
@@ -329,7 +305,7 @@ void ai_mission_wing_goal_complete( int wingnum, ai_goal *remove_goalp )
mode = remove_goalp->ai_mode;
submode = remove_goalp->ai_submode;
priority = remove_goalp->priority;
name = remove_goalp->ship_name;
name = remove_goalp->target_name;
Assert ( name ); // should not be NULL!!!!
@@ -345,10 +321,10 @@ void ai_mission_wing_goal_complete( int wingnum, ai_goal *remove_goalp )
aigp = &(aip->goals[j]);
// don't need to worry about these types of goals since they can't possibly be a goal we are looking for.
if ( (aigp->ai_mode == AI_GOAL_NONE) || !aigp->ship_name )
if ( (aigp->ai_mode == AI_GOAL_NONE) || !aigp->target_name )
continue;
if ( (aigp->ai_mode == mode) && (aigp->ai_submode == submode) && (aigp->priority == priority) && !stricmp(name, aigp->ship_name) ) {
if ( (aigp->ai_mode == mode) && (aigp->ai_submode == submode) && (aigp->priority == priority) && !stricmp(name, aigp->target_name) ) {
ai_remove_ship_goal( aip, j );
ai_do_default_behavior( &Objects[Ships[aip->shipnum].objnum] ); // do the default behavior
break; // we are all done
@@ -359,10 +335,10 @@ void ai_mission_wing_goal_complete( int wingnum, ai_goal *remove_goalp )
// now remove the goal from the wing
for (i = 0; i < MAX_AI_GOALS; i++ ) {
aigp = &(wingp->ai_goals[i]);
if ( (aigp->ai_mode == AI_GOAL_NONE) || !aigp->ship_name )
if ( (aigp->ai_mode == AI_GOAL_NONE) || !aigp->target_name )
continue;
if ( (aigp->ai_mode == mode) && (aigp->ai_submode == submode) && (aigp->priority == priority) && !stricmp(name, aigp->ship_name) ) {
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;
@@ -401,7 +377,7 @@ void ai_goal_purge_invalid_goals( ai_goal *aigp, ai_goal *goal_list, ai_info *ai
int mode, ship_index, wingnum;
// get locals for easer access
name = aigp->ship_name;
name = aigp->target_name;
mode = aigp->ai_mode;
// these goals cannot be associated to wings, but can to a ship in a wing. So, we should find out
@@ -424,17 +400,17 @@ void ai_goal_purge_invalid_goals( ai_goal *aigp, ai_goal *goal_list, ai_info *ai
continue;
// goals must operate on something to be purged.
if ( purge_goal->ship_name == NULL )
if ( purge_goal->target_name == NULL )
continue;
// determine if the purge goal is acting either on the ship or the ship's wing.
purge_wing = wing_name_lookup( purge_goal->ship_name, 1 );
purge_wing = wing_name_lookup( purge_goal->target_name, 1 );
// if the target of the purge goal is a ship (purge_wing will be -1), then if the names
// don't match, we can continue; if the wing is valid, don't process if the wing numbers
// are different.
if ( purge_wing == -1 ) {
if ( stricmp(purge_goal->ship_name, name ) )
if ( stricmp(purge_goal->target_name, name ) )
continue;
} else if ( purge_wing != wingnum )
continue;
@@ -560,7 +536,7 @@ void ai_goal_fixup_dockpoints(ai_info *aip, ai_goal *aigp)
int shipnum, docker_index, dockee_index;
Assert ( aip->shipnum != -1 );
shipnum = ship_name_lookup( aigp->ship_name );
shipnum = ship_name_lookup( aigp->target_name );
docker_index = -1;
dockee_index = -1;
@@ -626,27 +602,36 @@ 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 *shipname, ai_goal *aigp )
void ai_add_goal_sub_player(int type, int mode, int submode, char *target_name, ai_goal *aigp )
{
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->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_index = submode;
if ( mode == AI_GOAL_CHASE_WEAPON ) {
aigp->wp_index = submode; // submode contains the instance of the weapon
aigp->weapon_signature = Objects[Weapons[submode].objnum].signature;
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 ( shipname != NULL )
aigp->ship_name = ai_get_goal_ship_name( shipname, &aigp->ship_name_index );
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->ship_name = NULL;
aigp->target_name = NULL;
// special case certain orders from player so that ships continue to do the right thing
@@ -711,7 +696,7 @@ int ai_goal_num(ai_goal *goals)
}
void ai_add_goal_sub_scripting(int type, int mode, int submode, int priority, char *shipname, ai_goal *aigp )
void ai_add_goal_sub_scripting(int type, int mode, int submode, int priority, char *target_name, ai_goal *aigp )
{
Assert ( (type == AIG_TYPE_PLAYER_WING) || (type == AIG_TYPE_PLAYER_SHIP) );
@@ -721,17 +706,17 @@ void ai_add_goal_sub_scripting(int type, int mode, int submode, int priority, ch
aigp->ai_submode = submode; // could mean different things depending on mode
if ( mode == AI_GOAL_WARP )
aigp->wp_index = submode;
aigp->wp_list = NULL;
if ( mode == AI_GOAL_CHASE_WEAPON ) {
aigp->wp_index = submode; // submode contains the instance of the weapon
aigp->weapon_signature = Objects[Weapons[submode].objnum].signature;
aigp->target_instance = submode; // submode contains the instance of the weapon
aigp->target_signature = Objects[Weapons[submode].objnum].signature;
}
if ( shipname != NULL )
aigp->ship_name = ai_get_goal_ship_name( shipname, &aigp->ship_name_index );
if ( target_name != NULL )
aigp->target_name = ai_get_goal_target_name( target_name, &aigp->target_name_index );
else
aigp->ship_name = NULL;
aigp->target_name = NULL;
aigp->priority = priority;
}
@@ -824,7 +809,7 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name )
aigp->signature = Ai_goal_signature++;
aigp->ship_name = NULL;
aigp->target_name = NULL;
aigp->time = Missiontime;
aigp->type = type;
aigp->flags = 0;
@@ -839,10 +824,10 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name )
ref_type = Sexp_nodes[CDR(node)].subtype;
if (ref_type == SEXP_ATOM_STRING) { // referenced by name
// save the waypoint path name -- the index will get resolved when the goal is checked
// for acheivability.
aigp->ship_name = ai_get_goal_ship_name(CTEXT(CDR(node)), &aigp->ship_name_index); // waypoint path name;
aigp->wp_index = -1;
// 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();
@@ -856,24 +841,24 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name )
case OP_AI_DESTROY_SUBSYS:
aigp->ai_mode = AI_GOAL_DESTROY_SUBSYSTEM;
aigp->ship_name = ai_get_goal_ship_name( CTEXT(CDR(node)), &aigp->ship_name_index );
aigp->target_name = ai_get_goal_target_name( CTEXT(CDR(node)), &aigp->target_name_index );
// store the name of the subsystem in the docker.name field for now -- this field must get
// fixed up when the goal is valid since we need to locate the subsystem on the ship's model
aigp->docker.name = ai_get_goal_ship_name(CTEXT(CDR(CDR(node))), &dummy);
aigp->docker.name = ai_get_goal_target_name(CTEXT(CDR(CDR(node))), &dummy);
aigp->flags |= AIGF_SUBSYS_NEEDS_FIXUP;
aigp->priority = atoi( CTEXT(CDR(CDR(CDR(node)))) );
break;
case OP_AI_DISABLE_SHIP:
aigp->ai_mode = AI_GOAL_DISABLE_SHIP;
aigp->ship_name = ai_get_goal_ship_name( CTEXT(CDR(node)), &aigp->ship_name_index );
aigp->target_name = ai_get_goal_target_name( CTEXT(CDR(node)), &aigp->target_name_index );
aigp->ai_submode = -SUBSYSTEM_ENGINE;
aigp->priority = atoi( CTEXT(CDR(CDR(node))) );
break;
case OP_AI_DISARM_SHIP:
aigp->ai_mode = AI_GOAL_DISARM_SHIP;
aigp->ship_name = ai_get_goal_ship_name( CTEXT(CDR(node)), &aigp->ship_name_index );
aigp->target_name = ai_get_goal_target_name( CTEXT(CDR(node)), &aigp->target_name_index );
aigp->ai_submode = -SUBSYSTEM_TURRET;
aigp->priority = atoi( CTEXT(CDR(CDR(node))) );
break;
@@ -886,9 +871,8 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name )
// the following goal is obsolete, but here for compatibility
case OP_AI_WARP:
aigp->ai_mode = AI_GOAL_WARP;
aigp->ship_name = ai_get_goal_ship_name(CTEXT(CDR(node)), &aigp->ship_name_index); // waypoint path name;
//aigp->wp_index = atoi( CTEXT(CDR(node)) ); // this is the index into the warp points
aigp->wp_index = -1;
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;
@@ -897,9 +881,9 @@ 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->ship_name = ai_get_goal_ship_name( CTEXT(CDR(CDR(node))), &aigp->ship_name_index );
aigp->target_name = ai_get_goal_target_name( CTEXT(CDR(CDR(node))), &aigp->target_name_index );
else
aigp->ship_name = NULL;
aigp->target_name = NULL;
aigp->ai_mode = AI_GOAL_UNDOCK;
aigp->ai_submode = AIS_UNDOCK_0;
@@ -907,12 +891,12 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name )
case OP_AI_STAY_STILL:
aigp->ai_mode = AI_GOAL_STAY_STILL;
aigp->ship_name = ai_get_goal_ship_name(CTEXT(CDR(node)), &aigp->ship_name_index); // waypoint path name;
aigp->target_name = ai_get_goal_target_name(CTEXT(CDR(node)), &aigp->target_name_index); // waypoint path name;
aigp->priority = atoi( CTEXT(CDR(CDR(node))) );
break;
case OP_AI_DOCK:
aigp->ship_name = ai_get_goal_ship_name( CTEXT(CDR(node)), &aigp->ship_name_index );
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 &= ~AIGF_DOCK_INDEXES_VALID;
@@ -937,6 +921,12 @@ 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_FORM_ON_WING:
aigp->priority = 99;
aigp->target_name = ai_get_goal_target_name(CTEXT(CDR(node)), &aigp->target_name_index);
aigp->ai_mode = AI_GOAL_FORM_ON_WING;
break;
case OP_AI_CHASE:
case OP_AI_GUARD:
case OP_AI_GUARD_WING:
@@ -945,7 +935,7 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name )
case OP_AI_STAY_NEAR_SHIP:
case OP_AI_IGNORE:
case OP_AI_IGNORE_NEW:
aigp->ship_name = ai_get_goal_ship_name( CTEXT(CDR(node)), &aigp->ship_name_index );
aigp->target_name = ai_get_goal_target_name( CTEXT(CDR(node)), &aigp->target_name_index );
aigp->priority = atoi( CTEXT(CDR(CDR(node))) );
if ( op == OP_AI_CHASE ) {
@@ -954,12 +944,12 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name )
// in the case of ai_chase (and ai_guard) we must do a wing_name_lookup on the name
// passed here to see if we could be chasing a wing. Hoffoss and I have consolidated
// sexpression operators which makes this step necessary
if ( wing_name_lookup(aigp->ship_name, 1) != -1 )
if ( wing_name_lookup(aigp->target_name, 1) != -1 )
aigp->ai_mode = AI_GOAL_CHASE_WING;
} else if ( op == OP_AI_GUARD ) {
aigp->ai_mode = AI_GOAL_GUARD;
if ( wing_name_lookup(aigp->ship_name, 1) != -1 )
if ( wing_name_lookup(aigp->target_name, 1) != -1 )
aigp->ai_mode = AI_GOAL_GUARD_WING;
} else if ( op == OP_AI_EVADE_SHIP ) {
@@ -991,7 +981,7 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name )
// Goober5000 - since none of the goals act on the actor,
// don't assign the goal if the actor's goal target is itself
if (aigp->ship_name != NULL && !strcmp(aigp->ship_name, actor_name))
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"
@@ -1008,7 +998,7 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name )
* Pass -1 in priority to ignore priority when searching
* Returns -1 if not found, or [0, MAX_AI_GOALS)
*/
int ai_find_goal_index( ai_goal* aigp, int mode, int submode = -1, int priority = -1 )
int ai_find_goal_index( ai_goal* aigp, int mode, int submode, int priority )
{
Assert( aigp != NULL );
for ( int i = 0; i < MAX_AI_GOALS; i++ )
@@ -1275,7 +1265,7 @@ void ai_add_goal_ship_internal( ai_info *aip, int goal_type, char *name, int doc
*/
case AI_GOAL_UNDOCK:
aigp->ship_name = name;
aigp->target_name = name;
aigp->priority = MAX_GOAL_PRIORITY;
aigp->ai_mode = AI_GOAL_UNDOCK;
aigp->ai_submode = AIS_UNDOCK_0;
@@ -1294,7 +1284,7 @@ void ai_add_goal_ship_internal( ai_info *aip, int goal_type, char *name, int doc
case AI_GOAL_REARM_REPAIR:
aigp->ai_mode = AI_GOAL_REARM_REPAIR;
aigp->ai_submode = 0;
aigp->ship_name = name;
aigp->target_name = name;
aigp->priority = PLAYER_PRIORITY_MIN-1; // make the priority always less than what the player's is
aigp->flags &= ~AIGF_GOAL_OVERRIDE; // don't override this goal. rearm repair requests should happen in order
ai_goal_fixup_dockpoints( aip, aigp );
@@ -1359,7 +1349,6 @@ void ai_copy_mission_wing_goal( ai_goal *aigp, ai_info *aip )
int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
{
int status;
char *ai_shipname;
int return_val;
object *objp;
ai_info *aip;
@@ -1368,7 +1357,6 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
objp = &Objects[objnum];
Assert( objp->instance != -1 );
ai_shipname = Ships[objp->instance].ship_name;
aip = &Ai_info[Ships[objp->instance].ai_index];
// these orders are always achievable.
@@ -1400,7 +1388,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
// if the wing target is valid then be sure to set the override bit so that it always
// gets executed next
if ( aigp->ai_mode == AI_GOAL_FORM_ON_WING ) {
sindex = ship_name_lookup( aigp->ship_name );
sindex = ship_name_lookup( aigp->target_name );
if (sindex < 0)
return AI_GOAL_NOT_ACHIEVABLE;
@@ -1409,20 +1397,14 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
return AI_GOAL_ACHIEVABLE;
}
// check to see if we have a valid index. If not, then try to set one up. If that
// check to see if we have a valid list. If not, then try to set one up. If that
// fails, then we must pitch this order
if ( (aigp->ai_mode == AI_GOAL_WAYPOINTS_ONCE) || (aigp->ai_mode == AI_GOAL_WAYPOINTS) ) {
if ( aigp->wp_index == -1 ) {
int i;
if ( aigp->wp_list == NULL ) {
aigp->wp_list = find_matching_waypoint_list(aigp->target_name);
for (i = 0; i < Num_waypoint_lists; i++) {
if (!stricmp(aigp->ship_name, Waypoint_lists[i].name)) {
aigp->wp_index = i;
break;
}
}
if ( i == Num_waypoint_lists ) {
Warning(LOCATION, "Unknown waypoint %s. not found in mission file. Killing ai goal", aigp->ship_name );
if ( aigp->wp_list == NULL ) {
Warning(LOCATION, "Unknown waypoint list %s - not found in mission file. Killing ai goal", aigp->target_name );
return AI_GOAL_NOT_ACHIEVABLE;
}
}
@@ -1437,8 +1419,6 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
{
case AI_GOAL_DOCK:
case AI_GOAL_UNDOCK:
//status = mission_log_get_time( LOG_SHIP_DOCK, ai_shipname, aigp->ship_name, NULL );
//status = mission_log_get_time( LOG_SHIP_UNDOCK, ai_shipname, aigp->ship_name, NULL );
//MWA 3/20/97 -- cannot short circuit a dock or undock goal already succeeded -- we must
// rely on the goal removal code to just remove this goal. This is because docking/undock
// can happen > 1 time per mission per pair of ships. The above checks will find only
@@ -1452,7 +1432,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
// shipnum could be -1 depending on if the ship hasn't arrived or died. only look for subsystem
// destroyed when shipnum is valid
sindex = ship_name_lookup( aigp->ship_name );
sindex = ship_name_lookup( aigp->target_name );
// can't determine the status of this goal if ship not valid
// or we haven't found a valid subsystem index yet
@@ -1466,17 +1446,22 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
// for this goal to be valid).
Assert ( aigp->ai_submode >= 0 );
ssp = ship_get_indexed_subsys( &Ships[sindex], aigp->ai_submode );
status = mission_log_get_time( LOG_SHIP_SUBSYS_DESTROYED, aigp->ship_name, ssp->system_info->subobj_name, NULL );
if (ssp != NULL) {
status = mission_log_get_time( LOG_SHIP_SUBSYS_DESTROYED, aigp->target_name, ssp->system_info->subobj_name, NULL );
} else {
// not supposed to ever happen, but could if there is a mismatch between the table and model subsystems
nprintf(("AI", "Couldn't find subsystem %d for ship %s\n", aigp->ai_submode, Ships[sindex].ship_name));
status = 0;
}
break;
}
case AI_GOAL_DISABLE_SHIP:
status = mission_log_get_time( LOG_SHIP_DISABLED, aigp->ship_name, NULL, NULL );
status = mission_log_get_time( LOG_SHIP_DISABLED, aigp->target_name, NULL, NULL );
break;
case AI_GOAL_DISARM_SHIP:
status = mission_log_get_time( LOG_SHIP_DISARMED, aigp->ship_name, NULL, NULL );
status = mission_log_get_time( LOG_SHIP_DISARMED, aigp->target_name, NULL, NULL );
break;
// to guard or ignore a ship, the goal cannot continue if the ship being guarded is either destroyed
@@ -1493,11 +1478,11 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
// MWA -- 4/22/98. Check for the ship actually being in the mission before
// checking departure and destroyed. In multiplayer, since ships can respawn,
// they get log entries for being destroyed even though they have respawned.
sindex = ship_name_lookup( aigp->ship_name );
sindex = ship_name_lookup( aigp->target_name );
if ( sindex == -1 ) {
status = mission_log_get_time( LOG_SHIP_DEPARTED, aigp->ship_name, NULL, NULL);
status = mission_log_get_time( LOG_SHIP_DEPARTED, aigp->target_name, NULL, NULL);
if ( !status ) {
status = mission_log_get_time( LOG_SHIP_DESTROYED, aigp->ship_name, NULL, NULL);
status = mission_log_get_time( LOG_SHIP_DESTROYED, aigp->target_name, NULL, NULL);
if ( status )
return_val = AI_GOAL_NOT_ACHIEVABLE;
}
@@ -1511,9 +1496,9 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
case AI_GOAL_CHASE_WING:
case AI_GOAL_GUARD_WING:
{
status = mission_log_get_time( LOG_WING_DEPARTED, aigp->ship_name, NULL, NULL );
status = mission_log_get_time( LOG_WING_DEPARTED, aigp->target_name, NULL, NULL );
if ( !status ) {
status = mission_log_get_time( LOG_WING_DESTROYED, aigp->ship_name, NULL, NULL);
status = mission_log_get_time( LOG_WING_DESTROYED, aigp->target_name, NULL, NULL);
if ( status )
return_val = AI_GOAL_NOT_ACHIEVABLE;
}
@@ -1526,13 +1511,13 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
{
// for chase weapon, we simply need to look at the weapon instance that we are trying to
// attack and see if the object still exists, and has the same signature that we expect.
Assert( aigp->wp_index >= 0 );
Assert( aigp->target_instance >= 0 );
if ( Weapons[aigp->wp_index].objnum == -1 )
if ( Weapons[aigp->target_instance].objnum == -1 )
return AI_GOAL_NOT_ACHIEVABLE;
// if the signatures don't match, then goal isn't achievable.
if ( Objects[Weapons[aigp->wp_index].objnum].signature != aigp->weapon_signature )
if ( Objects[Weapons[aigp->target_instance].objnum].signature != aigp->target_signature )
return AI_GOAL_NOT_ACHIEVABLE;
// otherwise, we should be good to go
@@ -1557,7 +1542,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
// the if statement.
if ( (aigp->ai_mode == AI_GOAL_CHASE_WING) || (aigp->ai_mode == AI_GOAL_GUARD_WING) )
{
sindex = wing_name_lookup( aigp->ship_name );
sindex = wing_name_lookup( aigp->target_name );
if (sindex < 0)
return AI_GOAL_NOT_KNOWN;
@@ -1573,24 +1558,24 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
}
// Goober5000 - undocking from an unspecified object is always achievable;
// undocking from a specified object is handled below
else if ( (aigp->ai_mode == AI_GOAL_UNDOCK) && (aigp->ship_name == NULL) )
else if ( (aigp->ai_mode == AI_GOAL_UNDOCK) && (aigp->target_name == NULL) )
{
return AI_GOAL_ACHIEVABLE;
}
else
{
// goal ship is currently in mission
if ( ship_name_lookup( aigp->ship_name ) != -1 )
if ( ship_name_lookup( aigp->target_name ) != -1 )
{
status = SHIP_STATUS_ARRIVED;
}
// goal ship is still on the arrival list
else if ( mission_parse_get_arrival_ship(aigp->ship_name) )
else if ( mission_parse_get_arrival_ship(aigp->target_name) )
{
status = SHIP_STATUS_NOT_ARRIVED;
}
// goal ship has left the area
else if ( ship_find_exited_ship_by_name(aigp->ship_name) != -1 )
else if ( ship_find_exited_ship_by_name(aigp->target_name) != -1 )
{
status = SHIP_STATUS_GONE;
}
@@ -1605,7 +1590,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
if ((status == SHIP_STATUS_ARRIVED) && (aigp->ai_mode == AI_GOAL_DISARM_SHIP))
{
// if the ship has no turrets, we can't disarm it!
if (Ships[ship_name_lookup(aigp->ship_name)].subsys_info[SUBSYSTEM_TURRET].num == 0)
if (Ships[ship_name_lookup(aigp->target_name)].subsys_info[SUBSYSTEM_TURRET].type_count == 0)
return AI_GOAL_NOT_ACHIEVABLE;
}
@@ -1636,7 +1621,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
}
if (!(aigp->flags & AIGF_DOCKEE_INDEX_VALID)) {
sindex = ship_name_lookup(aigp->ship_name);
sindex = ship_name_lookup(aigp->target_name);
if ( sindex != -1 ) {
modelnum = Ship_info[Ships[sindex].ship_info_index].model_num;
index = model_find_dock_name_index(modelnum, aigp->dockee.name);
@@ -1656,7 +1641,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
return AI_GOAL_NOT_KNOWN;
// we must also determine if we're prevented from docking for any reason
sindex = ship_name_lookup(aigp->ship_name);
sindex = ship_name_lookup(aigp->target_name);
Assert( sindex >= 0 );
object *goal_objp = &Objects[Ships[sindex].objnum];
@@ -1708,7 +1693,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
if ((aip->mode == AIM_DOCK) && (aip->submode >= AIS_UNDOCK_0))
{
// only put it on hold if it's someone other than the guy we're undocking from right now!!
if (aip->goal_objnum != Ships[ship_name_lookup(aigp->ship_name)].objnum)
if (aip->goal_objnum != Ships[ship_name_lookup(aigp->target_name)].objnum)
return AI_GOAL_NOT_KNOWN;
}
@@ -1717,7 +1702,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
// have fixed up the subsystem name (of the subsystem to destroy) into an index into
// the ship's subsystem list
if ( aigp->flags & AIGF_SUBSYS_NEEDS_FIXUP ) {
sindex = ship_name_lookup( aigp->ship_name );
sindex = ship_name_lookup( aigp->target_name );
if ( sindex != -1 ) {
aigp->ai_submode = ship_get_subsys_index( &Ships[sindex], aigp->docker.name );
@@ -1731,7 +1716,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
object *ignored;
// for ignoring a ship, call the ai_ignore object function, then declare the goal satisfied
sindex = ship_name_lookup( aigp->ship_name );
sindex = ship_name_lookup( aigp->target_name );
Assert( sindex != -1 ); // should be true because of above status
ignored = &Objects[Ships[sindex].objnum];
@@ -1785,7 +1770,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
if ( status == SHIP_STATUS_GONE )
return AI_GOAL_NOT_ACHIEVABLE;
sindex = ship_name_lookup( aigp->ship_name );
sindex = ship_name_lookup( aigp->target_name );
if ( sindex < 0 ) {
Int3();
@@ -1811,7 +1796,6 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
// test code!!!
if ( aip->goal_objnum == -1 ) {
// -- MK, 11/9/97 -- I was always hitting this: Int3();
return AI_GOAL_ACHIEVABLE;
}
@@ -2045,8 +2029,8 @@ void ai_process_mission_orders( int objnum, ai_info *aip )
switch ( current_goal->ai_mode ) {
case AI_GOAL_CHASE:
if ( current_goal->ship_name ) {
shipnum = ship_name_lookup( current_goal->ship_name );
if ( current_goal->target_name ) {
shipnum = ship_name_lookup( current_goal->target_name );
Assert (shipnum != -1 ); // shouldn't get here if this is false!!!!
other_obj = &Objects[Ships[shipnum].objnum];
} else
@@ -2058,13 +2042,14 @@ void ai_process_mission_orders( int objnum, ai_info *aip )
break;
case AI_GOAL_CHASE_WEAPON:
Assert( Weapons[current_goal->wp_index].objnum != -1 );
other_obj = &Objects[Weapons[current_goal->wp_index].objnum];
Assert( Weapons[current_goal->target_instance].objnum >= 0 );
other_obj = &Objects[Weapons[current_goal->target_instance].objnum];
Assert( other_obj->signature == current_goal->target_signature );
ai_attack_object( objp, other_obj, NULL );
break;
case AI_GOAL_GUARD:
shipnum = ship_name_lookup( current_goal->ship_name );
shipnum = ship_name_lookup( current_goal->target_name );
Assert (shipnum != -1 ); // shouldn't get here if this is false!!!!
other_obj = &Objects[Ships[shipnum].objnum];
// shipnum and other_obj are the shipnumber and object pointer of the object that you should
@@ -2079,7 +2064,7 @@ void ai_process_mission_orders( int objnum, ai_info *aip )
break;
case AI_GOAL_GUARD_WING:
wingnum = wing_name_lookup( current_goal->ship_name );
wingnum = wing_name_lookup( current_goal->target_name );
Assert (wingnum != -1 ); // shouldn't get here if this is false!!!!
ai_set_guard_wing(objp, wingnum);
aip->submode_start_time = Missiontime;
@@ -2091,18 +2076,18 @@ void ai_process_mission_orders( int objnum, ai_info *aip )
if ( current_goal->ai_mode == AI_GOAL_WAYPOINTS)
flags |= WPF_REPEAT;
ai_start_waypoints(objp, current_goal->wp_index, flags);
ai_start_waypoints(objp, current_goal->wp_list, flags);
break;
}
case AI_GOAL_FLY_TO_SHIP:
shipnum = ship_name_lookup( current_goal->ship_name );
shipnum = ship_name_lookup( current_goal->target_name );
Assert (shipnum != -1 ); // shouldn't get here if this is false!!!!
ai_start_fly_to_ship(objp, shipnum);
break;
case AI_GOAL_DOCK: {
shipnum = ship_name_lookup( current_goal->ship_name );
shipnum = ship_name_lookup( current_goal->target_name );
Assert (shipnum != -1 ); // shouldn't get here if this is false!!!!
other_obj = &Objects[Ships[shipnum].objnum];
@@ -2119,9 +2104,9 @@ void ai_process_mission_orders( int objnum, ai_info *aip )
// goal cannot continue. Spit out a warning and remove the goal.
// Goober5000 - do we have a specific ship to undock from?
if ( current_goal->ship_name != NULL )
if ( current_goal->target_name != NULL )
{
shipnum = ship_name_lookup( current_goal->ship_name );
shipnum = ship_name_lookup( current_goal->target_name );
// hmm, perhaps he was destroyed
if (shipnum == -1)
@@ -2144,7 +2129,7 @@ void ai_process_mission_orders( int objnum, ai_info *aip )
other_obj = dock_get_first_docked_object( objp );
// and add the ship name so it displays on the HUD
current_goal->ship_name = Ships[other_obj->instance].ship_name;
current_goal->target_name = Ships[other_obj->instance].ship_name;
}
// hmm, nobody exists that we can undock from
else
@@ -2154,7 +2139,6 @@ void ai_process_mission_orders( int objnum, ai_info *aip )
}
if ( other_obj == NULL ) {
//Int3();
// assume that the guy he was docked with doesn't exist anymore. (i.e. a cargo containuer
// can get destroyed while docked with a freighter.) We should just remove this goal and
// let this ship pick up it's next goal.
@@ -2183,7 +2167,7 @@ void ai_process_mission_orders( int objnum, ai_info *aip )
case AI_GOAL_DESTROY_SUBSYSTEM:
case AI_GOAL_DISABLE_SHIP:
case AI_GOAL_DISARM_SHIP: {
shipnum = ship_name_lookup( current_goal->ship_name );
shipnum = ship_name_lookup( current_goal->target_name );
Assert( shipnum >= 0 );
other_obj = &Objects[Ships[shipnum].objnum];
ai_attack_object( objp, other_obj, NULL);
@@ -2202,7 +2186,7 @@ void ai_process_mission_orders( int objnum, ai_info *aip )
}
case AI_GOAL_CHASE_WING:
wingnum = wing_name_lookup( current_goal->ship_name );
wingnum = wing_name_lookup( current_goal->target_name );
Assert( wingnum >= 0 );
ai_attack_wing(objp, wingnum);
break;
@@ -2212,15 +2196,12 @@ void ai_process_mission_orders( int objnum, ai_info *aip )
break;
case AI_GOAL_WARP: {
int index;
index = current_goal->wp_index;
mission_do_departure( objp );
break;
}
case AI_GOAL_EVADE_SHIP:
shipnum = ship_name_lookup( current_goal->ship_name );
shipnum = ship_name_lookup( current_goal->target_name );
Assert( shipnum >= 0 );
other_obj = &Objects[Ships[shipnum].objnum];
ai_evade_object( objp, other_obj);
@@ -2249,7 +2230,7 @@ void ai_process_mission_orders( int objnum, ai_info *aip )
// 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->ship_name );
shipnum = ship_name_lookup( current_goal->target_name );
Assert( shipnum >= 0 );
other_obj = &Objects[Ships[shipnum].objnum];
ai_form_on_wing( objp, other_obj );
@@ -2258,7 +2239,7 @@ void ai_process_mission_orders( int objnum, ai_info *aip )
// labels for support ship commands
case AI_GOAL_STAY_NEAR_SHIP: {
shipnum = ship_name_lookup( current_goal->ship_name );
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!!!
@@ -2275,7 +2256,7 @@ void ai_process_mission_orders( int objnum, ai_info *aip )
break;
case AI_GOAL_REARM_REPAIR:
shipnum = ship_name_lookup( current_goal->ship_name );
shipnum = ship_name_lookup( current_goal->target_name );
Assert( shipnum >= 0 );
other_obj = &Objects[Ships[shipnum].objnum];
ai_rearm_repair( objp, current_goal->docker.index, other_obj, current_goal->dockee.index );
@@ -2346,11 +2327,11 @@ void ai_update_goal_references(ai_goal *goals, int type, char *old_name, char *n
}
if (flag) // is this a valid goal to parse for this conversion?
if (!stricmp(goals[i].ship_name, old_name)) {
if (!stricmp(goals[i].target_name, old_name)) {
if (*new_name == '<') // target was just deleted..
goals[i].ai_mode = AI_GOAL_NONE;
else
goals[i].ship_name = ai_get_goal_ship_name(new_name, &dummy);
goals[i].target_name = ai_get_goal_target_name(new_name, &dummy);
}
}
}
@@ -2412,7 +2393,7 @@ int query_referenced_in_ai_goals(ai_goal *goals, int type, char *name)
if (flag) // is this a valid goal to parse for this conversion?
{
if (!stricmp(goals[i].ship_name, name))
if (!stricmp(goals[i].target_name, name))
return 1;
}
}
@@ -2425,7 +2406,7 @@ char *ai_add_dock_name(char *str)
char *ptr;
int i;
Assert(strlen(str) < NAME_LENGTH - 1);
Assert(strlen(str) <= NAME_LENGTH - 1);
for (i=0; i<Num_ai_dock_names; i++)
if (!stricmp(Ai_dock_names[i], str))
return Ai_dock_names[i];
+24 -24
View File
@@ -26,35 +26,35 @@ struct ai_goal;
// Fred. If the goal you add doesn't have a target (such as chase_any), then you don't have
// to worry about doing this. Also add it to list in Fred\Management.cpp, and let Hoffoss know!
// WMC - Oh and add them to Ai_goal_names plz. TY! :)
#define AI_GOAL_CHASE (1<<1)
#define AI_GOAL_DOCK (1<<2) // used for undocking as well
#define AI_GOAL_WAYPOINTS (1<<3)
#define AI_GOAL_WAYPOINTS_ONCE (1<<4)
#define AI_GOAL_WARP (1<<5)
#define AI_GOAL_DESTROY_SUBSYSTEM (1<<6)
#define AI_GOAL_FORM_ON_WING (1<<7)
#define AI_GOAL_UNDOCK (1<<8)
#define AI_GOAL_CHASE_WING (1<<9)
#define AI_GOAL_GUARD (1<<10)
#define AI_GOAL_DISABLE_SHIP (1<<11)
#define AI_GOAL_DISARM_SHIP (1<<12)
#define AI_GOAL_CHASE_ANY (1<<13)
#define AI_GOAL_IGNORE (1<<14)
#define AI_GOAL_GUARD_WING (1<<15)
#define AI_GOAL_EVADE_SHIP (1<<16)
#define AI_GOAL_CHASE (1<<1) // 0x00000002
#define AI_GOAL_DOCK (1<<2) // 0x00000004 // used for undocking as well
#define AI_GOAL_WAYPOINTS (1<<3) // 0x00000008
#define AI_GOAL_WAYPOINTS_ONCE (1<<4) // 0x00000010
#define AI_GOAL_WARP (1<<5) // 0x00000020
#define AI_GOAL_DESTROY_SUBSYSTEM (1<<6) // 0x00000040
#define AI_GOAL_FORM_ON_WING (1<<7) // 0x00000080
#define AI_GOAL_UNDOCK (1<<8) // 0x00000100
#define AI_GOAL_CHASE_WING (1<<9) // 0x00000200
#define AI_GOAL_GUARD (1<<10) // 0x00000400
#define AI_GOAL_DISABLE_SHIP (1<<11) // 0x00000800
#define AI_GOAL_DISARM_SHIP (1<<12) // 0x00001000
#define AI_GOAL_CHASE_ANY (1<<13) // 0x00002000
#define AI_GOAL_IGNORE (1<<14) // 0x00004000
#define AI_GOAL_GUARD_WING (1<<15) // 0x00008000
#define AI_GOAL_EVADE_SHIP (1<<16) // 0x00010000
// the next goals are for support ships only
#define AI_GOAL_STAY_NEAR_SHIP (1<<17)
#define AI_GOAL_KEEP_SAFE_DISTANCE (1<<18)
#define AI_GOAL_REARM_REPAIR (1<<19)
#define AI_GOAL_STAY_NEAR_SHIP (1<<17) // 0x00020000
#define AI_GOAL_KEEP_SAFE_DISTANCE (1<<18) // 0x00040000
#define AI_GOAL_REARM_REPAIR (1<<19) // 0x00080000
// resume regular goals
#define AI_GOAL_STAY_STILL (1<<20)
#define AI_GOAL_PLAY_DEAD (1<<21)
#define AI_GOAL_CHASE_WEAPON (1<<22)
#define AI_GOAL_STAY_STILL (1<<20) // 0x00100000
#define AI_GOAL_PLAY_DEAD (1<<21) // 0x00200000
#define AI_GOAL_CHASE_WEAPON (1<<22) // 0x00400000
#define AI_GOAL_FLY_TO_SHIP (1<<23) // kazan
#define AI_GOAL_IGNORE_NEW (1<<24) // Goober5000
#define AI_GOAL_FLY_TO_SHIP (1<<23) // 0x00800000
#define AI_GOAL_IGNORE_NEW (1<<24) // 0x01000000
// now the masks for ship types
+384 -63
View File
@@ -52,15 +52,21 @@ char *Turret_target_order_names[NUM_TURRET_ORDER_TYPES] = {
"Asteroids",
};
#define EEOF_BIG_ONLY (1<<0) // turret fires only at big and huge ships
#define EEOF_SMALL_ONLY (1<<1) // turret fires only at small ships
#define EEOF_TAGGED_ONLY (1<<2) // turret fires only at tagged ships
#define EEOF_BEAM (1<<3) // turret is a beam
#define EEOF_FLAK (1<<4) // turret is flak
#define EEOF_LASER (1<<5) // turret is a laser
#define EEOF_MISSILE (1<<6) // turret is a missile
typedef struct eval_enemy_obj_struct {
int turret_parent_objnum; // parent of turret
float weapon_travel_dist; // max targeting range of turret weapon
int enemy_team_mask;
int weapon_system_ok; // is the weapon subsystem of turret ship ok
bool big_only_flag; // turret fires only at big and huge ships
bool small_only_flag; // turret fires only at small ships
bool tagged_only_flag; // turret fires only at tagged ships
bool beam_flag; // turret is a beam
int eeo_flags;
vec3d *tpos;
vec3d *tvec;
ship_subsys *turret_subsys;
@@ -100,6 +106,101 @@ int object_in_turret_fov(object *objp, ship_subsys *ss, vec3d *tvec, vec3d *tpos
return 0;
}
bool is_object_radius_in_turret_fov(object *objp, ship_subsys *ss, vec3d *tvec, vec3d *tpos, vec3d *v2e, vec3d *predicted_pos, float distance)
{
float target_dist = distance;
if (distance == 0.0f)
target_dist = vm_vec_dist(predicted_pos,tpos);
if (object_in_turret_fov(objp, ss, tvec, tpos, target_dist + objp->radius)) {
// so the targeted spot in not in fov but the enemy + radius is
// lets align the darn gun and try shooting there
vec3d temp_vec;
float multiplier = 0;
model_subsystem *tp = ss->system_info;
// project v2e_from_turret to turret normal
// substract resultant vector from the temp_vec (v2e_from_turret)
// adjust z component as necessary
// calculate multiplier for the resultant vector
// use multiplier and the z component and compose a new vector
float dot = vm_vec_dot(v2e, tvec);
vm_vec_scale_add(&temp_vec, v2e, tvec, -dot);
if (IS_VEC_NULL_SQ_SAFE(&temp_vec)) {
// return false, target is perfectly aligned over or below the turret
// safe bet is to allow turret to reacquire better target
return false;
}
// normalize the vec, it needs to be done regardless
vm_vec_normalize(&temp_vec);
bool fix_elevation = false;
bool fix_base_rot = false;
if (dot < tp->turret_fov) {
dot = tp->turret_fov;
fix_elevation = true;
}
if (dot > tp->turret_max_fov) {
dot = tp->turret_max_fov;
fix_elevation = true;
}
if (tp->flags & MSS_FLAG_TURRET_ALT_MATH) {
vec3d temp_vec2;
vm_vec_rotate(&temp_vec2, &temp_vec, &ss->world_to_turret_matrix);
// now in turrets frame of reference
// check if math is actually possible
if (!((temp_vec2.xyz.x == 0) && (temp_vec2.xyz.y == 0))) {
float temp_z = temp_vec2.xyz.z;
temp_vec2.xyz.z = 0.0f;
// make sure null vecs wont happen
if (!IS_VEC_NULL_SQ_SAFE(&temp_vec2)) {
vm_vec_normalize(&temp_vec2);
// only do this if it actually is required
if (-temp_vec2.xyz.y < tp->turret_y_fov) {
float check_pos = 1;
fix_base_rot = true;
temp_vec2.xyz.y = -tp->turret_y_fov;
if (temp_vec2.xyz.x < 0)
check_pos = -1;
temp_vec2.xyz.x = check_pos * sqrtf(1 - (temp_vec2.xyz.y*temp_vec2.xyz.y));
// restore z component
float scaler = sqrtf(1 - (temp_z*temp_z));
vm_vec_scale(&temp_vec2,scaler);
temp_vec2.xyz.z = temp_z;
// back to world frame
vm_vec_unrotate(&temp_vec, &temp_vec2, &ss->world_to_turret_matrix);
}
}
}
}
if (fix_elevation || fix_base_rot) {
if (fix_elevation) {
multiplier = sqrtf(1 - (dot*dot));
// keep the temp_vec scaled with the tweaked vector
vm_vec_scale(&temp_vec, multiplier);
}
vm_vec_scale_add(v2e, &temp_vec, tvec, dot);
// and we are done with v2e...
vm_vec_scale_add(predicted_pos, tpos, v2e, target_dist);
// and we are done with predicted position
return true;
} else {
mprintf(("Warning: Function 'is_object_radius_in_turret_fov' was called\nwithout need to fix turret alignments\n"));
return false;
}
}
// outside of the expanded radii, unable to align, return false
return false;
}
// return 1 if bomb_objp is headed towards ship_objp
int bomb_headed_towards_ship(object *bomb_objp, object *ship_objp)
{
@@ -300,7 +401,7 @@ int valid_turret_enemy(object *objp, object *turret_parent)
return 1;
}
if ( (objp->type == OBJ_SHIP) ) {
if ( objp->type == OBJ_SHIP ) {
Assert( objp->instance >= 0 );
ship *shipp;
ship_info *sip;
@@ -357,9 +458,10 @@ extern int Player_attacking_enabled;
void evaluate_obj_as_target(object *objp, eval_enemy_obj_struct *eeo)
{
object *turret_parent_obj = &Objects[eeo->turret_parent_objnum];
ship *shipp;
ship *shipp;
ship_subsys *ss = eeo->turret_subsys;
float dist, dist_comp;
bool turret_has_no_target = false;
// Don't look for bombs when weapon system is not ok
if (objp->type == OBJ_WEAPON && !eeo->weapon_system_ok) {
@@ -390,28 +492,49 @@ void evaluate_obj_as_target(object *objp, eval_enemy_obj_struct *eeo)
}
// check if beam protected
if (eeo->beam_flag) {
if (eeo->eeo_flags & EEOF_BEAM) {
if (objp->flags & OF_BEAM_PROTECTED) {
return;
}
}
// check if flak protected
if (eeo->eeo_flags & EEOF_FLAK) {
if (objp->flags & OF_FLAK_PROTECTED) {
return;
}
}
// check if laser protected
if (eeo->eeo_flags & EEOF_LASER) {
if (objp->flags & OF_LASER_PROTECTED) {
return;
}
}
// check if missile protected
if (eeo->eeo_flags & EEOF_MISSILE) {
if (objp->flags & OF_MISSILE_PROTECTED) {
return;
}
}
// don't shoot at small ships if we shouldn't
if (eeo->big_only_flag) {
if (eeo->eeo_flags & EEOF_BIG_ONLY) {
if (!(Ship_info[shipp->ship_info_index].flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP))) {
return;
}
}
// don't shoot at big ships if we shouldn't
if (eeo->small_only_flag) {
if (eeo->eeo_flags & EEOF_SMALL_ONLY) {
if ((Ship_info[shipp->ship_info_index].flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP))) {
return;
}
}
// check if turret flagged to only target tagged ships
if (eeo->tagged_only_flag) {
if (eeo->eeo_flags & EEOF_TAGGED_ONLY) {
if (!ship_is_tagged(objp)) {
return;
}
@@ -474,9 +597,20 @@ void evaluate_obj_as_target(object *objp, eval_enemy_obj_struct *eeo)
}
if ((objp->type == OBJ_WEAPON) && check_weapon) {
//Maybe restrict the number of turrets attacking this bomb
if (ss->turret_max_bomb_ownage != -1) {
int num_att_turrets = num_turrets_attacking(turret_parent_obj, OBJ_INDEX(objp));
if (num_att_turrets > ss->system_info->turret_max_bomb_ownage) {
return;
}
}
if ( Weapons[objp->instance].homing_object == &Objects[eeo->turret_parent_objnum] ) {
if ( dist_comp < eeo->nearest_homing_bomb_dist ) {
if ( (eeo->current_enemy == -1) || object_in_turret_fov(objp, ss, eeo->tvec, eeo->tpos, dist + objp->radius) ) {
if (!(ss->flags & SSF_FOV_REQUIRED) && (eeo->current_enemy == -1)) {
turret_has_no_target = true;
}
if ( (turret_has_no_target) || object_in_turret_fov(objp, ss, eeo->tvec, eeo->tpos, dist + objp->radius) ) {
eeo->nearest_homing_bomb_dist = dist_comp;
eeo->nearest_homing_bomb_objnum = OBJ_INDEX(objp);
}
@@ -484,7 +618,10 @@ void evaluate_obj_as_target(object *objp, eval_enemy_obj_struct *eeo)
// if not homing, check if bomb is flying towards ship
} else if ( bomb_headed_towards_ship(objp, &Objects[eeo->turret_parent_objnum]) ) {
if ( dist_comp < eeo->nearest_bomb_dist ) {
if ( (eeo->current_enemy == -1) || object_in_turret_fov(objp, ss, eeo->tvec, eeo->tpos, dist + objp->radius) ) {
if (!(ss->flags & SSF_FOV_REQUIRED) && (eeo->current_enemy == -1)) {
turret_has_no_target = true;
}
if ( (turret_has_no_target) || object_in_turret_fov(objp, ss, eeo->tvec, eeo->tpos, dist + objp->radius) ) {
eeo->nearest_bomb_dist = dist_comp;
eeo->nearest_bomb_objnum = OBJ_INDEX(objp);
}
@@ -513,6 +650,10 @@ void evaluate_obj_as_target(object *objp, eval_enemy_obj_struct *eeo)
if (objp->flags & OF_PLAYER_SHIP) {
max_turrets = The_mission.ai_profile->max_turret_ownage_player[Game_skill_level];
}
// Apply the per-turret limit, if there is one
if (ss->turret_max_target_ownage != -1) {
max_turrets = MIN(max_turrets, ss->system_info->turret_max_target_ownage);
}
if (num_att_turrets > max_turrets) {
return;
}
@@ -540,7 +681,10 @@ void evaluate_obj_as_target(object *objp, eval_enemy_obj_struct *eeo)
// maybe update nearest attacker
if ( dist_comp < eeo->nearest_attacker_dist ) {
if ( (eeo->current_enemy == -1) || object_in_turret_fov(objp, ss, eeo->tvec, eeo->tpos, dist + objp->radius) ) {
if (!(ss->flags & SSF_FOV_REQUIRED) && (eeo->current_enemy == -1)) {
turret_has_no_target = true;
}
if ( (turret_has_no_target) || object_in_turret_fov(objp, ss, eeo->tvec, eeo->tpos, dist + objp->radius) ) {
// nprintf(("AI", "Nearest enemy = %s, dist = %7.3f, dot = %6.3f, fov = %6.3f\n", Ships[objp->instance].ship_name, dist, vm_vec_dot(&v2e, tvec), tp->turret_fov));
eeo->nearest_attacker_dist = dist_comp;
eeo->nearest_attacker_objnum = OBJ_INDEX(objp);
@@ -555,7 +699,10 @@ void evaluate_obj_as_target(object *objp, eval_enemy_obj_struct *eeo)
dist_comp *= 0.9f + (0.01f * asteroid_time_to_impact(objp));
if (dist_comp < eeo->nearest_dist ) {
if ( (eeo->current_enemy == -1) || object_in_turret_fov(objp, ss, eeo->tvec, eeo->tpos, dist + objp->radius) ) {
if (!(ss->flags & SSF_FOV_REQUIRED) && (eeo->current_enemy == -1)) {
turret_has_no_target = true;
}
if ( (turret_has_no_target) || object_in_turret_fov(objp, ss, eeo->tvec, eeo->tpos, dist + objp->radius) ) {
eeo->nearest_dist = dist_comp;
eeo->nearest_objnum = OBJ_INDEX(objp);
}
@@ -592,7 +739,7 @@ int is_target_beam_valid(ship_weapon *swp, object *objp)
// tpos => position of turret (world coords)
// tvec => forward vector of turret (world coords)
// current_enemy => objnum of current turret target
int get_nearest_turret_objnum(int turret_parent_objnum, ship_subsys *turret_subsys, int enemy_team_mask, vec3d *tpos, vec3d *tvec, int current_enemy, bool big_only_flag, bool small_only_flag, bool tagged_only_flag, bool beam_flag)
int get_nearest_turret_objnum(int turret_parent_objnum, ship_subsys *turret_subsys, int enemy_team_mask, vec3d *tpos, vec3d *tvec, int current_enemy, bool big_only_flag, bool small_only_flag, bool tagged_only_flag, bool beam_flag, bool flak_flag, bool laser_flag, bool missile_flag)
{
//float weapon_travel_dist;
int weapon_system_ok;
@@ -620,10 +767,26 @@ int get_nearest_turret_objnum(int turret_parent_objnum, ship_subsys *turret_subs
eeo.turret_parent_objnum = turret_parent_objnum;
eeo.weapon_system_ok = weapon_system_ok;
eeo.weapon_travel_dist = longest_turret_weapon_range(swp);
eeo.big_only_flag = big_only_flag;
eeo.small_only_flag = small_only_flag;
eeo.tagged_only_flag = tagged_only_flag;
eeo.beam_flag = beam_flag;
// set flags
eeo.eeo_flags = 0;
if (big_only_flag)
eeo.eeo_flags |= EEOF_BIG_ONLY;
if (small_only_flag)
eeo.eeo_flags |= EEOF_SMALL_ONLY;
if (tagged_only_flag)
eeo.eeo_flags |= EEOF_TAGGED_ONLY;
// flags for weapon types
if (beam_flag)
eeo.eeo_flags |= EEOF_BEAM;
else if (flak_flag)
eeo.eeo_flags |= EEOF_FLAK;
else if (laser_flag)
eeo.eeo_flags |= EEOF_LASER;
else if (missile_flag)
eeo.eeo_flags |= EEOF_MISSILE;
eeo.enemy_team_mask = enemy_team_mask;
eeo.current_enemy = current_enemy;
eeo.tpos = tpos;
@@ -672,9 +835,9 @@ int get_nearest_turret_objnum(int turret_parent_objnum, ship_subsys *turret_subs
else
tt = &Ai_tp_list[Weapon_info[priority_weapon_idx].targeting_priorities[i]];
int n_types = tt->ship_type.size();
int n_s_classes = tt->ship_class.size();
int n_w_classes = tt->weapon_class.size();
int n_types = (int)tt->ship_type.size();
int n_s_classes = (int)tt->ship_class.size();
int n_w_classes = (int)tt->weapon_class.size();
bool found_something;
object *ptr = GET_FIRST(&obj_used_list);
@@ -894,10 +1057,15 @@ int find_turret_enemy(ship_subsys *turret_subsys, int objnum, vec3d *tpos, vec3d
tp = turret_subsys->system_info;
enemy_team_mask = iff_get_attackee_mask(obj_team(&Objects[objnum]));
bool big_only_flag = all_turret_weapons_have_flags(&turret_subsys->weapons, WIF_HUGE);
bool small_only_flag = all_turret_weapons_have_flags2(&turret_subsys->weapons, WIF2_SMALL_ONLY);
bool tagged_only_flag = all_turret_weapons_have_flags2(&turret_subsys->weapons, WIF2_TAGGED_ONLY) || (turret_subsys->weapons.flags & SW_FLAG_TAGGED_ONLY);
bool beam_flag = all_turret_weapons_have_flags(&turret_subsys->weapons, WIF_BEAM);
bool beam_flag = turret_weapon_has_flags(&turret_subsys->weapons, WIF_BEAM);
bool flak_flag = turret_weapon_has_flags(&turret_subsys->weapons, WIF_FLAK);
bool laser_flag = turret_weapon_has_subtype(&turret_subsys->weapons, WP_LASER);
bool missile_flag = turret_weapon_has_subtype(&turret_subsys->weapons, WP_MISSILE);
// If a small ship and target_objnum != -1, use that as goal.
ai_info *aip = &Ai_info[Ships[Objects[objnum].instance].ai_index];
@@ -931,8 +1099,14 @@ int find_turret_enemy(ship_subsys *turret_subsys, int objnum, vec3d *tpos, vec3d
}
// maybe use ship target_objnum if valid for turret
// check for beam weapon and beam protected
if ( !((target_flags & OF_BEAM_PROTECTED) && (beam_flag)) ) {
// check for beam weapon and beam protected, etc.
bool skip = false;
if ( (target_flags & OF_BEAM_PROTECTED) && beam_flag ) skip = true;
else if ( (target_flags & OF_FLAK_PROTECTED) && flak_flag ) skip = true;
else if ( (target_flags & OF_LASER_PROTECTED) && laser_flag ) skip = true;
else if ( (target_flags & OF_MISSILE_PROTECTED) && missile_flag ) skip = true;
if (!skip) {
if ( Objects[aip->target_objnum].type == OBJ_SHIP ) {
// check for huge weapon and huge ship
if ( !big_only_flag || (Ship_info[Ships[Objects[aip->target_objnum].instance].ship_info_index].flags & (SIF_BIG_SHIP|SIF_HUGE_SHIP)) ) {
@@ -945,7 +1119,13 @@ int find_turret_enemy(ship_subsys *turret_subsys, int objnum, vec3d *tpos, vec3d
dist = vm_vec_normalized_dir(&v2e, &Objects[aip->target_objnum].pos, tpos);
in_fov = turret_fov_test(turret_subsys, tvec, &v2e);
// MODIFY FOR ATTACKING BIG SHIP
if (turret_subsys->flags & SSF_FOV_EDGE_CHECK) {
if (in_fov == false)
if (object_in_turret_fov(&Objects[aip->target_objnum], turret_subsys, tvec, tpos, dist + Objects[aip->target_objnum].radius))
in_fov = true;
}
// MODIFY FOR ATTACKING BIG SHIP
// dot += (0.5f * Objects[aip->target_objnum].radius / dist);
if (in_fov) {
return aip->target_objnum;
@@ -957,9 +1137,13 @@ int find_turret_enemy(ship_subsys *turret_subsys, int objnum, vec3d *tpos, vec3d
}
}
enemy_objnum = get_nearest_turret_objnum(objnum, turret_subsys, enemy_team_mask, tpos, tvec, current_enemy, big_only_flag, small_only_flag, tagged_only_flag, beam_flag);
enemy_objnum = get_nearest_turret_objnum(objnum, turret_subsys, enemy_team_mask, tpos, tvec, current_enemy, big_only_flag, small_only_flag, tagged_only_flag, beam_flag, flak_flag, laser_flag, missile_flag);
if ( enemy_objnum >= 0 ) {
Assert( !((Objects[enemy_objnum].flags & OF_BEAM_PROTECTED) && beam_flag) );
Assert( !((Objects[enemy_objnum].flags & OF_FLAK_PROTECTED) && flak_flag) );
Assert( !((Objects[enemy_objnum].flags & OF_LASER_PROTECTED) && laser_flag) );
Assert( !((Objects[enemy_objnum].flags & OF_MISSILE_PROTECTED) && missile_flag) );
if ( Objects[enemy_objnum].flags & OF_PROTECTED ) {
Int3();
enemy_objnum = aip->target_objnum;
@@ -994,23 +1178,43 @@ void ship_get_global_turret_gun_info(object *objp, ship_subsys *ssp, vec3d *gpos
vec3d * gun_pos;
model_subsystem *tp = ssp->system_info;
ship_model_start(objp);
//ship_model_start(objp);
gun_pos = &tp->turret_firing_point[ssp->turret_next_fire_pos % tp->turret_num_firing_points];
model_find_world_point(gpos, gun_pos, tp->model_num, tp->turret_gun_sobj, &objp->orient, &objp->pos );
//model_find_world_point(gpos, gun_pos, tp->model_num, tp->turret_gun_sobj, &objp->orient, &objp->pos );
model_instance_find_world_point(gpos, gun_pos, tp->model_num, Ships[objp->instance].model_instance_num, tp->turret_gun_sobj, &objp->orient, &objp->pos);
if (use_angles)
model_find_world_dir(gvec, &tp->turret_norm, tp->model_num, tp->turret_gun_sobj, &objp->orient, &objp->pos );
model_instance_find_world_dir(gvec, &tp->turret_norm, tp->model_num, Ships[objp->instance].model_instance_num, tp->turret_gun_sobj, &objp->orient, &objp->pos );
else {
//vector gun_pos2;
//vm_vec_add(&gun_pos2, gpos, gun_pos);
vm_vec_normalized_dir(gvec, targetp, gpos);
}
ship_model_stop(objp);
//ship_model_stop(objp);
// per firingpoint based changes go here for turrets
}
//Update turret aiming data based on max turret aim update delay
void turret_ai_update_aim(ai_info *aip, object *En_Objp, ship_subsys *ss)
{
if (Missiontime >= ss->next_aim_pos_time)
{
ss->last_aim_enemy_pos = En_Objp->pos;
ss->last_aim_enemy_vel = En_Objp->phys_info.vel;
ss->next_aim_pos_time = Missiontime + fl2f(frand_range(0.0f, aip->ai_turret_max_aim_update_delay));
}
else
{
//Update the position based on the velocity (assume no velocity vector change)
vm_vec_scale_add2(&ss->last_aim_enemy_pos, &ss->last_aim_enemy_vel, flFrametime);
}
}
// Rotate a turret towards an enemy.
// Return TRUE if caller should use angles in subsequent rotations.
// Some obscure model thing only John Slagel knows about.
@@ -1041,23 +1245,26 @@ int aifft_rotate_turret(ship *shipp, int parent_objnum, ship_subsys *ss, object
ship_get_global_turret_info(&Objects[parent_objnum], tp, &gun_pos, &gun_vec);
//Update "known" position and velocity of target. Only matters if max_aim_update_delay is set.
turret_ai_update_aim(&Ai_info[shipp->ai_index], &Objects[ss->turret_enemy_objnum], ss);
//Figure out what point on the ship we want to point the gun at, and store the global location
//in enemy_point.
vec3d enemy_point;
if ((ss->targeted_subsys != NULL) && !(ss->flags & SSF_NO_SS_TARGETING)) {
if (ss->turret_enemy_objnum != -1) {
vm_vec_unrotate(&enemy_point, &ss->targeted_subsys->system_info->pnt, &Objects[ss->turret_enemy_objnum].orient);
vm_vec_add2(&enemy_point, &Objects[ss->turret_enemy_objnum].pos);
vm_vec_add2(&enemy_point, &ss->last_aim_enemy_pos);
}
} else {
if ((lep->type == OBJ_SHIP) && (Ship_info[Ships[lep->instance].ship_info_index].flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP))) {
ai_big_pick_attack_point_turret(lep, ss, &gun_pos, &gun_vec, &enemy_point, tp->turret_fov, MIN(wip->max_speed * wip->lifetime, wip->weapon_range));
} else {
enemy_point = lep->pos;
enemy_point = ss->last_aim_enemy_pos;
}
}
target_moving_direction = lep->phys_info.vel;
target_moving_direction = 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 & AIPF_USE_ADDITIVE_WEAPON_VELOCITY) {
@@ -1084,6 +1291,11 @@ int aifft_rotate_turret(ship *shipp, int parent_objnum, ship_subsys *ss, object
in_fov = turret_fov_test(ss, gvec, &v2e);
if (ss->flags & SSF_FOV_EDGE_CHECK) {
if (in_fov == false)
in_fov = is_object_radius_in_turret_fov(&Objects[ss->turret_enemy_objnum], ss, gvec, &gun_pos, &v2e, predicted_enemy_pos, 0.0f);
}
if (in_fov) {
ret_val = model_rotate_gun(Ship_info[shipp->ship_info_index].model_num,
tp, &Objects[parent_objnum].orient,
@@ -1317,7 +1529,7 @@ void turret_set_next_fire_timestamp(int weapon_num, weapon_info *wip, ship_subsy
{
// make side even for team vs. team
if ((Game_mode & GM_MULTIPLAYER) && (Netgame.type_flags & NG_TYPE_TEAM)) {
if (MULTI_TEAM) {
// flak guns need to fire more rapidly
if (wip->wi_flags & WIF_FLAK) {
wait *= aip->ai_ship_fire_delay_scale_friendly * 0.5f;
@@ -1359,13 +1571,16 @@ void turret_set_next_fire_timestamp(int weapon_num, weapon_info *wip, ship_subsy
wait *= frand_range(0.9f, 1.1f);
}
if(turret->rof_scaler != 1.0f)
wait /= get_adjusted_turret_rof(turret);
(*fs_dest) = timestamp((int)wait);
}
// Decide if a turret should launch an aspect seeking missile
int turret_should_fire_aspect(ship_subsys *turret, float dot, weapon_info *wip)
int turret_should_fire_aspect(ship_subsys *turret, weapon_info *wip, bool in_sight)
{
if ( (dot > AICODE_TURRET_DUMBFIRE_ANGLE) && (turret->turret_time_enemy_in_range >= MIN(wip->min_lock_time,AICODE_TURRET_MAX_TIME_IN_RANGE)) ) {
if ( in_sight && (turret->turret_time_enemy_in_range >= MIN(wip->min_lock_time,AICODE_TURRET_MAX_TIME_IN_RANGE)) ) {
return 1;
}
@@ -1420,6 +1635,34 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
wip = get_turret_weapon_wip(&turret->weapons, weapon_num);
int turret_weapon_class = WEAPON_INFO_INDEX(wip);
#ifndef NDEBUG
// moved here from check_ok_to_fire
if (turret->turret_enemy_objnum >= 0) {
object *tobjp = &Objects[turret->turret_enemy_objnum];
// should not get this far. check if ship is protected from beam and weapon is type beam
if ( (wip->wi_flags & WIF_BEAM) && (tobjp->flags & OF_BEAM_PROTECTED) ) {
Int3();
return 0;
}
// should not get this far. check if ship is protected from flak and weapon is type flak
else if ( (wip->wi_flags & WIF_FLAK) && (tobjp->flags & OF_FLAK_PROTECTED) ) {
Int3();
return 0;
}
// should not get this far. check if ship is protected from laser and weapon is type laser
else if ( (wip->subtype == WP_LASER) && (tobjp->flags & OF_LASER_PROTECTED) ) {
Int3();
return 0;
}
// should not get this far. check if ship is protected from missile and weapon is type missile
else if ( (wip->subtype == WP_MISSILE) && (tobjp->flags & OF_MISSILE_PROTECTED) ) {
Int3();
return 0;
}
}
#endif
if (check_ok_to_fire(parent_objnum, turret->turret_enemy_objnum, wip)) {
vm_vector_2_matrix(&turret_orient, turret_fvec, NULL, NULL);
turret->turret_last_fire_direction = *turret_fvec;
@@ -1432,8 +1675,6 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
if (wip->wi_flags & WIF_BEAM) {
// if this beam isn't free to fire
if (!(turret->weapons.flags & SW_FLAG_BEAM_FREE)) {
//WMC - remove this
//Int3(); // should never get this far
return false;
}
beam_fire_info fire_info;
@@ -1447,7 +1688,6 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
fire_info.target = &Objects[turret->turret_enemy_objnum];
fire_info.target_subsys = NULL;
fire_info.turret = turret;
fire_info.fighter_beam = false;
// fire a beam weapon
beam_fire(&fire_info);
@@ -1465,7 +1705,11 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
// now do anything else
else {
for (int i=0; i < wip->shots; i++)
{
{
// zookeeper - Firepoints should cycle normally between shots,
// so we need to get the position info separately for each shot
ship_get_global_turret_gun_info(&Objects[parent_objnum], turret, turret_pos, turret_fvec, 1, NULL);
weapon_objnum = weapon_create( turret_pos, &turret_orient, turret_weapon_class, parent_objnum, -1, 1);
weapon_set_tracking_info(weapon_objnum, parent_objnum, turret->turret_enemy_objnum, 1, turret->targeted_subsys);
@@ -1515,13 +1759,14 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
if ( wip->launch_snd != -1 ) {
// Don't play turret firing sound if turret sits on player ship... it gets annoying.
if ( parent_objnum != OBJ_INDEX(Player_obj) ) {
if ( parent_objnum != OBJ_INDEX(Player_obj) || (turret->flags & SSF_PLAY_SOUND_FOR_PLAYER) ) {
snd_play_3d( &Snds[wip->launch_snd], turret_pos, &View_position );
}
}
}
turret->turret_next_fire_pos++;
}
turret->turret_next_fire_pos--;
// reset any animations if we need to
// (I'm not sure how accurate this timestamp would be in practice - taylor)
if (turret->turret_animation_position == MA_POS_READY)
@@ -1668,14 +1913,6 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
return;
}
// starting animation checks
if (ss->turret_animation_position == MA_POS_NOT_SET) {
if ( model_anim_start_type(shipp, TRIGGER_TYPE_TURRET_FIRING, ss->system_info->subobj_num, 1) ) {
ss->turret_animation_done_time = model_anim_get_time_type(shipp, TRIGGER_TYPE_TURRET_FIRING, ss->system_info->subobj_num);
ss->turret_animation_position = MA_POS_SET;
}
}
if (ss->turret_animation_position == MA_POS_SET) {
if ( timestamp_elapsed(ss->turret_animation_done_time) ) {
ss->turret_animation_position = MA_POS_READY;
@@ -1847,6 +2084,12 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
}
}
if ( wip->wi_flags2 & WIF2_SMALL_ONLY ) {
if ( (lep->type == OBJ_SHIP) && (Ship_info[Ships[lep->instance].ship_info_index].flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP)) ) {
continue;
}
}
if (lep->type == OBJ_SHIP) {
// Check if we're targeting a protected ship
if (lep->flags & OF_PROTECTED) {
@@ -1861,6 +2104,24 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
ss->turret_time_enemy_in_range = 0.0f;
continue;
}
// Check if we're targeting a flak protected ship with a flak weapon
else if ( (lep->flags & OF_FLAK_PROTECTED) && (wip->wi_flags & WIF_FLAK) ) {
ss->turret_enemy_objnum = -1;
ss->turret_time_enemy_in_range = 0.0f;
continue;
}
// Check if we're targeting a laser protected ship with a laser weapon
else if ( (lep->flags & OF_LASER_PROTECTED) && (wip->subtype == WP_LASER) ) {
ss->turret_enemy_objnum = -1;
ss->turret_time_enemy_in_range = 0.0f;
continue;
}
// Check if we're targeting a missile protected ship with a missile weapon
else if ( (lep->flags & OF_MISSILE_PROTECTED) && (wip->subtype == WP_MISSILE) ) {
ss->turret_enemy_objnum = -1;
ss->turret_time_enemy_in_range = 0.0f;
continue;
}
}
else
{
@@ -1883,8 +2144,8 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
if(num_valid < 1)
ss->turret_enemy_objnum = -1;
// Maybe pick a new enemy.
if ( turret_should_pick_new_target(ss) ) {
// Maybe pick a new enemy, unless targeting has been taken over by scripting
if ( turret_should_pick_new_target(ss) && !ss->scripting_target_override ) {
Num_find_turret_enemy++;
int objnum = find_turret_enemy(ss, parent_objnum, &gpos, &gvec, ss->turret_enemy_objnum);
//Assert(objnum < 0 || is_target_beam_valid(tp, objnum));
@@ -1892,11 +2153,13 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
if (objnum >= 0 && is_target_beam_valid(&ss->weapons, &Objects[objnum])) {
if (ss->turret_enemy_objnum == -1) {
ss->turret_enemy_objnum = objnum;
ss->targeted_subsys = NULL; // Turret has retargeted; reset subsystem - Valathil for Mantis #2652
ss->turret_enemy_sig = Objects[objnum].signature;
// why return?
return;
} else {
ss->turret_enemy_objnum = objnum;
ss->targeted_subsys = NULL; // Turret has retargeted; reset subsystem - Valathil for Mantis #2652
ss->turret_enemy_sig = Objects[objnum].signature;
}
} else {
@@ -2070,7 +2333,7 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
{
turret_update_enemy_in_range(ss, 2*wip->fire_wait);
}
if ( turret_should_fire_aspect(ss, dot, wip) )
if ( turret_should_fire_aspect(ss, wip, in_sight) )
{
ok_to_fire = true;
}
@@ -2083,7 +2346,7 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
}
// Check if turret should fire and enemy's engines are
// in line of sight
if (turret_should_fire_aspect(ss, dot, wip) &&
if (turret_should_fire_aspect(ss, wip, in_sight) &&
ship_get_closest_subsys_in_sight(&Ships[lep->signature], SUBSYSTEM_ENGINE, &gpos))
{
ok_to_fire = true;
@@ -2097,6 +2360,7 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
vm_vec_scale_add(&end, &gpos, &gvec, model_get_radius(model_num));
hull_check.model_instance_num = shipp->model_instance_num;
hull_check.model_num = model_num;
hull_check.orient = &objp->orient;
hull_check.pos = &objp->pos;
@@ -2109,18 +2373,40 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
}
}
if ( ok_to_fire )
{
// starting animation checks
if (ss->turret_animation_position == MA_POS_NOT_SET) {
if ( model_anim_start_type(shipp, TRIGGER_TYPE_TURRET_FIRING, ss->system_info->subobj_num, 1) ) {
ss->turret_animation_done_time = model_anim_get_time_type(shipp, TRIGGER_TYPE_TURRET_FIRING, ss->system_info->subobj_num);
ss->turret_animation_position = MA_POS_SET;
}
}
//Wait until the animation is done to actually fire
if (tp->flags & MSS_FLAG_TURRET_ANIM_WAIT && (ss->turret_animation_position != MA_POS_READY))
{
ok_to_fire = false;
}
}
if ( ok_to_fire )
{
something_was_ok_to_fire = true;
Num_turrets_fired++;
//Pass along which gun we are using
if (tp->flags & MSS_FLAG_TURRET_SALVO)
turret_fire_weapon(valid_weapons[0], ss, parent_objnum, &gpos, &tv2e, &predicted_enemy_pos);
else
turret_fire_weapon(valid_weapons[i], ss, parent_objnum, &gpos, &tv2e, &predicted_enemy_pos);
} else {
// make sure salvo fire mode does not turn into autofire
if ((tp->flags & MSS_FLAG_TURRET_SALVO) && ((i + 1) == number_of_firings)) {
ai_info *parent_aip = &Ai_info[Ships[Objects[parent_objnum].instance].ai_index];
turret_set_next_fire_timestamp(valid_weapons[0], wip, ss, parent_aip);
}
}
// moved this here so we increment the fire pos only after we have fired and not during it
ss->turret_next_fire_pos++;
}
@@ -2130,6 +2416,14 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
//Impose a penalty on turret accuracy for losing site of its goal, or just not being able to fire.
turret_update_enemy_in_range(ss, -4*Weapon_info[ss->turret_best_weapon].fire_wait);
ss->turret_next_fire_stamp = timestamp(500);
// If nothing is OK to fire (lost track of the target?)
// reset the target (so we don't continue to track what we can't hit)
if (tp->flags2 & MSS_FLAG2_TURRET_ONLY_TARGET_IF_CAN_FIRE)
{
ss->turret_enemy_objnum = -1; // Reset enemy objnum, find a new one next frame.
ss->turret_time_enemy_in_range = 0.0f;
}
}
else
{
@@ -2178,7 +2472,7 @@ bool turret_std_fov_test(ship_subsys *ss, vec3d *gvec, vec3d *v2e, float size_mo
{
model_subsystem *tp = ss->system_info;
float dot = vm_vec_dot(v2e, gvec);
if (((dot + size_mod) > tp->turret_fov) && ((dot - size_mod) <= tp->turret_max_fov))
if (((dot + size_mod) >= tp->turret_fov) && ((dot - size_mod) <= tp->turret_max_fov))
return true;
return false;
@@ -2188,17 +2482,19 @@ bool turret_adv_fov_test(ship_subsys *ss, vec3d *gvec, vec3d *v2e, float size_mo
{
model_subsystem *tp = ss->system_info;
float dot = vm_vec_dot(v2e, gvec);
if (((dot + size_mod) > tp->turret_fov) && ((dot - size_mod) <= tp->turret_max_fov)) {
if (((dot + size_mod) >= tp->turret_fov) && ((dot - size_mod) <= tp->turret_max_fov)) {
vec3d of_dst;
vm_vec_rotate( &of_dst, v2e, &ss->world_to_turret_matrix );
vm_vec_normalize(&of_dst);
if ((of_dst.xyz.x == 0) && (of_dst.xyz.y == 0)) {
return true;
} else {
of_dst.xyz.z = 0;
// now we have 2d vector with lenght of 1 that points at the targets direction after being rotated to turrets FOR
if ((-of_dst.xyz.y + size_mod) > tp->turret_y_fov)
return true;
if (!IS_VEC_NULL_SQ_SAFE(&of_dst)) {
vm_vec_normalize(&of_dst);
// now we have 2d vector with lenght of 1 that points at the targets direction after being rotated to turrets FOR
if ((-of_dst.xyz.y + size_mod) >= tp->turret_y_fov)
return true;
}
}
}
return false;
@@ -2214,3 +2510,28 @@ bool turret_fov_test(ship_subsys *ss, vec3d *gvec, vec3d *v2e, float size_mod)
return in_fov;
}
float get_adjusted_turret_rof(ship_subsys *ss)
{
float tempf = ss->rof_scaler;
// optional reset switch (negative value)
if (tempf < 0) {
ss->rof_scaler = 1.0f;
return 1.0f;
}
if (tempf == 0) {
// special case returning the number of firingpoints
ss->rof_scaler = (float) ss->system_info->turret_num_firing_points;
tempf = ss->rof_scaler;
// safety check to avoid div/0 issues
if (tempf == 0) {
ss->rof_scaler = 1.0f;
return 1.0f;
}
}
return tempf;
}
+112 -183
View File
@@ -31,16 +31,17 @@ anim_instance anim_render_list;
#define MAX_ANIM_INSTANCES 25
anim_instance anim_render_instance[MAX_ANIM_INSTANCES];
int Anim_paused; // global variable to pause the playing back of anims
int Anim_paused; /// Global variable to pause the playing back of anims
int Anim_inited = FALSE;
fix t1,t2;
int Anim_ignore_frametime=0; // flag used to ignore frametime... useful when need to avoid saturated frametimes
// -------------------------------------------------------------------------------------------------
// anim_init() will queue all the anim_render_instance[] elements onto the anim_free_list
//
/**
* @brief Initialise animation
* @details Queue all the ::anim_render_instance[] elements onto the ::anim_free_list
*/
void anim_init()
{
int i;
@@ -60,9 +61,9 @@ void anim_init()
Anim_inited = TRUE;
}
// -------------------------------------------------------------------------------------------------
// anim_render_all() will display the frames for the currently playing anims
//
/**
* @brief Display the frames for the currently playing anims
*/
void anim_render_all(int screen_id, float frametime)
{
anim_instance* A;
@@ -85,10 +86,10 @@ void anim_render_all(int screen_id, float frametime)
}
}
// -------------------------------------------------------------------------------------------------
// anim_render_one() will display the frames for the passed animation, it will ignore animations which
// do not have the same id as the passed screen_id
//
/**
* @brief Display the frames for the passed animation
* @details It will ignore animations which do not have the same id as the passed screen_id
*/
void anim_render_one(int screen_id, anim_instance *ani, float frametime)
{
// make sure this guy's screen id matches the passed one
@@ -109,14 +110,17 @@ void anim_render_one(int screen_id, anim_instance *ani, float frametime)
MONITOR(NumANIPlayed)
// Setup an anim_play_struct for passing into anim_play(). Will fill in default values, which you
// can then change before calling anim_play().
//
void anim_play_init(anim_play_struct *aps, anim *a_info, int x, int y)
/**
* @brief Setup an anim_play_struct for passing into ::anim_play().
* @details Will fill in default values, which you can then change before calling ::anim_play().
*/
void anim_play_init(anim_play_struct *aps, anim *a_info, int x, int y, int base_w, int base_h)
{
aps->anim_info = a_info;
aps->x = x;
aps->y = y;
aps->base_w = base_w;
aps->base_h = base_h;
aps->start_at = 0;
aps->stop_at = a_info->total_frames - 1;
aps->screen_id = 0;
@@ -129,49 +133,21 @@ void anim_play_init(anim_play_struct *aps, anim *a_info, int x, int y)
aps->ping_pong = 0;
}
// -------------------------------------------------------------------------------------------------
// anim_play() will add an anim instance to the anim_render_list. This will cause the
// anim to be played at the x,y position specified in the parameter list.
//
// input:
//
// anim_info => the compressed animation that we should make an instance from
// x => x position of animation to play at (top left corner)
// y => y position of animation to play at ( top left corner)
// start_at => frame number to start at (note: numbering is from 0->num_frames-1)
// stop_at => frame number to stop at (note: numbering is from 0->num_frames-1)
// screen_id => OPTIONAL (default value 0): screen signature so animation only plays when
// anim_render_all() called with that same signature
// world_pos => OPTIONAL (default value NULL): only give a world pos when you want to
// play the animation at a 3D location. You must specify radius when
// this is non-null.
// radius => OPTIONAL (default value 0): only needed when the animation is playing
// as a 3D animation (this is only when world_pos in not NULL).
// fi => OPTIONAL (default value 0): framerate indepentdent flag, when set TRUE
// the animation will skip frames if necessary to maintain the fps value
// associated with the animation
// color => OPTIONAL (default value NULL) address of an alpha color struct. Only
// required when the animation should be drawn with an alpha color.
// skip_frames => OPTIONAL (default value 1) should anim skip frames when doing framerate
// independent playback
// looped => OPTIONAL (default value 0) should anim play looped (ie forever)
//
// returns:
//
// pointer to instance => success
// NULL => if anim anim could not be played
//
/**
* @brief Will add an anim instance to the anim_render_list.
* This will cause the anim to be played at the x,y position specified in the parameter list.
*
* @param aps Compressed animation that we should make an instance from
* @return If success pointer to instance, NULL if anim anim could not be played
*/
anim_instance *anim_play(anim_play_struct *aps)
{
Assert( aps->anim_info != NULL );
Assert( aps->start_at >= 0 );
Assert( aps->stop_at < aps->anim_info->total_frames );
// Assert( aps->stop_at >= aps->start_at );
Assert( !(aps->looped && aps->ping_pong) ); // shouldn't have these both set at once
MONITOR_INC(NumANIPlayed, 1);
// if (aps->ping_pong && !(aps->anim_info->flags & ANF_ALL_KEYFRAMES));
anim_instance *instance;
@@ -219,6 +195,14 @@ anim_instance *anim_play(anim_play_struct *aps)
instance->xlate_pal = 0;
}
if(aps->base_w < 0 || aps->base_h < 0) {
instance->base_w = gr_screen.max_w_unscaled;
instance->base_h = gr_screen.max_h_unscaled;
} else {
instance->base_w = aps->base_w;
instance->base_h = aps->base_h;
}
// determining the start_at frame is more complicated, since it must be a key-frame.
// Futhermore, need to subtract 1 from key-frame number, since frame number is always
// incremented the first time anim_show_next_frame() is called
@@ -243,16 +227,6 @@ anim_instance *anim_play(anim_play_struct *aps)
idx++;
}
/*while (keyp) {
if (( (keyp->frame_num-1) <= frame_num) && ( (keyp->frame_num-1) > key)) { // find closest key
key = keyp->frame_num-1;
offset = keyp->offset;
if ( key == frame_num )
break;
}
keyp = keyp->next;
}*/
if (key > instance->frame_num) { // best key is closer than current position
instance->frame_num = key;
@@ -270,20 +244,17 @@ anim_instance *anim_play(anim_play_struct *aps)
return instance;
}
// -----------------------------------------------------------------------------
// anim_show_next_frame()
//
// This function is called to blit the next frame of an anim instance to the
// screen. This is normally called by the anim_render_all() function.
//
// input: instance => pointer to animation instance
// frametime => time elapsed since last call, in seconds
//
/**
* @brief This function is called to blit the next frame of an anim instance to the screen.
* This is normally called by the anim_render_all() function.
*
* @param instance Pointer to animation instance
* @param frametime Time elapsed since last call, in seconds
*/
int anim_show_next_frame(anim_instance *instance, float frametime)
{
int bitmap_id, bitmap_flags=0, new_frame_num, frame_diff=0, i, n_frames=0,frame_save;
float percent_through, decompress_time, render_time, time;
int bitmap_id, bitmap_flags=0, new_frame_num, frame_diff=0, i, n_frames=0,frame_save;
float percent_through, decompress_time, render_time, time;
vertex image_vertex;
int aabitmap = 0;
int bpp = 16;
@@ -365,7 +336,6 @@ int anim_show_next_frame(anim_instance *instance, float frametime)
instance->time_elapsed = 0.0f;
} else if(instance->ping_pong) { // pingponged animations
instance->frame_num = instance->stop_at;
// instance->time_elapsed = 0.0f;
anim_reverse_direction(instance);
} else { // one-shot animations
instance->frame_num = instance->stop_at;
@@ -380,7 +350,6 @@ int anim_show_next_frame(anim_instance *instance, float frametime)
instance->time_elapsed = 0.0f;
} else if(instance->ping_pong) { // pingponged animations
instance->frame_num = instance->stop_at;
// instance->time_elapsed = 0.0f;
anim_reverse_direction(instance);
} else { // one-shot animations
instance->frame_num = instance->stop_at+1;
@@ -404,7 +373,6 @@ int anim_show_next_frame(anim_instance *instance, float frametime)
}
}
Assert(frame_diff >= 0);
// nprintf(("Alan","FRAME DIFF: %d\n",frame_diff));
Assert( instance->frame_num >= 0 && instance->frame_num < instance->parent->total_frames );
// if the anim is paused, ignore all the above changes and still display this frame
@@ -415,7 +383,6 @@ int anim_show_next_frame(anim_instance *instance, float frametime)
}
if (instance->parent->flags & ANF_XPARENT){
// bitmap_flags = BMP_XPARENT;
bitmap_flags = 0;
}
bpp = 16;
@@ -505,7 +472,7 @@ int anim_show_next_frame(anim_instance *instance, float frametime)
if ( instance->last_bitmap != -1 ){
bm_release(instance->last_bitmap);
}
bitmap_id = bm_create(16, instance->parent->width, instance->parent->height, instance->frame, bitmap_flags);
bitmap_id = bm_create(bpp, instance->parent->width, instance->parent->height, instance->frame, bitmap_flags);
}
if ( bitmap_id == -1 ) {
@@ -521,6 +488,8 @@ int anim_show_next_frame(anim_instance *instance, float frametime)
// determine x,y to display the bitmap at
if ( instance->world_pos == NULL ) {
gr_set_screen_scale(instance->base_w, instance->base_h);
gr_set_clip(0, 0, instance->base_w, instance->base_h, false);
if ( instance->aa_color == NULL ) {
gr_bitmap(instance->x, instance->y);
}
@@ -528,6 +497,8 @@ int anim_show_next_frame(anim_instance *instance, float frametime)
gr_set_color_fast( (color*)instance->aa_color );
gr_aabitmap(instance->x, instance->y);
}
gr_reset_screen_scale();
gr_reset_clip();
}
else {
g3_rotate_vertex(&image_vertex,instance->world_pos);
@@ -535,23 +506,18 @@ int anim_show_next_frame(anim_instance *instance, float frametime)
g3_draw_bitmap(&image_vertex, 0, instance->radius*1.5f, TMAP_FLAG_TEXTURED | TMAP_HTL_2D);
}
//bm_release(bitmap_id);
instance->last_bitmap = bitmap_id;
}
t2 = timer_get_fixed_seconds();
render_time = f2fl(t2-t1);
// nprintf(("Alan","DECOMPRESS: %.3fms RENDER: %.3fms\n", decompress_time*1000, render_time*1000));
return 0;
}
// -----------------------------------------------------------------------------
// anim_stop_playing()
//
// Stop an anim instance that is on the anim_render_list from playing
//
/**
* @brief Stop an anim instance that is on the anim_render_list from playing
*/
int anim_stop_playing(anim_instance* instance)
{
Assert(instance != NULL);
@@ -562,14 +528,12 @@ int anim_stop_playing(anim_instance* instance)
return 0;
}
// -----------------------------------------------------------------------------
// anim_release_render_instance()
//
// Free a particular animation instance that is on the anim_render_list. Do
// not call this function to free an animation instance in general (use
// free_anim_instance() for that), only when you want to free an instance
// that is on the anim_render_list
//
/**
* @brief Free a particular animation instance that is on the anim_render_list.
* Do not call this function to free an animation instance in general (use
* free_anim_instance() for that), only when you want to free an instance
* that is on the anim_render_list
*/
void anim_release_render_instance(anim_instance* instance)
{
Assert( instance != NULL );
@@ -592,16 +556,13 @@ void anim_release_render_instance(anim_instance* instance)
list_append( &anim_free_list, instance );
}
// -----------------------------------------------------------------------------
// anim_release_all_instances()
//
// Free all anim instances that are on the anim_render_list.
//
// input: screen_id => optional parameter that lets you only free a subset
// of the anim instances. A screen_id of 0 is the default
// value, and this is used for animations that always play
// when they are placed on the aim_render_list.
//
/**
* @brief Free all anim instances that are on the anim_render_list.
*
* @param screen_id Optional parameter that lets you only free a subset of the anim instances.
* A screen_id of 0 is the default value, and this is used for animations that always play when
* they are placed on the aim_render_list.
*/
void anim_release_all_instances(int screen_id)
{
anim_instance* A;
@@ -625,18 +586,18 @@ void anim_release_all_instances(int screen_id)
//
// Read the header of a .ani file. Below is the format of a .ani header
//
// #bytes | description
// #bytes | description
// 2 | obsolete, kept for compatibility with old versions
// 2 | version number
// 2 | fps
// 1 | transparent red value
// 1 | transparent green value
// 1 | transparent green value
// 1 | transparent blue value
// 2 | width
// 2 | height
// 2 | number of frames
// 1 | packer code
// 763 | palette
// 763 | palette
// 2 | number of key frames
// 2 | key frame number } repeats
// 4 | key frame offset } repeats
@@ -646,7 +607,7 @@ void anim_read_header(anim *ptr, CFILE *fp)
{
ptr->width = cfread_short(fp);
// If first 2 bytes are zero, this means we are using a new format, which includes
// a version, and fps values. This is only done since a version number was not included
// a version, and fps values. This is only done since a version number was not included
// in the original header.
// default
@@ -711,20 +672,17 @@ void anim_read_header(anim *ptr, CFILE *fp)
}
}
// -----------------------------------------------------------------------------
// anim_load()
//
// Load an animation. This stores the compressed data, which instances
// of the animation can reference. Must be free'ed later with anim_free()
//
// input: name => filename of animation
// file_mapped => boolean, whether to use memory-mapped file or not.
// Memory-mapped files will page in the animation from disk
// as it is needed, but performance is not as good
//
// returns: pointer to anim that is loaded => sucess
// NULL => failure
//
/**
* @brief Load an animation. This stores the compressed data, which instances of the animation can reference.
* Must be free'ed later with anim_free().
*
* @param real_filename Filename of animation
* @param cf_dir_type
* @param file_mapped Whether to use memory-mapped file or not.
*
* @details Memory-mapped files will page in the animation from disk as it is needed, but performance is not as good.
* @return Pointer to anim that is loaded if sucess, NULL if failure.
*/
anim *anim_load(char *real_filename, int cf_dir_type, int file_mapped)
{
anim *ptr;
@@ -732,7 +690,7 @@ anim *anim_load(char *real_filename, int cf_dir_type, int file_mapped)
int count,idx;
char name[_MAX_PATH];
Assert ( real_filename != NULL );
Assert( real_filename != NULL );
strcpy_s( name, real_filename );
char *p = strchr( name, '.' );
@@ -783,22 +741,10 @@ anim *anim_load(char *real_filename, int cf_dir_type, int file_mapped)
ptr->keys[idx].frame_num = 0;
cfread(&ptr->keys[idx].frame_num, 2, 1, fp);
cfread(&ptr->keys[idx].offset, 4, 1, fp);
ptr->keys[idx].frame_num = INTEL_INT( ptr->keys[idx].frame_num );
ptr->keys[idx].offset = INTEL_INT( ptr->keys[idx].offset );
ptr->keys[idx].frame_num = INTEL_INT( ptr->keys[idx].frame_num ); //-V570
ptr->keys[idx].offset = INTEL_INT( ptr->keys[idx].offset ); //-V570
}
/*prev_keyp = &ptr->keys;
count = ptr->num_keys;
while (count--) {
keyp = (key_frame *) vm_malloc(sizeof(key_frame));
keyp->next = *prev_keyp;
*prev_keyp = keyp;
prev_keyp = &keyp->next;
keyp->frame_num = 0;
cfread(&keyp->frame_num, 2, 1, fp);
cfread(&keyp->offset, 4, 1, fp);
}*/
cfread(&count, 4, 1, fp); // size of compressed data
count = INTEL_INT( count );
@@ -859,12 +805,10 @@ anim *anim_load(char *real_filename, int cf_dir_type, int file_mapped)
return ptr;
}
// ---------------------------------------------------
// anim_free()
//
// Free an animation that was loaded with anim_load(). All instances
// referencing this animation must be free'ed or get an assert.
//
/**
* @brief Free an animation that was loaded with anim_load().
* @details All instances referencing this animation must be free'ed or get an assert.
*/
int anim_free(anim *ptr)
{
Assert ( ptr != NULL );
@@ -896,14 +840,14 @@ int anim_free(anim *ptr)
if ( ptr->flags & (ANF_MEM_MAPPED|ANF_STREAMED) ) {
cfclose(ptr->cfile_ptr);
if ( ptr->cache ) {
if (ptr->cache != NULL) {
vm_free(ptr->cache);
ptr->cache = NULL;
}
}
else {
Assert(ptr->data);
if ( ptr->data ) {
if (ptr->data != NULL) {
vm_free(ptr->data);
ptr->data = NULL;
}
@@ -915,11 +859,9 @@ int anim_free(anim *ptr)
}
// ---------------------------------------------------------------------
// anim_playing()
//
// Return if an anim is playing or not.
//
/**
* @brief Return if an anim is playing or not.
*/
int anim_playing(anim_instance *ai)
{
Assert(ai != NULL);
@@ -930,36 +872,28 @@ int anim_playing(anim_instance *ai)
}
// ---------------------------------------------------------------------
// anim_level_init()
//
// Called at the beginning of a mission to initialize any mission dependent
// anim data.
//
/**
* @brief Called at the beginning of a mission to initialize any mission dependent anim data.
* @todo Redundant?
*/
void anim_level_init()
{
}
// ---------------------------------------------------------------------
// anim_level_close()
//
// Called after the end of a mission to clean up any mission dependent
// anim data.
//
/**
* @brief Called after the end of a mission to clean up any mission dependent anim data.
*/
void anim_level_close()
{
anim_release_all_instances();
}
// ---------------------------------------------------
// anim_write_frames_out()
//
// Write the frames of a .ani file out to disk as .pcx files.
// Use naming convention: filename0000.pcx, filename0001.pcx etc.
//
// return: 0 => success
// -1 => failed
//
/**
* @brief Write the frames of a .ani file out to disk as .pcx files.
* @details Use naming convention: filename0000.pcx, filename0001.pcx etc.
*
* @return If success 0, or if failed -1
*/
int anim_write_frames_out(char *filename)
{
anim *source_anim;
@@ -1005,12 +939,10 @@ int anim_write_frames_out(char *filename)
return 0;
}
// ---------------------------------------------------
// anim_display_info()
//
// Display information and statistics about a .ani file.
// This is called when -i switch is on when running ac.exe
//
/**
* @brief Display information and statistics about a .ani file.
* @details This is called when -i switch is on when running ac.exe
*/
void anim_display_info(char *real_filename)
{
CFILE *fp;
@@ -1040,7 +972,6 @@ void anim_display_info(char *real_filename)
key_frame_nums[i] = 0;
cfread(&key_frame_nums[i], 2, 1, fp);
cfread(&tmp, 4, 1, fp);
//printf("key frame num: %d,%d\n", key_frame_nums[i],tmp);
}
cfread(&compressed, 4, 1, fp);
@@ -1069,7 +1000,7 @@ void anim_display_info(char *real_filename)
printf("FPS: %d\n", A.fps);
#ifndef NDEBUG
printf("Transparent RGB: (%d,%d,%d)\n", A.xparent_r, A.xparent_g, A.xparent_b);
printf("Transparent RGB: (%u,%u,%u)\n", A.xparent_r, A.xparent_g, A.xparent_b);
#endif
printf("ac version: %d\n", A.version);
@@ -1085,11 +1016,9 @@ void anim_reverse_direction(anim_instance *ai)
{
int temp;
if(!(ai->parent->flags & ANF_ALL_KEYFRAMES)){
// you're not allowed to call anim_reverse_direction(...) unless every frame is a keyframe!!!!
// The God of Delta-RLE demands it be thus.
Int3();
}
// you're not allowed to call anim_reverse_direction(...) unless every frame is a keyframe!!!!
// The God of Delta-RLE demands it be thus.
Assertion( ai->parent->flags & ANF_ALL_KEYFRAMES, "Ani was set to play backwards. In order to enable this, all frames of the animation MUST be keyframes.");
// flip the animation direction
if(ai->direction == ANIM_DIRECT_FORWARD){
+3 -1
View File
@@ -24,6 +24,8 @@ typedef struct {
anim *anim_info;
int x;
int y;
int base_w;
int base_h;
int start_at;
int stop_at;
int screen_id;
@@ -50,7 +52,7 @@ void anim_level_init();
void anim_level_close();
void anim_render_all(int screen_id, float frametime);
void anim_render_one(int screen_id, anim_instance *ani, float frametime);
void anim_play_init(anim_play_struct *aps, anim *a_info, int x, int y);
void anim_play_init(anim_play_struct *aps, anim *a_info, int x, int y, int max_x = -1, int max_y = -1);
anim_instance *anim_play(anim_play_struct *aps);
void anim_ignore_next_frametime();
int anim_stop_playing(anim_instance* anim_instance);
+66 -203
View File
@@ -15,8 +15,6 @@
#include "anim/animplay.h"
const int packer_code = PACKER_CODE;
const int transparent_code = 254;
@@ -51,6 +49,7 @@ anim_instance *init_anim_instance(anim *ptr, int bpp)
ptr->instance_count++;
inst = (anim_instance *) vm_malloc(sizeof(anim_instance));
Assert(inst);
memset(inst, 0, sizeof(anim_instance));
inst->frame_num = -1;
inst->last_frame_num = -1;
inst->parent = ptr;
@@ -101,12 +100,7 @@ int anim_get_next_frame(anim_instance *inst)
return -1;
}
if (inst->parent->flags & ANF_XPARENT) {
// bitmap_flags = BMP_XPARENT;
bitmap_flags = 0;
} else {
bitmap_flags = 0;
}
bitmap_flags = 0;
bpp = 16;
if(inst->aa_color != NULL){
@@ -168,159 +162,16 @@ ubyte *anim_get_next_raw_buffer(anim_instance *inst, int xlate_pal, int aabitmap
return inst->frame;
}
// --------------------------------------------------------------------
// anim_get_frame()
//
// Get a bitmap id from the anim_instance for the specified frame_num
//
// input: *inst => pointer to anim instance
// frame_num => frame number to get (first frame is 0)
// xlate_pal => DEFAULT PARM (value 1): whether to translate the palette
// to the current game palette
//
int anim_get_frame(anim_instance *inst, int frame_num, int xlate_pal)
{
/*
int bm, bitmap_flags, key = 0, offset = 0;
int idx;
if ((frame_num < 0) || (frame_num >= inst->parent->total_frames)) // illegal frame number
return -1;
int need_reset = 0;
if ( anim_instance_is_streamed(inst) ) {
if ( inst->file_offset < 0 ) {
need_reset = 1;
}
} else {
if ( !inst->data ) {
need_reset = 1;
}
}
if (need_reset || (inst->frame_num >= inst->parent->total_frames)) { // reset to valid info
inst->data = inst->parent->data;
inst->file_offset = inst->parent->file_offset;
inst->frame_num = 0;
}
bitmap_flags = 0;
if (inst->parent->flags & ANF_XPARENT) {
// bitmap_flags = BMP_XPARENT;
bitmap_flags = 0;
}
if ( inst->frame_num == frame_num ) {
bm = bm_create(16, inst->parent->width, inst->parent->height, inst->frame, bitmap_flags);
bm_unload(bm);
return bm;
}
if (inst->parent->flags & ANF_XPARENT){
// bitmap_flags = BMP_XPARENT;
bitmap_flags = 0;
} else {
bitmap_flags = 0;
}
idx = 0;
key = 0;
while(idx < inst->parent->num_keys){
if (( (inst->parent->keys[idx].frame_num-1) <= frame_num) && ( (inst->parent->keys[idx].frame_num-1) > key)) { // find closest key
key = inst->parent->keys[idx].frame_num - 1;
offset = inst->parent->keys[idx].offset;
if ( key == frame_num )
break;
}
idx++;
}
if ( key == frame_num ) {
inst->frame_num = key;
if ( anim_instance_is_streamed(inst) ) {
inst->file_offset = inst->parent->file_offset + offset;
} else {
inst->data = inst->parent->data + offset;
}
anim_check_for_palette_change(inst);
if ( anim_instance_is_streamed(inst) ) {
if ( xlate_pal ){
inst->file_offset = unpack_frame_from_file(inst, inst->frame, inst->parent->width*inst->parent->height, inst->parent->palette_translation);
} else {
inst->file_offset = unpack_frame_from_file(inst, inst->frame, inst->parent->width*inst->parent->height, NULL);
}
} else {
if ( xlate_pal ){
inst->data = unpack_frame(inst, inst->data, inst->frame, inst->parent->width*inst->parent->height, inst->parent->palette_translation);
} else {
inst->data = unpack_frame(inst, inst->data, inst->frame, inst->parent->width*inst->parent->height, NULL);
}
}
goto create_bitmap;
}
if (key > inst->frame_num) // best key is closer than current position
{
inst->frame_num = key;
if ( anim_instance_is_streamed(inst) ) {
inst->file_offset = inst->parent->file_offset + offset;
} else {
inst->data = inst->parent->data + offset;
}
anim_check_for_palette_change(inst);
if ( anim_instance_is_streamed(inst) ) {
if ( xlate_pal )
inst->file_offset = unpack_frame_from_file(inst, inst->frame, inst->parent->width*inst->parent->height, inst->parent->palette_translation);
else
inst->file_offset = unpack_frame_from_file(inst, inst->frame, inst->parent->width*inst->parent->height, NULL);
} else {
if ( xlate_pal )
inst->data = unpack_frame(inst, inst->data, inst->frame, inst->parent->width*inst->parent->height, inst->parent->palette_translation);
else
inst->data = unpack_frame(inst, inst->data, inst->frame, inst->parent->width*inst->parent->height, NULL);
}
}
while (inst->frame_num != frame_num) {
anim_check_for_palette_change(inst);
if ( anim_instance_is_streamed(inst) ) {
if ( xlate_pal )
inst->file_offset = unpack_frame_from_file(inst, inst->frame, inst->parent->width*inst->parent->height, inst->parent->palette_translation);
else
inst->file_offset = unpack_frame_from_file(inst, inst->frame, inst->parent->width*inst->parent->height, NULL);
} else {
if ( xlate_pal )
inst->data = unpack_frame(inst, inst->data, inst->frame, inst->parent->width*inst->parent->height, inst->parent->palette_translation);
else
inst->data = unpack_frame(inst, inst->data, inst->frame, inst->parent->width*inst->parent->height, NULL);
}
inst->frame_num++;
}
create_bitmap:
bm = bm_create(16, inst->parent->width, inst->parent->height, inst->frame, bitmap_flags);
bm_unload(bm);
return bm;
*/
Int3();
return -1;
}
// frame = frame pixel data to pack
// save = memory to store packed data to
// size = number of bytes to pack
// max = maximum number of packed bytes (size of buffer)
// returns: actual number of bytes data packed to or -1 if error
/**
* @brief Pack key frame
*
* @param frame Frame pixel data to pack
* @param save Memory to store packed data to
* @param size Number of bytes to pack
* @param max Maximum number of packed bytes (size of buffer)
* @param compress_type Compress type
* @return Actual number of bytes data packed to or -1 if error
*/
int pack_key_frame(ubyte *frame, ubyte *save, long size, long max, int compress_type)
{
int last = -32768, count = 0;
@@ -405,14 +256,12 @@ int pack_key_frame(ubyte *frame, ubyte *save, long size, long max, int compress_
*save++ = (ubyte)last;
packed_size++;
Assert( last != STD_RLE_CODE );
// printf("Just packed %d 1 times, since pixel change, no count included\n",last);
}
else {
count |= STD_RLE_CODE;
*save++ = (ubyte)count;
*save++ = (ubyte)last;
packed_size += 2;
// printf("Just packed %d %d times, since pixel change\n",last,count);
}
}
@@ -429,8 +278,6 @@ int pack_key_frame(ubyte *frame, ubyte *save, long size, long max, int compress_
*save++ = (ubyte)last;
packed_size += 2;
count = 0;
// printf("Just packed %d %d times, since count overflow\n",last,count);
}
} // end for
@@ -442,7 +289,6 @@ int pack_key_frame(ubyte *frame, ubyte *save, long size, long max, int compress_
if ( (count == 1) && !(last & STD_RLE_CODE) ) {
*save++ = (ubyte)last;
packed_size++;
// printf("Just packed %d 1 times, at end since single pixel, no count\n",last);
Assert( last != STD_RLE_CODE );
}
else {
@@ -450,7 +296,6 @@ int pack_key_frame(ubyte *frame, ubyte *save, long size, long max, int compress_
*save++ = (ubyte)count;
*save++ = (ubyte)last;
packed_size += 2;
// printf("Just packed %d %d times, at end since pixel change\n",last,count);
}
}
@@ -468,12 +313,17 @@ int pack_key_frame(ubyte *frame, ubyte *save, long size, long max, int compress_
return packed_size;
}
// frame = frame pixel data to pack
// frame2 = previous frame's pixel data
// save = memory to store packed data to
// size = number of bytes to pack
// max = maximum number of packed bytes (size of buffer)
// returns: actual number of bytes data packed to or -1 if error
/**
* @brief Pack frame
*
* @param frame Frame pixel data to pack
* @param frame2 Previous frame's pixel data
* @param save Memory to store packed data to
* @param size Number of bytes to pack
* @param max Maximum number of packed bytes (size of buffer)
* @param compress_type Compress type
* @return Actual number of bytes data packed to or -1 if error
*/
int pack_frame(ubyte *frame, ubyte *frame2, ubyte *save, long size, long max, int compress_type)
{
int pixel, last = -32768, count = 0, i;
@@ -629,7 +479,11 @@ int pack_frame(ubyte *frame, ubyte *frame2, ubyte *save, long size, long max, in
return packed_size;
}
// convert a 24 bit value to a 16 bit value
/**
* @brief Convert a 24 bit value to a 16 bit value
* @param bit_24 24 bit value
* @param bit_16 16 bit value (output)
*/
void convert_24_to_16(int bit_24, ushort *bit_16)
{
ubyte *pixel = (ubyte*)&bit_24;
@@ -638,7 +492,10 @@ void convert_24_to_16(int bit_24, ushort *bit_16)
bm_set_components((ubyte*)bit_16, (ubyte*)&pixel[0], (ubyte*)&pixel[1], (ubyte*)&pixel[2], &alpha);
}
// unpack a pixel given the passed index and the anim_instance's palette, return bytes stuffed
/**
* @brief Unpack a pixel given the passed index and the anim_instance's palette
* @return Bytes stuffed
*/
int unpack_pixel(anim_instance *ai, ubyte *data, ubyte pix, int aabitmap, int bpp)
{
int bit_24;
@@ -687,7 +544,7 @@ int unpack_pixel(anim_instance *ai, ubyte *data, ubyte pix, int aabitmap, int bp
}
} else {
// stuff the 24 bit value
memcpy(&bit_24, &ai->parent->palette[pix * 3], 3);
memcpy(&bit_24, &ai->parent->palette[pix * 3], 3); //-V512
// convert to 16 bit
convert_24_to_16(bit_24, &bit_16);
@@ -718,7 +575,10 @@ int unpack_pixel(anim_instance *ai, ubyte *data, ubyte pix, int aabitmap, int bp
return pixel_size;
}
// unpack a pixel given the passed index and the anim_instance's palette, return bytes stuffed
/**
* @brief Unpack a pixel given the passed index and the anim_instance's palette
* @return Bytes stuffed
*/
int unpack_pixel_count(anim_instance *ai, ubyte *data, ubyte pix, int count = 0, int aabitmap = 0, int bpp = 8)
{
int bit_24;
@@ -768,7 +628,7 @@ int unpack_pixel_count(anim_instance *ai, ubyte *data, ubyte pix, int count = 0,
}
} else {
// stuff the 24 bit value
memcpy(&bit_24, &ai->parent->palette[pix * 3], 3);
memcpy(&bit_24, &ai->parent->palette[pix * 3], 3); //-V512
// convert to 16 bit
convert_24_to_16(bit_24, &bit_16);
@@ -797,10 +657,17 @@ int unpack_pixel_count(anim_instance *ai, ubyte *data, ubyte pix, int count = 0,
return (pixel_size * count);
}
// ptr = packed data to unpack
// frame = where to store unpacked data to
// size = total number of unpacked pixels requested
// pal_translate = color translation lookup table (NULL if no palette translation desired)
/**
* @brief Unpack frame
*
* @param ai Animation instance
* @param ptr Packed data to unpack
* @param frame Where to store unpacked data to
* @param size Total number of unpacked pixels requested
* @param pal_translate Color translation lookup table (NULL if no palette translation desired)
* @param aabitmap
* @param bpp
*/
ubyte *unpack_frame(anim_instance *ai, ubyte *ptr, ubyte *frame, int size, ubyte *pal_translate, int aabitmap, int bpp)
{
int xlate_pal, value, count = 0;
@@ -883,9 +750,6 @@ ubyte *unpack_frame(anim_instance *ai, ubyte *ptr, ubyte *frame, int size, ubyte
}
}
else if (*ptr == PACKING_METHOD_RLE) { // normal frame, Hoffoss's RLE format
// test code, to show unused pixels
// memset(frame, 255, size);
ptr++;
while (size > 0) {
@@ -976,17 +840,23 @@ ubyte *unpack_frame(anim_instance *ai, ubyte *ptr, ubyte *frame, int size, ubyte
}
}
else {
// Assert(0); // unknown packing method
// unknown packing method
return NULL;
}
return ptr;
}
// ptr = packed data to unpack
// frame = where to store unpacked data to
// size = total number of unpacked pixels requested
// pal_translate = color translation lookup table (NULL if no palette translation desired)
/**
* @brief Unpack frame from file
*
* @param ai Animation instance
* @param frame Where to store unpacked data to
* @param size Total number of unpacked pixels requested
* @param pal_translate Color translation lookup table (NULL if no palette translation desired)
* @param aabitmap
* @param bpp
*/
int unpack_frame_from_file(anim_instance *ai, ubyte *frame, int size, ubyte *pal_translate, int aabitmap, int bpp)
{
int xlate_pal, value, count = 0;
@@ -1076,9 +946,6 @@ int unpack_frame_from_file(anim_instance *ai, ubyte *frame, int size, ubyte *pal
}
}
else if (anim_instance_get_byte(ai,offset) == PACKING_METHOD_RLE) { // normal frame, Hoffoss's RLE format
// test code, to show unused pixels
// memset(frame, 255, size);
offset++;
while (size > 0) {
@@ -1173,7 +1040,7 @@ int unpack_frame_from_file(anim_instance *ai, ubyte *frame, int size, ubyte *pal
}
}
else {
// Int3(); // unknown packing method
// unknown packing method
return -1;
}
@@ -1181,21 +1048,17 @@ int unpack_frame_from_file(anim_instance *ai, ubyte *frame, int size, ubyte *pal
}
// TODO: actually convert the frame data to correct palette at this point
/**
* @brief Set animation palette
* @todo Actually convert the frame data to correct palette at this point
*/
void anim_set_palette(anim *ptr)
{
int i, xparent_found = 0;
// create the palette translation look-up table
for ( i = 0; i < 256; i++ ) {
//if ( (ptr->palette[i*3] == ptr->xparent_r) && (ptr->palette[i*3+1] == ptr->xparent_g) && (ptr->palette[i*3+2] == ptr->xparent_b) ) {
// ptr->palette_translation[i] = 255;
// xparent_found = 1;
//} else {
// ptr->palette_translation[i] = (ubyte)palette_find( ptr->palette[i*3], ptr->palette[i*3+1], ptr->palette[i*3+2] );
ptr->palette_translation[i] = (ubyte)i;
//}
ptr->palette_translation[i] = (ubyte)i;
}
if ( xparent_found ) {
+6 -6
View File
@@ -18,11 +18,11 @@ struct CFILE;
#define ANI_STREAM_CACHE_SIZE 4096
#define PACKER_CODE 0xEE // Use'd by PACKING_METHOD_RLE
#define PACKING_METHOD_RLE 0 // Hoffoss's RLE format
#define PACKING_METHOD_RLE_KEY 1 // Hoffoss's key frame RLE format
#define PACKING_METHOD_STD_RLE 2 // Standard RLE format (high bit is count)
#define PACKING_METHOD_STD_RLE_KEY 3 // Standard RLE format key frame
#define PACKER_CODE 0xEE /// Used by PACKING_METHOD_RLE
#define PACKING_METHOD_RLE 0 /// Hoffoss's RLE format
#define PACKING_METHOD_RLE_KEY 1 /// Hoffoss's key frame RLE format
#define PACKING_METHOD_STD_RLE 2 /// Standard RLE format (high bit is count)
#define PACKING_METHOD_STD_RLE_KEY 3 /// Standard RLE format key frame
#define STD_RLE_CODE 0x80
@@ -71,6 +71,7 @@ typedef struct anim {
typedef struct anim_instance {
anim_instance *next, *prev;
int x,y; // coordinates anim is played at (top left corner of anim)
int base_w, base_h; // coordinate scale this anim is played in.
vec3d *world_pos; // world (x,y,z) position of explosion
float radius; // radius of image, needed for scaling
int frame_num; // current frame, or last frame if between frames (first frame is 0)
@@ -106,7 +107,6 @@ void anim_init();
anim_instance *init_anim_instance(anim *ptr, int bpp);
void free_anim_instance(anim_instance *inst);
int anim_get_next_frame(anim_instance *inst);
int anim_get_frame(anim_instance *inst, int frame_num, int xlate_pal=1);
ubyte *anim_get_next_raw_buffer(anim_instance *inst, int xlate_pal, int aabitmap, int bpp);
void anim_set_palette(anim *a);
void anim_check_for_palette_change(anim_instance *inst);
+197 -201
View File
@@ -9,7 +9,6 @@
#include "asteroid/asteroid.h"
#include "object/object.h"
#include "object/objcollide.h"
@@ -42,10 +41,6 @@
#include "parse/scripting.h"
//WMC - we want asteroid ability with demo!!
//#ifndef FS2_DEMO
#define ASTEROID_OBJ_USED (1<<0) // flag used in asteroid_obj struct
#define MAX_ASTEROID_OBJS MAX_ASTEROIDS // max number of asteroids tracked in asteroid list
asteroid_obj Asteroid_objs[MAX_ASTEROID_OBJS]; // array used to store asteroid object indexes
@@ -73,7 +68,9 @@ static float Asteroid_impact_explosion_radius;
#define ASTEROID_UPDATE_COLLIDE_TIMESTAMP 2000 // how often asteroid is checked for impending collisions with escort ships
#define ASTEROID_MIN_COLLIDE_TIME 24 // time in seconds to check for asteroid colliding
// Force updating of pair stuff for asteroid *objp.
/**
* Force updating of pair stuff for asteroid *objp.
*/
void asteroid_update_collide(object *objp)
{
// Asteroid has wrapped, update collide objnum and flags
@@ -82,8 +79,9 @@ void asteroid_update_collide(object *objp)
OBJ_RECALC_PAIRS(objp);
}
// Clear out the Asteroid_obj_list
//
/**
* Clear out the ::Asteroid_obj_list
*/
void asteroid_obj_list_init()
{
int i;
@@ -94,11 +92,10 @@ void asteroid_obj_list_init()
}
}
// ---------------------------------------------------
// asteroid_obj_list_add()
//
// Function to add a node from the Asteroid_obj_list. Only
// called from weapon_create()
/**
* Add a node from the Asteroid_obj_list.
* Only called from ::weapon_create()
*/
int asteroid_obj_list_add(int objnum)
{
int index;
@@ -117,11 +114,10 @@ int asteroid_obj_list_add(int objnum)
return index;
}
// ---------------------------------------------------
// missle_obj_list_remove()
//
// Function to remove a node from the Asteroid_obj_list. Only
// called from weapon_delete()
/**
* Remove a node from the Asteroid_obj_list.
* Only called from ::weapon_delete()
*/
void asteroid_obj_list_remove(object * obj)
{
int index = obj->instance;
@@ -134,7 +130,9 @@ void asteroid_obj_list_remove(object * obj)
}
// Prevent speed from getting too huge so it's hard to catch up to an asteroid.
/**
* Prevent speed from getting too huge so it's hard to catch up to an asteroid.
*/
float asteroid_cap_speed(int asteroid_info_index, float speed)
{
float max, double_max;
@@ -155,9 +153,12 @@ float asteroid_cap_speed(int asteroid_info_index, float speed)
return speed;
}
// Returns whether position is inside inner bounding volume
// sum together the following: 1 inside x, 2 inside y, 4 inside z
// inside only when sum = 7
/**
* Returns whether position is inside inner bounding volume
*
* Sum together the following: 1 inside x, 2 inside y, 4 inside z
* inside only when sum = 7
*/
int asteroid_in_inner_bound_with_axes(asteroid_field *asfieldp, vec3d *pos, float delta)
{
Assert(asfieldp->has_inner_bound);
@@ -178,8 +179,10 @@ int asteroid_in_inner_bound_with_axes(asteroid_field *asfieldp, vec3d *pos, floa
return rval;
}
// check if asteroid is within inner bound
// return 0 if not inside or no inner bound, 1 if inside inner bound
/**
* Check if asteroid is within inner bound
* @return 0 if not inside or no inner bound, 1 if inside inner bound
*/
int asteroid_in_inner_bound(asteroid_field *asfieldp, vec3d *pos, float delta) {
if (!asfieldp->has_inner_bound) {
@@ -189,8 +192,11 @@ int asteroid_in_inner_bound(asteroid_field *asfieldp, vec3d *pos, float delta) {
return (asteroid_in_inner_bound_with_axes(asfieldp, pos, delta) == 7);
}
// repositions asteroid outside the inner box on all 3 axes
// moves to the other side of the inner box a distance delta from edge of box
/**
* Repositions asteroid outside the inner box on all 3 axes
*
* Moves to the other side of the inner box a distance delta from edge of box
*/
void inner_bound_pos_fixup(asteroid_field *asfieldp, vec3d *pos)
{
if (!asteroid_in_inner_bound(asfieldp, pos, 0)) {
@@ -213,8 +219,9 @@ void inner_bound_pos_fixup(asteroid_field *asfieldp, vec3d *pos)
}
}
// Create a single asteroid
/**
* Create a single asteroid
*/
object *asteroid_create(asteroid_field *asfieldp, int asteroid_type, int asteroid_subtype)
{
int n, objnum;
@@ -289,7 +296,6 @@ object *asteroid_create(asteroid_field *asfieldp, int asteroid_type, int asteroi
pos.xyz.z = asfieldp->min_bound.xyz.z + delta_bound.xyz.z * frand();
inner_bound_pos_fixup(asfieldp, &pos);
// vm_set_identity(&orient);
angs.p = frand() * PI2;
angs.b = frand() * PI2;
angs.h = frand() * PI2;
@@ -302,7 +308,6 @@ object *asteroid_create(asteroid_field *asfieldp, int asteroid_type, int asteroi
pos.xyz.z = asfieldp->min_bound.xyz.z + delta_bound.xyz.z * static_randf( rand_base++ );
inner_bound_pos_fixup(asfieldp, &pos);
// vm_set_identity(&orient);
angs.p = static_randf( rand_base++ ) * PI2;
angs.b = static_randf( rand_base++ ) * PI2;
angs.h = static_randf( rand_base++ ) * PI2;
@@ -311,7 +316,6 @@ object *asteroid_create(asteroid_field *asfieldp, int asteroid_type, int asteroi
vm_angles_2_matrix(&orient, &angs);
objnum = obj_create( OBJ_ASTEROID, -1, n, &orient, &pos, radius, OF_RENDERS | OF_PHYSICS | OF_COLLIDES);
// mprintf(("Framecount: %d asteroid create: obj = %d\n", Framecount, objnum));
if ( (objnum == -1) || (objnum >= MAX_OBJECTS) ) {
mprintf(("Couldn't create asteroid -- out of object slots\n"));
@@ -381,13 +385,12 @@ object *asteroid_create(asteroid_field *asfieldp, int asteroid_type, int asteroi
// ensure vel is valid
Assert( !vm_is_vec_nan(&objp->phys_info.vel) );
// assign a persistant sound to the asteroid
// obj_snd_assign(objnum, SND_ASTEROID);
return objp;
}
// Create asteroids when parent_objp blows up.
/**
* Create asteroids when parent_objp blows up.
*/
void asteroid_sub_create(object *parent_objp, int asteroid_type, vec3d *relvec)
{
object *new_objp;
@@ -424,16 +427,14 @@ void asteroid_sub_create(object *parent_objp, int asteroid_type, vec3d *relvec)
new_objp->phys_info.desired_vel = new_objp->phys_info.vel;
vm_vec_scale_add(&new_objp->last_pos, &new_objp->pos, &new_objp->phys_info.vel, -flFrametime);
// DA: 4/22/98 We get next line for free when new object (in obj_create_list) is merged.
// this line gives too many collision pairs.
// asteroid_update_collide(new_objp);
}
// Load in an asteroid model
/**
* Load in an asteroid model
*/
void asteroid_load(int asteroid_info_index, int asteroid_subtype)
{
asteroid_info *asip;
// int pof_index;
Assert( asteroid_info_index < (int)Asteroid_info.size() );
Assert( asteroid_subtype < NUM_DEBRIS_POFS );
@@ -444,16 +445,6 @@ void asteroid_load(int asteroid_info_index, int asteroid_subtype)
asip = &Asteroid_info[asteroid_info_index];
// pick one of MAX_ASTEROID_POFS models
// LOAD ALL TEXTURES USED
// static int asteroid_pof_index = rand() % MAX_ASTEROID_POFS;
// if (Asteroid_field.debris_genre == DG_ASTEROID) {
// pof_index = asteroid_pof_index;
// } else {
// // only 1 pof for ship debris type
// pof_index = 0;
// }
if ( !VALID_FNAME(asip->pof_files[asteroid_subtype]) )
return;
@@ -469,7 +460,9 @@ void asteroid_load(int asteroid_info_index, int asteroid_subtype)
}
}
// randomly choose a debris model within the current group
/**
* Randomly choose a debris model within the current group
*/
int get_debris_from_same_group(int index) {
int group_base, group_offset;
@@ -481,8 +474,11 @@ int get_debris_from_same_group(int index) {
return group_base + ((group_offset + rand()%(NUM_DEBRIS_SIZES-1) + 1) % NUM_DEBRIS_SIZES);
}
// returns a weight that depends on asteroid size.
// the weight is then used to determine the frequencty of different sizes of ship debris
/**
* Returns a weight that depends on asteroid size.
*
* The weight is then used to determine the frequencty of different sizes of ship debris
*/
int get_debris_weight(int ship_debris_index)
{
int size = ship_debris_index % NUM_DEBRIS_SIZES;
@@ -503,7 +499,9 @@ int get_debris_weight(int ship_debris_index)
}
}
// Create all the asteroids for the mission, called from
/**
* Create all the asteroids for the mission
*/
void asteroid_create_all()
{
int i, idx;
@@ -600,17 +598,26 @@ void asteroid_create_all()
}
}
// Init asteriod system for the level, called from game_level_init()
/**
* Init asteriod system for the level, called from ::game_level_init()
*/
void asteroid_level_init()
{
Asteroid_field.num_initial_asteroids=0;
Num_asteroids = 0;
Next_asteroid_throw = timestamp(1);
asteroid_obj_list_init();
SCP_vector<asteroid_info>::iterator ast;
for (ast = Asteroid_info.begin(); ast != Asteroid_info.end(); ++ast)
ast->damage_type_idx = ast->damage_type_idx_sav;
}
// return !0 if asteroid should be wrapped, 0 otherwise. Multiplayer clients will always return
// 0 from this function. We will force a wrap on the clients when server tells us
/**
* Should asteroid wrap from one end of the asteroid field to the other.
* Multiplayer clients will always return 0 from this function. We will force a wrap on the clients when server tells us
*
* @return !0 if asteroid should be wrapped, 0 otherwise.
*/
int asteroid_should_wrap(object *objp, asteroid_field *asfieldp)
{
if ( MULTIPLAYER_CLIENT )
@@ -653,7 +660,9 @@ int asteroid_should_wrap(object *objp, asteroid_field *asfieldp)
return 0;
}
// Wrap an asteroid from one end of the asteroid field to the other
/**
* Wrap an asteroid from one end of the asteroid field to the other
*/
void asteroid_wrap_pos(object *objp, asteroid_field *asfieldp)
{
if (objp->pos.xyz.x < asfieldp->min_bound.xyz.x) {
@@ -686,7 +695,11 @@ void asteroid_wrap_pos(object *objp, asteroid_field *asfieldp)
}
// return !0 if this asteroid is a target for any ship, otherwise return 0
/**
* Is asteroid targeted?
*
* @return !0 if this asteroid is a target for any ship, otherwise return 0
*/
int asteroid_is_targeted(object *objp)
{
ship_obj *so;
@@ -705,7 +718,9 @@ int asteroid_is_targeted(object *objp)
return 0;
}
// Create an asteroid that will hit object *objp in delta_time seconds
/**
* Create an asteroid that will hit object *objp in delta_time seconds
*/
void asteroid_aim_at_target(object *objp, object *asteroid_objp, float delta_time)
{
vec3d predicted_center_pos;
@@ -729,8 +744,11 @@ void asteroid_aim_at_target(object *objp, object *asteroid_objp, float delta_tim
vm_vec_scale_add(&asteroid_objp->last_pos, &asteroid_objp->pos, &asteroid_objp->phys_info.vel, -flFrametime);
}
// Call once per frame to maybe throw an asteroid at a ship.
// "count" asteroids already targeted on
/**
* Call once per frame to maybe throw an asteroid at a ship.
*
* @param count asteroids already targeted on
*/
void maybe_throw_asteroid(int count)
{
if (!timestamp_elapsed(Next_asteroid_throw)) {
@@ -765,9 +783,6 @@ void maybe_throw_asteroid(int count)
objp->flags |= OF_SHOULD_BE_DEAD;
} else {
Asteroids[objp->instance].target_objnum = so->objnum;
// DA: 4/22/98 We get next line for free when new object (in obj_create_list) is merged.
// this line gives too many collision pairs.
// asteroid_update_collide(objp);
if ( MULTIPLAYER_MASTER ) {
send_asteroid_throw( objp );
@@ -781,6 +796,9 @@ void maybe_throw_asteroid(int count)
}
/**
* Delete asteroid from Asteroid_used_list
*/
void asteroid_delete( object * obj )
{
int num;
@@ -796,12 +814,13 @@ void asteroid_delete( object * obj )
asp->flags = 0;
Num_asteroids--;
// Delete asteroid from Asteroid_used_list
asteroid_obj_list_remove( obj );
}
// See if we should reposition the asteroid. Only reposition if oustide the bounding volume and
// the player isn't looking towards the asteroid.
/**
* See if we should reposition the asteroid.
* Only reposition if oustide the bounding volume and the player isn't looking towards the asteroid.
*/
void asteroid_maybe_reposition(object *objp, asteroid_field *asfieldp)
{
// passive field does not wrap
@@ -816,8 +835,6 @@ void asteroid_maybe_reposition(object *objp, asteroid_field *asfieldp)
old_asteroid_pos = objp->pos;
old_vel = objp->phys_info.vel;
//nprintf(("AI", "Frame %i, reposition #%i\n", Framecount, objp-Objects));
// don't wrap asteroid if it is a target of some ship
if ( !asteroid_is_targeted(objp) ) {
@@ -866,13 +883,6 @@ void lerp(float *goal, float f1, float f2, float scale)
void asteroid_process_pre( object *objp, float frame_time)
{
if (Asteroids_enabled) {
// vec3d *v, *vv;
// v = &objp->phys_info.vel;
// vv = &objp->phys_info.desired_vel;
//nprintf(("AI", "Frm %i: Obj #%2i: Hull: %5.1f Vel: %5.1f %5.1f %5.1f Des: %5.1f %5.1f %5.1f\n", Framecount, objp-Objects, objp->hull_strength, v->xyz.x, v->xyz.y, v->xyz.z, vv->xyz.x, vv->xyz.y, vv->xyz.z));
// Make vel chase desired_vel
lerp(&objp->phys_info.vel.xyz.x, objp->phys_info.vel.xyz.x, objp->phys_info.desired_vel.xyz.x, flFrametime);
lerp(&objp->phys_info.vel.xyz.y, objp->phys_info.vel.xyz.y, objp->phys_info.desired_vel.xyz.y, flFrametime);
@@ -901,6 +911,7 @@ int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos
if ( asteroid_hit_info == NULL ) {
// asteroid weapon collision
Assert( other_obj->type == OBJ_WEAPON );
mc.model_instance_num = -1;
mc.model_num = Asteroid_info[Asteroids[num].asteroid_type].model_num[asteroid_subtype]; // Fill in the model to check
model_clear_instance( mc.model_num );
mc.orient = &pasteroid->orient; // The object's orient
@@ -948,7 +959,6 @@ int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos
vm_vec_scale( &asteroid_hit_info->light_rel_vel, 1/flFrametime );
// HACK - this applies to big ships warping in/out of asteroid fields - not sure what it does
if (vm_vec_mag(&asteroid_hit_info->light_rel_vel) > 300) {
// nprintf(("Physics", "Asteroid type %d\n", Asteroids[asteroid_hit_info->light->instance].type));
asteroid_hit_info->collide_rotate = 0;
vm_vec_sub( &asteroid_hit_info->light_rel_vel, &light->phys_info.vel, &heavy->phys_info.vel );
}
@@ -960,6 +970,7 @@ int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos
int mc_ret_val = 0;
if ( asteroid_hit_info->heavy == ship_obj ) { // ship is heavier, so asteroid is sphere. Check sphere collision against ship poly model
mc.model_instance_num = Ships[ship_obj->instance].model_instance_num;
mc.model_num = Ship_info[Ships[ship_obj->instance].ship_info_index].model_num; // Fill in the model to check
mc.orient = &ship_obj->orient; // The object's orient
mc.radius = pasteroid->radius;
@@ -974,11 +985,9 @@ int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos
// first test against the sphere - if this fails then don't do any submodel tests
mc.flags = MC_ONLY_SPHERE | MC_CHECK_SPHERELINE;
int submodel_list[MAX_ROTATING_SUBMODELS];
int num_rotating_submodels = 0;
SCP_vector<int> submodel_vector;
polymodel *pm;
ship_model_start(ship_obj);
polymodel_instance *pmi;
if (model_collide(&mc)) {
@@ -988,15 +997,15 @@ int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos
// Do collision the cool new way
if ( asteroid_hit_info->collide_rotate ) {
// We collide with the sphere, find the list of rotating submodels and test one at a time
model_get_rotating_submodel_list(submodel_list, &num_rotating_submodels, heavy_obj);
model_get_rotating_submodel_list(&submodel_vector, heavy_obj);
// Get polymodel and turn off all rotating submodels, collide against only 1 at a time.
pm = model_get(Ship_info[Ships[heavy_obj->instance].ship_info_index].model_num);
pmi = model_get_instance(Ships[ship_obj->instance].model_instance_num);
// turn off all rotating submodels and test for collision
int i;
for (i=0; i<num_rotating_submodels; i++) {
pm->submodel[submodel_list[i]].blown_off = 1;
for (size_t j=0; j<submodel_vector.size(); j++) {
pmi->submodel[submodel_vector[j]].collision_checked = true;
}
// reset flags to check MC_CHECK_MODEL | MC_CHECK_SPHERELINE and maybe MC_CHECK_INVISIBLE_FACES and MC_SUBMODEL_INSTANCE
@@ -1004,26 +1013,25 @@ int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos
// check each submodel in turn
for (i=0; i<num_rotating_submodels; i++) {
for (size_t i=0; i<submodel_vector.size(); i++) {
// turn on submodel for collision test
pm->submodel[submodel_list[i]].blown_off = 0;
pmi->submodel[submodel_vector[i]].collision_checked = false;
// set angles for last frame (need to set to prev to get p0)
angles copy_angles = pm->submodel[submodel_list[i]].angs;
angles copy_angles = pmi->submodel[submodel_vector[i]].angs;
// find the start and end positions of the sphere in submodel RF
pm->submodel[submodel_list[i]].angs = pm->submodel[submodel_list[i]].sii->prev_angs;
world_find_model_point(&p0, &light_obj->last_pos, pm, submodel_list[i], &heavy_obj->last_orient, &heavy_obj->last_pos);
pmi->submodel[submodel_vector[i]].angs = pmi->submodel[submodel_vector[i]].prev_angs;
world_find_model_instance_point(&p0, &light_obj->last_pos, pm, pmi, submodel_vector[i], &heavy_obj->last_orient, &heavy_obj->last_pos);
pm->submodel[submodel_list[i]].angs = copy_angles;
world_find_model_point(&p1, &light_obj->pos, pm, submodel_list[i], &heavy_obj->orient, &heavy_obj->pos);
pmi->submodel[submodel_vector[i]].angs = copy_angles;
world_find_model_instance_point(&p1, &light_obj->pos, pm, pmi, submodel_vector[i], &heavy_obj->orient, &heavy_obj->pos);
mc.p0 = &p0;
mc.p1 = &p1;
// mc.pos = zero // in submodel RF
mc.orient = &vmd_identity_matrix;
mc.submodel_num = submodel_list[i];
mc.submodel_num = submodel_vector[i];
if ( model_collide(&mc) ) {
if ( mc.hit_dist < asteroid_hit_info->hit_time ) {
@@ -1034,18 +1042,18 @@ int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos
// set up asteroid_hit_info for rotating submodel
if (asteroid_hit_info->edge_hit == 0) {
model_find_obj_dir(&asteroid_hit_info->collision_normal, &mc.hit_normal, heavy_obj, mc.hit_submodel);
model_instance_find_obj_dir(&asteroid_hit_info->collision_normal, &mc.hit_normal, heavy_obj, mc.hit_submodel);
}
// find position in submodel RF of light object at collison
vec3d int_light_pos, diff;
vm_vec_sub(&diff, mc.p1, mc.p0);
vm_vec_scale_add(&int_light_pos, mc.p0, &diff, mc.hit_dist);
model_find_world_point(&asteroid_hit_info->light_collision_cm_pos, &int_light_pos, mc.model_num, mc.hit_submodel, &heavy_obj->orient, &zero);
model_instance_find_world_point(&asteroid_hit_info->light_collision_cm_pos, &int_light_pos, mc.model_num, mc.model_instance_num, mc.hit_submodel, &heavy_obj->orient, &zero);
}
}
// Don't look at this submodel again
pm->submodel[submodel_list[i]].blown_off = 1;
pmi->submodel[submodel_vector[i]].collision_checked = true;
}
}
@@ -1066,7 +1074,7 @@ int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos
// get collision normal if not edge hit
if (asteroid_hit_info->edge_hit == 0) {
model_find_obj_dir(&asteroid_hit_info->collision_normal, &mc.hit_normal, heavy_obj, mc.hit_submodel);
model_instance_find_obj_dir(&asteroid_hit_info->collision_normal, &mc.hit_normal, heavy_obj, mc.hit_submodel);
}
// find position in submodel RF of light object at collison
@@ -1076,12 +1084,11 @@ int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos
}
}
ship_model_stop( ship_obj );
}
} else {
// Asteroid is heavier obj
mc.model_instance_num = -1;
mc.model_num = Asteroid_info[Asteroids[num].asteroid_type].model_num[asteroid_subtype]; // Fill in the model to check
model_clear_instance( mc.model_num );
mc.orient = &pasteroid->orient; // The object's orient
@@ -1156,7 +1163,9 @@ void asteroid_render(object * obj)
}
}
// Create a normalized vector generally in the direction from *hitpos to other_obj->pos
/**
* Create a normalized vector generally in the direction from *hitpos to other_obj->pos
*/
void asc_get_relvec(vec3d *relvec, object *other_obj, vec3d *hitpos)
{
vec3d tvec, rand_vec;
@@ -1176,7 +1185,9 @@ void asc_get_relvec(vec3d *relvec, object *other_obj, vec3d *hitpos)
vm_vec_normalize_quick(relvec);
}
// return multiplier on asteroid radius for fireball
/**
* Return multiplier on asteroid radius for fireball
*/
float asteroid_get_fireball_scale_multiplier(int num)
{
if (Asteroids[num].flags & AF_USED) {
@@ -1197,8 +1208,10 @@ float asteroid_get_fireball_scale_multiplier(int num)
}
// create asteroid explosion
// exit: expected time for explosion anim to last, in seconds
/**
* Create asteroid explosion
* @return expected time for explosion anim to last, in seconds
*/
float asteroid_create_explosion(object *objp)
{
int fireball_objnum;
@@ -1216,7 +1229,9 @@ float asteroid_create_explosion(object *objp)
return explosion_life;
}
// play sound when asteroid explodes
/**
* Play sound when asteroid explodes
*/
void asteriod_explode_sound(object *objp, int type, int play_loud)
{
int sound_index = -1;
@@ -1242,11 +1257,11 @@ void asteriod_explode_sound(object *objp, int type, int play_loud)
snd_play_3d( &Snds[sound_index], &objp->pos, &Eye_position, objp->radius, NULL, 0, 1.0f, SND_PRIORITY_MUST_PLAY, NULL, range_factor );
}
// asteroid_do_area_effect()
//
// Do the area effect for an asteroid exploding
//
// input: asteroid_objp => object pointer to asteriod causing explosion
/**
* Do the area effect for an asteroid exploding
*
* @param asteroid_objp object pointer to asteriod causing explosion
*/
void asteroid_do_area_effect(object *asteroid_objp)
{
object *ship_objp;
@@ -1278,12 +1293,14 @@ void asteroid_do_area_effect(object *asteroid_objp)
} // end for
}
// Asteroid asteroid_obj was hit.
// Apply damage. Maybe make it break into smaller asteroids.
// input: asteroid_obj => pointer to asteroid object getting hit
// other_obj => object that hit asteroid, can be NULL if asteroid hit by area effect
// hitpos => world position asteroid was hit, can be NULL if hit by area effect
// damage => amount of damage to apply to asteroid
/**
* Upon asteroid asteroid_obj being hit. Apply damage and maybe make it break into smaller asteroids.
*
* @param asteroid_obj pointer to asteroid object getting hit
* @param other_obj object that hit asteroid, can be NULL if asteroid hit by area effect
* @param hitpos world position asteroid was hit, can be NULL if hit by area effect
* @param damage amount of damage to apply to asteroid
*/
void asteroid_hit( object * asteroid_obj, object * other_obj, vec3d * hitpos, float damage )
{
float explosion_life;
@@ -1301,16 +1318,12 @@ void asteroid_hit( object * asteroid_obj, object * other_obj, vec3d * hitpos, fl
asteroid_obj->hull_strength -= damage;
//nprintf(("AI", "Asteroid collided with %s, hull = %.2f\n", Object_type_names[other_obj->type], asteroid_obj->hull_strength));
if (asteroid_obj->hull_strength < 0.0f) {
if ( asp->final_death_time <= 0 ) {
int play_loud_collision = 0;
explosion_life = asteroid_create_explosion(asteroid_obj);
if ( asp->collide_objnum == OBJ_INDEX(other_obj) ) {
// play_loud_collision = 1;
}
asteriod_explode_sound(asteroid_obj, asp->asteroid_type, play_loud_collision);
asteroid_do_area_effect(asteroid_obj);
@@ -1340,7 +1353,9 @@ void asteroid_hit( object * asteroid_obj, object * other_obj, vec3d * hitpos, fl
scoring_eval_hit(asteroid_obj,other_obj);
}
// De-init asteroids, called from game_level_close()
/**
* De-init asteroids, called from ::game_level_close()
*/
void asteroid_level_close()
{
int i;
@@ -1372,14 +1387,6 @@ DCF(asteroids,"Turns asteroids on/off")
if ( Dc_status )
dc_printf( "asteroids are %s\n", (Asteroids_enabled?"ON":"OFF") );
/*
if ((old_asteroids_enabled == 0) && (Asteroids_enabled == 1)) {
asteroid_init();
} else if ((old_asteroids_enabled == 1) && (Asteroids_enabled == 0)) {
asteroid_uninit();
}
*/
}
void hud_target_asteroid()
@@ -1411,14 +1418,18 @@ void hud_target_asteroid()
}
}
// Return the number of active asteroids
/**
* Return the number of active asteroids
*/
int asteroid_count()
{
return Num_asteroids;
}
// See if asteroid should split up. We delay splitting up to allow the explosion animation
// to play for a bit.
/**
* See if asteroid should split up.
* We delay splitting up to allow the explosion animation to play for a bit.
*/
void asteroid_maybe_break_up(object *asteroid_obj)
{
asteroid *asp;
@@ -1518,8 +1529,7 @@ void asteroid_test_collide(object *asteroid_obj, object *ship_obj, mc_info *mc,
Assert(ship_obj->type == OBJ_SHIP);
ship_model_start(ship_obj);
mc->model_instance_num = Ships[ship_obj->instance].model_instance_num;
mc->model_num = Ship_info[Ships[ship_obj->instance].ship_info_index].model_num; // Fill in the model to check
mc->orient = &ship_obj->orient; // The object's orientation
mc->pos = &ship_obj->pos; // The object's position
@@ -1534,7 +1544,8 @@ void asteroid_test_collide(object *asteroid_obj, object *ship_obj, mc_info *mc,
model_collide(mc);
ship_model_stop(ship_obj);
// PVS-Studio says that mc->p1 will become invalid... on the one hand, it will; on the other hand, we won't use it again; on the *other* other hand, we should keep things proper in case of future changes
mc->p1 = NULL;
}
// Return !0 is the asteroid will collide with the escort ship within ASTEROID_MIN_COLLIDE_TIME
@@ -1552,7 +1563,10 @@ int asteroid_will_collide(object *asteroid_obj, object *escort_objp)
return 1;
}
// return !0 if we should warn about asteroid hitting ship, otherwise return 0
/**
* Warn if asteroid on collision path with ship
* @return !0 if we should warn about asteroid hitting ship, otherwise return 0
*/
int asteroid_valid_ship_to_warn_collide(ship *shipp)
{
if ( !(Ship_info[shipp->ship_info_index].flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP)) ) {
@@ -1571,8 +1585,10 @@ int asteroid_valid_ship_to_warn_collide(ship *shipp)
return 1;
}
// See if asteroid will collide with a large ship on the escort list in the next
// ASTEROID_MIN_COLLIDE_TIME seconds.
/**
* See if asteroid will collide with a large ship on the escort list in the next
* ASTEROID_MIN_COLLIDE_TIME seconds.
*/
void asteroid_update_collide_flag(object *asteroid_objp)
{
int i, num_escorts, escort_objnum, will_collide=0;
@@ -1584,7 +1600,7 @@ void asteroid_update_collide_flag(object *asteroid_objp)
asp->collide_objsig = -1;
// multiplayer dogfight
if((Game_mode & GM_MULTIPLAYER) && (Netgame.type_flags & NG_TYPE_DOGFIGHT)){
if(MULTI_DOGFIGHT){
return;
}
@@ -1609,7 +1625,9 @@ void asteroid_update_collide_flag(object *asteroid_objp)
}
}
// ensure that the collide objnum for the asteroid is still valid
/**
* Ensure that the collide objnum for the asteroid is still valid
*/
void asteroid_verify_collide_objnum(asteroid *asp)
{
if ( asp->collide_objnum >= 0 ) {
@@ -1626,7 +1644,6 @@ void asteroid_process_post(object * obj, float frame_time)
int num;
num = obj->instance;
//Assert( Asteroids[num].objnum == objnum );
asteroid *asp = &Asteroids[num];
// Only wrap if active field
@@ -1648,13 +1665,19 @@ void asteroid_process_post(object * obj, float frame_time)
}
}
// return the object number that the asteroid is about to impact
/**
* Find the object number of the object the asteroid is about to impact
* @return the object number that the asteroid is about to impact
*/
int asteroid_collide_objnum(object *asteroid_objp)
{
return Asteroids[asteroid_objp->instance].collide_objnum;
}
// return the time until the asteroid will impact its collide_objnum
/**
* Find the time until asteroid will collide with object
* @return the time until the asteroid will impact its collide_objnum
*/
float asteroid_time_to_impact(object *asteroid_objp)
{
float time=-1.0f, total_dist, speed;
@@ -1681,7 +1704,9 @@ float asteroid_time_to_impact(object *asteroid_objp)
return time;
}
// read in a single asteroid section from asteroid.tbl
/**
* Read in a single asteroid section from asteroid.tbl
*/
void asteroid_parse_section(asteroid_info *asip)
{
required_string("$Name:");
@@ -1709,7 +1734,8 @@ void asteroid_parse_section(asteroid_info *asip)
if(optional_string("$Damage Type:")) {
char buf[NAME_LENGTH];
stuff_string(buf, F_NAME, NAME_LENGTH);
asip->damage_type_idx = damage_type_add(buf);
asip->damage_type_idx_sav = damage_type_add(buf);
asip->damage_type_idx = asip->damage_type_idx_sav;
}
required_string("$Expl inner rad:");
@@ -1728,7 +1754,9 @@ void asteroid_parse_section(asteroid_info *asip)
stuff_float(&asip->initial_asteroid_strength);
}
// read in data from asteroid.tbl into Asteroid_info[] array
/**
* Read in data from asteroid.tbl into Asteroid_info[] array
*/
void asteroid_parse_tbl()
{
char impact_ani_file[MAX_FILENAME_LEN];
@@ -1753,7 +1781,6 @@ void asteroid_parse_tbl()
memset(asteroid_tally, 0, sizeof(int) * (Species_info.size()+1));
while (required_string_either("#End","$Name:"))
{
asteroid_info new_asteroid;
@@ -1765,7 +1792,7 @@ void asteroid_parse_tbl()
Assert( Species_info.size() );
// sanity check for debris type sizes
for (i = Species_info.size(); i >= 0; i--) {
for (i = (int)Species_info.size(); i >= 0; i--) {
// must remain in proper order
// 0 - generic debris types
// > 0 - species specific debris types
@@ -1803,7 +1830,6 @@ void asteroid_parse_tbl()
// close localization
lcl_ext_close();
// check for any missing info
char *errormsg = new char[75 + (Species_info.size() * (NAME_LENGTH))];
bool species_missing = false;
@@ -1830,7 +1856,9 @@ void asteroid_parse_tbl()
delete[] errormsg;
}
// Return number of asteroids expected to collide with a ship.
/**
* Return number of asteroids expected to collide with a ship.
*/
int count_incident_asteroids()
{
object *asteroid_objp;
@@ -1851,8 +1879,10 @@ int count_incident_asteroids()
return count;
}
// Pick object to throw asteroids at.
// Pick any capital or big ship inside the bounds of the asteroid field.
/**
* Pick object to throw asteroids at.
* Pick any capital or big ship inside the bounds of the asteroid field.
*/
int set_asteroid_throw_objnum()
{
if (Asteroid_field.num_initial_asteroids < 1)
@@ -1895,7 +1925,9 @@ void asteroid_frame()
maybe_throw_asteroid(count_incident_asteroids());
}
// Called once, at game start. Do any one-time initializations here
/**
* Called once, at game start. Do any one-time initializations here
*/
void asteroid_init()
{
asteroid_parse_tbl();
@@ -1903,7 +1935,9 @@ void asteroid_init()
extern int Cmdline_targetinfo;
// Draw brackets around on-screen asteroids that are about to collide, otherwise draw an offscreen indicator
/**
* Draw brackets around on-screen asteroids that are about to collide, otherwise draw an offscreen indicator
*/
void asteroid_show_brackets()
{
vertex asteroid_vertex;
@@ -1935,28 +1969,17 @@ void asteroid_show_brackets()
g3_rotate_vertex(&asteroid_vertex,&asteroid_objp->pos);
g3_project_vertex(&asteroid_vertex);
if (!(asteroid_vertex.flags & PF_OVERFLOW)) {
gr_set_color_fast(iff_get_color(IFF_COLOR_SELECTION, 1));
hud_show_brackets(asteroid_objp, &asteroid_vertex);
if ( Cmdline_targetinfo ) {
hud_show_lead_indicator_quick(&asteroid_objp->pos, asteroid_objp);
}
}
// if asteroid is not on screen, draw an offscreen indicator
if ( hud_gauge_active(HUD_OFFSCREEN_INDICATOR) ) {
if (asteroid_vertex.codes != 0) {
float dist;
// dist = vm_vec_dist_quick(&Player_obj->pos, &asteroid_objp->pos);
dist = hud_find_target_distance( asteroid_objp, Player_obj );
gr_set_color_fast(iff_get_color(IFF_COLOR_SELECTION, 1));
hud_draw_offscreen_indicator(&asteroid_vertex, &asteroid_objp->pos, dist);
}
if ( Cmdline_targetinfo ) {
hud_target_add_display_list(asteroid_objp, &asteroid_vertex, &asteroid_objp->pos, 0, NULL, NULL, TARGET_DISPLAY_DIST | TARGET_DISPLAY_LEAD);
} else {
hud_target_add_display_list(asteroid_objp, &asteroid_vertex, &asteroid_objp->pos, 0, NULL, NULL, TARGET_DISPLAY_DIST);
}
}
}
// target the closest danger asteroid to the player
/**
* Target the closest danger asteroid to the player
*/
void asteroid_target_closest_danger()
{
object *asteroid_objp, *closest_asteroid_objp = NULL;
@@ -2041,30 +2064,3 @@ void asteroid_page_in()
}
}
}
/*
#else
// stubbed out functions not used in the demo
void asteroid_init() {}
void asteroid_level_init() {}
void asteroid_level_close() {}
void asteroid_create_all() {}
void asteroid_render( object *asteroid_objp ) {}
void asteroid_delete( object *asteroid_objp ) {}
void asteroid_process_pre( object *asteroid_objp, float frame_time) {}
void asteroid_process_post( object *asteroid_objp, float frame_time) {}
int asteroid_check_collision( object *asteroid_objp, object * other_obj, vec3d * hitpos, collision_info_struct *asteroid_hit_info ) {return 0;}
void asteroid_hit( object *asteroid_objp, object *other_objp, vec3d *hitpos, float damage ) {}
void asteroid_save_restore(CFILE *fp) {}
int asteroid_count() {return 0;}
int asteroid_collide_objnum(object *asteroid_objp) {return 0;}
float asteroid_time_to_impact(object *asteroid_objp) {return 0.0f;}
void asteroid_show_brackets() {}
void asteroid_target_closest_danger() {}
void asteroid_page_in() {}
void asteroid_sub_create(object *parent_objp, int asteroid_type, vec3d *relvec) {}
void asteroid_frame() {}
#endif
*/
+5 -9
View File
@@ -29,11 +29,6 @@ struct collision_info_struct;
#define ASTEROID_TYPE_MEDIUM 1
#define ASTEROID_TYPE_LARGE 2
// This is for the asteroid types plus DEBRIS_X_Y
// (X is each species and Y is SMALL, MEDIUM, and LARGE)
// 20060826 - made dynamic -- taylor
//#define MAX_DEBRIS_TYPES ((MAX_SPECIES + 1) * NUM_DEBRIS_SIZES)
// these should always be equal for the benefit of generic asteroids (c.f. asteroid_page_in)
#define MAX_ACTIVE_DEBRIS_TYPES NUM_DEBRIS_SIZES
@@ -56,6 +51,7 @@ typedef struct asteroid_info {
int detail_distance[MAX_ASTEROID_DETAIL_LEVELS]; // distance to change detail levels at
float max_speed; // cap on speed for asteroid
int damage_type_idx; //Damage type of the asteroid
int damage_type_idx_sav; // stored value from table used to reset damage_type_idx
float inner_rad; // radius within which maximum area effect damage is applied
float outer_rad; // radius at which no area effect damage is applied
float damage; // maximum damage applied from area effect explosion
@@ -64,10 +60,10 @@ typedef struct asteroid_info {
polymodel *modelp[NUM_DEBRIS_POFS];
int model_num[NUM_DEBRIS_POFS];
asteroid_info( )
: num_detail_levels( 0 ), max_speed( 0 ), damage_type_idx( -1 ),
inner_rad( 0 ), outer_rad( 0 ), damage( 0 ), blast( 0 ),
initial_asteroid_strength( 0 )
asteroid_info( )
: 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 )
{
name[ 0 ] = NULL;
memset( pof_files, 0, sizeof( pof_files ) );
+223 -180
View File
@@ -39,6 +39,7 @@ extern int Cmdline_autopilot_interruptable;
// Module variables
bool AutoPilotEngaged;
bool UseCutsceneBars;
bool LockWeaponsDuringAutopilot;
int CurrentNav;
float ramp_bias;
NavPoint Navs[MAX_NAVPOINTS];
@@ -55,6 +56,9 @@ bool CinematicStarted, CameraMoving;
vec3d cameraPos, cameraTarget;
std::map<int,int> autopilot_wings;
int AutopilotMinEnemyDistance;
int AutopilotMinAsteroidDistance;
// used for ramping time compression;
int start_dist;
@@ -63,14 +67,7 @@ int start_dist;
void autopilot_ai_waypoint_goal_fixup(ai_goal* aigp)
{
// this function sets wp_index properly;
for (int i = 0; i < Num_waypoint_lists; i++)
{
if (!stricmp(aigp->ship_name, Waypoint_lists[i].name))
{
aigp->wp_index = i;
return;
}
}
aigp->wp_list = find_matching_waypoint_list(aigp->target_name);
}
@@ -115,7 +112,9 @@ vec3d *NavPoint::GetPosition()
{
if (flags & NP_WAYPOINT)
{
return &((waypoint_list*) target_obj)->waypoints[waypoint_num-1];
waypoint *wpt = find_waypoint_at_index((waypoint_list*) target_obj, waypoint_num-1);
Assert(wpt != NULL);
return wpt->get_pos();
}
else
{
@@ -123,16 +122,16 @@ vec3d *NavPoint::GetPosition()
}
}
char* NavPoint::GetInteralName()
char* NavPoint::GetInternalName()
{
char *NavName;
char strtmp[33];
if (flags & NP_WAYPOINT)
{
NavName = new char[strlen(((waypoint_list*)target_obj)->name)+5];
memset(NavName, 0, strlen(((waypoint_list*)target_obj)->name)+5);
strcpy(NavName, ((waypoint_list*)target_obj)->name);
NavName = new char[strlen(((waypoint_list*)target_obj)->get_name())+5];
memset(NavName, 0, strlen(((waypoint_list*)target_obj)->get_name())+5);
strcpy(NavName, ((waypoint_list*)target_obj)->get_name());
strcat(NavName, ":");
sprintf(strtmp, "%d", waypoint_num);
@@ -149,12 +148,7 @@ char* NavPoint::GetInteralName()
}
// ********************************************************************************************
// Tell us if autopilot is allowed
// This needs:
// * Nav point selected
// * No enemies within X distance
// * Destination > 1,000 meters away
bool CanAutopilot(bool send_msg)
bool CanAutopilot(vec3d targetPos, bool send_msg)
{
if (CurrentNav == -1)
{
@@ -162,99 +156,69 @@ bool CanAutopilot(bool send_msg)
send_autopilot_msgID(NP_MSG_FAIL_NOSEL);
return false;
}
if (object_get_gliding(Player_obj))
{
if (send_msg)
send_autopilot_msgID(NP_MSG_FAIL_GLIDING);
return false;
}
// You cannot autopilot if you're within 1000 meters of your destination nav point
if (vm_vec_dist_quick(&Player_obj->pos, Navs[CurrentNav].GetPosition()) < 1000)
{
if (vm_vec_dist_quick(&targetPos, Navs[CurrentNav].GetPosition()) < 1000) {
if (send_msg)
send_autopilot_msgID(NP_MSG_FAIL_TOCLOSE);
return false;
}
// see if any hostiles are nearby
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];
// 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 & SIF_CARGO))
if ( AutopilotMinEnemyDistance > 0 ) {
// see if any hostiles are nearby
for (ship_obj *so = GET_FIRST(&Ship_obj_list); so != END_OF_LIST(&Ship_obj_list); so = GET_NEXT(so))
{
// Cannot autopilot if enemy within 5,000 meters
if (vm_vec_dist_quick(&Player_obj->pos, &other_objp->pos) < 5000)
object *other_objp = &Objects[so->objnum];
// 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 & SIF_CARGO)) // ignore cargo
{
if (send_msg)
send_autopilot_msgID(NP_MSG_FAIL_HOSTILES);
return false;
// Cannot autopilot if enemy within AutopilotMinEnemyDistance meters
if (vm_vec_dist_quick(&targetPos, &other_objp->pos) < AutopilotMinEnemyDistance) {
if (send_msg)
send_autopilot_msgID(NP_MSG_FAIL_HOSTILES);
return false;
}
}
}
}
//check for asteroids
for (int n=0; n<MAX_ASTEROIDS; n++)
{
// asteroid
if (Asteroids[n].flags & AF_USED)
{
// Cannot autopilot if asteroid within 1,000 meters
if (vm_vec_dist_quick(&Player_obj->pos, &Objects[Asteroids[n].objnum].pos) < 1000)
{
if (send_msg)
send_autopilot_msgID(NP_MSG_FAIL_HAZARD);
return false;
}
}
}
return true;
}
// ********************************************************************************************
// Tell us if autopilot is allowed at a certain position (only performs checks based on that position)
// This needs:
// * Nav point selected
// * No enemies within X distance
// * Destination > 1,000 meters away
bool CanAutopilotPos(vec3d targetPos)
{
// You cannot autopilot if you're within 1000 meters of your destination nav point
if (vm_vec_dist_quick(&targetPos, Navs[CurrentNav].GetPosition()) < 1000)
return false;
// see if any hostiles are nearby
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];
// 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 & SIF_CARGO)) // ignore cargo
{
// Cannot autopilot if enemy within 5,000 meters
if (vm_vec_dist_quick(&targetPos, &other_objp->pos) < 5000)
return false;
}
}
//check for asteroids
for (int n=0; n<MAX_ASTEROIDS; n++)
{
// asteroid
if (Asteroids[n].flags & AF_USED)
if ( AutopilotMinAsteroidDistance > 0 ) {
//check for asteroids
for (int n=0; n<MAX_ASTEROIDS; n++)
{
// Cannot autopilot if asteroid within 1,000 meters
if (vm_vec_dist_quick(&targetPos, &Objects[Asteroids[n].objnum].pos) < 1000)
return false;
// asteroid
if (Asteroids[n].flags & AF_USED)
{
// Cannot autopilot if asteroid within AutopilotMinAsteroidDistance meters
if (vm_vec_dist_quick(&targetPos, &Objects[Asteroids[n].objnum].pos) < AutopilotMinAsteroidDistance) {
if (send_msg)
send_autopilot_msgID(NP_MSG_FAIL_HAZARD);
return false;
}
}
}
}
// check for support ships
// cannot autopilot if support ship present
if ( ship_find_repair_ship(Player_obj) != NULL ) {
if (send_msg)
send_autopilot_msgID(NP_MSG_FAIL_SUPPORT_PRESENT);
return false;
}
return true;
}
extern object* Autopilot_flight_leader;
// ********************************************************************************************
// Engages autopilot
// This does:
@@ -263,13 +227,54 @@ bool CanAutopilotPos(vec3d targetPos)
// * Lock time compression -WMC
// * Tell AI to fly to targetted Nav Point (for all nav-status wings/ships)
// * Sets max waypoint speed to the best-speed of the slowest ship tagged
void StartAutopilot()
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.
bool done = false;
while (!done) {
object* support_ship_op = ship_find_repair_ship(Player_obj);
if ( support_ship_op == NULL ) {
// no more
done = true;
break;
}
Assert( support_ship_op->type == OBJ_SHIP );
Assert( support_ship_op->instance >= 0 );
Assert( support_ship_op->instance < MAX_SHIPS );
Assert( Ships[support_ship_op->instance].ai_index != -1 );
ai_info* support_ship_aip = &(Ai_info[Ships[support_ship_op->instance].ai_index]);
// is support ship trying to rearm-repair
if ( ai_find_goal_index( support_ship_aip->goals, AI_GOAL_REARM_REPAIR ) == -1 ) {
// no, so tell it to depart
ai_add_ship_goal_player( AIG_TYPE_PLAYER_SHIP, AI_GOAL_WARP, -1, NULL, support_ship_aip );
} else {
// yes
send_autopilot_msgID(NP_MSG_FAIL_SUPPORT_WORKING);
return false;
}
}
if (!CanAutopilot())
return;
return false;
AutoPilotEngaged = true;
// find the ship that is "leading" all of the ships when the player starts
// autopilot
// by default the ship that is leading the autopilot session the player's
// wing leader (if the player is the wing leader then it will be the
// player).
// TODO:implement a way to allow a FREDer to say a different ship is leader
Autopilot_flight_leader = get_wing_leader(Player_ship->wingnum);
if ( Autopilot_flight_leader == NULL ) {
// force player to be the leader if he doesn't have a wing
Autopilot_flight_leader = Player_obj;
}
if (The_mission.flags & MISSION_FLAG_USE_AP_CINEMATICS)
LockAPConv = timestamp(); // lock convergence instantly
else
@@ -328,10 +333,20 @@ void StartAutopilot()
}
}
// damp speed_cap to 90% of actual -- to make sure ships stay in formation
if (The_mission.flags & MISSION_FLAG_USE_AP_CINEMATICS)
speed_cap = 0.90f * speed_cap;
if ( speed_cap < 1.0f ) {
/* We need to deal with this so that incorrectly flagged ships will not
cause the engine to fail to limit all the ships speeds correctly. */
Warning(LOCATION, "Ship speed cap is way too small (%f)!\n"
"This is normally caused by a ship that has nav-carry-status set, but cannot move itself (like a Cargo container).\n"
"Speed cap has been set to 1.0 m/s.",
speed_cap);
speed_cap = 1.0f;
}
ramp_bias = speed_cap/50.0f;
// assign ship goals
@@ -352,8 +367,7 @@ void StartAutopilot()
{
capshipPresent = true;
capIndexes.resize(capIndexes.size()+1);
capIndexes[capIndexes.size()-1] = i;
capIndexes.push_back(i);
// ok.. what size class
if (Ship_info[Ships[i].ship_info_index].flags & (SIF_CAPITAL | SIF_SUPERCAP))
@@ -397,10 +411,10 @@ void StartAutopilot()
vm_vector_2_matrix(&Objects[Ships[i].objnum].orient, &norm1, NULL, NULL);
}
// snap wings into formation them into formation
// snap wings into formation
if (The_mission.flags & MISSION_FLAG_USE_AP_CINEMATICS && // only if using cinematics
(Ships[i].wingnum != -1 && Wings[Ships[i].wingnum].flags & WF_NAV_CARRY) // only if in a wing
&& Player_obj != &Objects[Ships[i].objnum]) //only if not player object
&& 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);
@@ -419,33 +433,34 @@ void StartAutopilot()
switch (wcount % 2)
{
case 1: // back-left
vm_vec_add(&perp, &zero, &Player_obj->orient.vec.rvec);
vm_vec_add(&perp, &zero, &Autopilot_flight_leader->orient.vec.rvec);
//vm_vec_sub(&perp, &perp, &Player_obj->orient.vec.fvec);
vm_vec_normalize(&perp);
vm_vec_scale(&perp, -166.0f*j); // 166m is supposedly the optimal range according to tolwyn
vm_vec_add(&goal_point, &Player_obj->pos, &perp);
vm_vec_add(&goal_point, &Autopilot_flight_leader->pos, &perp);
break;
default: //back-right
case 0:
vm_vec_add(&perp, &zero, &Player_obj->orient.vec.rvec);
vm_vec_add(&perp, &zero, &Autopilot_flight_leader->orient.vec.rvec);
//vm_vec_sub(&perp, &perp, &Player_obj->orient.vec.fvec);
vm_vec_normalize(&perp);
vm_vec_scale(&perp, 166.0f*j);
vm_vec_add(&goal_point, &Player_obj->pos, &perp);
vm_vec_add(&goal_point, &Autopilot_flight_leader->pos, &perp);
break;
}
autopilot_wings[wingnum] = wcount;
wcount++;
}
Objects[Ships[i].objnum].pos = goal_point;
if (vm_vec_dist_quick(&Player_obj->pos, &Objects[Ships[i].objnum].pos) > distance)
if (vm_vec_dist_quick(&Autopilot_flight_leader->pos, &Objects[Ships[i].objnum].pos) > distance)
{
distance = vm_vec_dist_quick(&Player_obj->pos, &Objects[Ships[i].objnum].pos);
distance = vm_vec_dist_quick(&Autopilot_flight_leader->pos, &Objects[Ships[i].objnum].pos);
}
}
// lock primary and secondary weapons
//Ships[i].flags2 |= (SF2_PRIMARIES_LOCKED | SF2_SECONDARIES_LOCKED);
if ( LockWeaponsDuringAutopilot )
Ships[i].flags2 |= (SF2_PRIMARIES_LOCKED | SF2_SECONDARIES_LOCKED);
// clear the ship goals and cap the waypoint speed
ai_clear_ship_goals(&Ai_info[Ships[i].ai_index]);
@@ -457,7 +472,7 @@ void StartAutopilot()
{
if (Navs[CurrentNav].flags & NP_WAYPOINT)
{
ai_add_ship_goal_player( AIG_TYPE_PLAYER_SHIP, AI_GOAL_WAYPOINTS_ONCE, 0, ((waypoint_list*)Navs[CurrentNav].target_obj)->name, &Ai_info[Ships[i].ai_index] );
ai_add_ship_goal_player( AIG_TYPE_PLAYER_SHIP, AI_GOAL_WAYPOINTS_ONCE, 0, ((waypoint_list*)Navs[CurrentNav].target_obj)->get_name(), &Ai_info[Ships[i].ai_index] );
//fixup has to wait until after wing goals
}
else
@@ -486,7 +501,7 @@ void StartAutopilot()
if (Navs[CurrentNav].flags & NP_WAYPOINT)
{
ai_add_wing_goal_player( AIG_TYPE_PLAYER_WING, AI_GOAL_WAYPOINTS_ONCE, 0, ((waypoint_list*)Navs[CurrentNav].target_obj)->name, i );
ai_add_wing_goal_player( AIG_TYPE_PLAYER_WING, AI_GOAL_WAYPOINTS_ONCE, 0, ((waypoint_list*)Navs[CurrentNav].target_obj)->get_name(), i );
// "fix up" the goal
for (j = 0; j < MAX_AI_GOALS; j++)
@@ -538,13 +553,13 @@ void StartAutopilot()
// position capships
vec3d right, front, up, offset;
for (i = 0; i < (int)capIndexes.size(); i++)
for (SCP_vector<int>::iterator idx = capIndexes.begin(); idx != capIndexes.end(); ++idx)
{
vm_vec_add(&right, &Player_obj->orient.vec.rvec, &zero);
vm_vec_add(&front, &Player_obj->orient.vec.fvec, &zero);
vm_vec_add(&up, &Player_obj->orient.vec.uvec, &zero);
vm_vec_add(&right, &Autopilot_flight_leader->orient.vec.rvec, &zero);
vm_vec_add(&front, &Autopilot_flight_leader->orient.vec.fvec, &zero);
vm_vec_add(&up, &Autopilot_flight_leader->orient.vec.uvec, &zero);
vm_vec_add(&offset, &zero, &zero);
if (Ship_info[Ships[capIndexes[i]].ship_info_index].flags & (SIF_CAPITAL | SIF_SUPERCAP))
if (Ship_info[Ships[*idx].ship_info_index].flags & (SIF_CAPITAL | SIF_SUPERCAP))
{
//0 - below - three lines of position
@@ -578,7 +593,7 @@ void StartAutopilot()
capship_placed[0]++;
}
else if (Ship_info[Ships[capIndexes[i]].ship_info_index].flags & SIF_CORVETTE)
else if (Ship_info[Ships[*idx].ship_info_index].flags & SIF_CORVETTE)
{
//1 above - 3 lines of position
// front/back to zero
@@ -610,7 +625,7 @@ void StartAutopilot()
vm_vec_scale(&up, (1+((float)floor((float)capship_placed[1]/3))));
// move ourselves up and out of the way of the smaller ships
vm_vec_add(&perp, &Player_obj->orient.vec.uvec, &zero);
vm_vec_add(&perp, &Autopilot_flight_leader->orient.vec.uvec, &zero);
vm_vec_scale(&perp, capship_spreads[2]);
vm_vec_add(&up, &up, &perp);
@@ -665,7 +680,7 @@ void StartAutopilot()
vm_vec_scale(&front, 2*(1+((float)floor((float)capship_placed[2]/3))));
// move "out" by 166*(wcount-1) so we don't bump into fighters
vm_vec_add(&perp, &Player_obj->orient.vec.rvec, &zero);
vm_vec_add(&perp, &Autopilot_flight_leader->orient.vec.rvec, &zero);
vm_vec_scale(&perp, 166.0f*float(wcount-1));
if ( (capship_placed[2] % 2) == 0)
vm_vec_add(&right, &right, &perp);
@@ -687,16 +702,16 @@ void StartAutopilot()
// global scale the position by 50%
//vm_vec_scale(&offset, 1.5);
vm_vec_add(&Objects[Ships[capIndexes[i]].objnum].pos, &Player_obj->pos, &offset);
vm_vec_add(&Objects[Ships[*idx].objnum].pos, &Autopilot_flight_leader->pos, &offset);
if (vm_vec_dist_quick(&Player_obj->pos, &Objects[Ships[i].objnum].pos) > distance)
if (vm_vec_dist_quick(&Autopilot_flight_leader->pos, &Objects[Ships[i].objnum].pos) > distance)
{
distance = vm_vec_dist_quick(&Player_obj->pos, &Objects[Ships[i].objnum].pos);
distance = vm_vec_dist_quick(&Autopilot_flight_leader->pos, &Objects[Ships[i].objnum].pos);
}
}
}
ftemp = floor(Player_obj->phys_info.max_vel.xyz.z/speed_cap);
ftemp = floor(Autopilot_flight_leader->phys_info.max_vel.xyz.z/speed_cap);
if (ftemp >= 2.0f && ftemp < 4.0f)
tc_factor = 2;
else if (ftemp >= 4.0f && ftemp < 8.0f)
@@ -708,11 +723,11 @@ void StartAutopilot()
tpos = *Navs[CurrentNav].GetPosition();
// determine distance toward nav at which camera will be
vm_vec_sub(&pos, &tpos, &Player_obj->pos);
vm_vec_sub(&pos, &tpos, &Autopilot_flight_leader->pos);
vm_vec_normalize(&pos); // pos is now a unit vector in the direction we will be moving the camera
//norm1 = pos;
vm_vec_scale(&pos, 5*speed_cap*tc_factor); // pos is now scaled by 5 times the speed (5 seconds ahead)
vm_vec_add(&pos, &pos, &Player_obj->pos); // pos is now 5*speed cap in front of player ship
vm_vec_add(&pos, &pos, &Autopilot_flight_leader->pos); // pos is now 5*speed cap in front of player ship
switch (myrand()%24)
// 8 different ways of getting perp points
@@ -723,74 +738,74 @@ void StartAutopilot()
case 9:
case 16:
if (capship_placed[0] == 0)
vm_vec_sub(&perp, &zero, &Player_obj->orient.vec.uvec);
vm_vec_sub(&perp, &zero, &Autopilot_flight_leader->orient.vec.uvec);
else
{ // become up-left
vm_vec_add(&perp, &zero, &Player_obj->orient.vec.uvec);
vm_vec_sub(&perp, &perp, &Player_obj->orient.vec.rvec);
vm_vec_add(&perp, &zero, &Autopilot_flight_leader->orient.vec.uvec);
vm_vec_sub(&perp, &perp, &Autopilot_flight_leader->orient.vec.rvec);
}
break;
case 2: // up
case 10:
case 23:
vm_vec_add(&perp, &perp, &Player_obj->orient.vec.uvec);
vm_vec_add(&perp, &perp, &Autopilot_flight_leader->orient.vec.uvec);
if (capshipPresent) // become up-right
vm_vec_add(&perp, &perp, &Player_obj->orient.vec.rvec);
vm_vec_add(&perp, &perp, &Autopilot_flight_leader->orient.vec.rvec);
break;
case 3: // left
case 11:
case 22:
vm_vec_sub(&perp, &zero, &Player_obj->orient.vec.rvec);
vm_vec_sub(&perp, &zero, &Autopilot_flight_leader->orient.vec.rvec);
break;
case 4: // up-left
case 12:
case 21:
vm_vec_sub(&perp, &zero, &Player_obj->orient.vec.rvec);
vm_vec_add(&perp, &perp, &Player_obj->orient.vec.uvec);
vm_vec_sub(&perp, &zero, &Autopilot_flight_leader->orient.vec.rvec);
vm_vec_add(&perp, &perp, &Autopilot_flight_leader->orient.vec.uvec);
break;
case 5: // up-right
case 13:
case 20:
vm_vec_add(&perp, &zero, &Player_obj->orient.vec.rvec);
vm_vec_add(&perp, &perp, &Player_obj->orient.vec.uvec);
vm_vec_add(&perp, &zero, &Autopilot_flight_leader->orient.vec.rvec);
vm_vec_add(&perp, &perp, &Autopilot_flight_leader->orient.vec.uvec);
break;
case 6: // down-left
case 14:
case 19:
vm_vec_sub(&perp, &zero, &Player_obj->orient.vec.rvec);
vm_vec_sub(&perp, &zero, &Autopilot_flight_leader->orient.vec.rvec);
if (capship_placed[0] < 2)
vm_vec_sub(&perp, &perp, &Player_obj->orient.vec.uvec);
vm_vec_sub(&perp, &perp, &Autopilot_flight_leader->orient.vec.uvec);
else
vm_vec_add(&perp, &perp, &Player_obj->orient.vec.uvec);
vm_vec_add(&perp, &perp, &Autopilot_flight_leader->orient.vec.uvec);
break;
case 7: // down-right
case 15:
case 18:
vm_vec_add(&perp, &zero, &Player_obj->orient.vec.rvec);
vm_vec_add(&perp, &zero, &Autopilot_flight_leader->orient.vec.rvec);
if (capship_placed[0] < 1)
vm_vec_sub(&perp, &perp, &Player_obj->orient.vec.uvec);
vm_vec_sub(&perp, &perp, &Autopilot_flight_leader->orient.vec.uvec);
else
vm_vec_add(&perp, &perp, &Player_obj->orient.vec.uvec);
vm_vec_add(&perp, &perp, &Autopilot_flight_leader->orient.vec.uvec);
break;
default:
case 0: // right
case 8:
case 17:
perp = Player_obj->orient.vec.rvec;
perp = Autopilot_flight_leader->orient.vec.rvec;
break;
}
vm_vec_normalize(&perp);
//vm_vec_scale(&perp, 2*radius+distance);
vm_vec_scale(&perp, Player_obj->radius+radius);
vm_vec_scale(&perp, Autopilot_flight_leader->radius+radius);
// randomly scale up/down by up to 20%
j = 20-myrand()%40; // [-20,20]
@@ -830,16 +845,8 @@ void StartAutopilot()
camMovingTime = int(4.5*float(tc_factor));
set_time_compression((float)tc_factor);
}
}
// ********************************************************************************************
// Checks if autopilot should automatically die
// Returns true if:
// * Targetted waypoint < 10,000 meters away
// * Enemy < 10,000 meters
bool Autopilot_AutoDiable()
{
return !CanAutopilot();
return true;
}
// ********************************************************************************************
@@ -852,6 +859,8 @@ void EndAutoPilot()
{
AutoPilotEngaged = false;
Autopilot_flight_leader = NULL;
set_time_compression(1);
lock_time_compression(false);
Player_use_ai = 0;
@@ -875,7 +884,7 @@ void EndAutoPilot()
if (Navs[CurrentNav].flags & NP_WAYPOINT)
{
goal = AI_GOAL_WAYPOINTS_ONCE;
goal_name = ((waypoint_list*)Navs[CurrentNav].target_obj)->name;
goal_name = ((waypoint_list*)Navs[CurrentNav].target_obj)->get_name();
}
else
{
@@ -899,14 +908,16 @@ void EndAutoPilot()
)
{
//unlock their weaponry
//Ships[i].flags2 &= ~(SF2_PRIMARIES_LOCKED | SF2_SECONDARIES_LOCKED);
if ( LockWeaponsDuringAutopilot )
Ships[i].flags2 &= ~(SF2_PRIMARIES_LOCKED | SF2_SECONDARIES_LOCKED);
Ai_info[Ships[i].ai_index].waypoint_speed_cap = -1; // uncap their speed
Ai_info[Ships[i].ai_index].mode = AIM_NONE; // make AI re-evaluate current ship mode
for (j = 0; j < MAX_AI_GOALS; j++)
{
ai_goal *aigp = &Ai_info[Ships[i].ai_index].goals[j];
if ( ((aigp->ship_name != NULL) && !stricmp(aigp->ship_name, goal_name))
if ( ((aigp->target_name != NULL) && !stricmp(aigp->target_name, goal_name))
&& (aigp->ai_mode == goal) )
{
ai_remove_ship_goal(&Ai_info[Ships[i].ai_index], j);
@@ -919,7 +930,7 @@ void EndAutoPilot()
{
ai_goal *aigp = &Wings[Ships[i].wingnum].ai_goals[j];
if ( ((aigp->ship_name != NULL) && !stricmp(aigp->ship_name, goal_name))
if ( ((aigp->target_name != NULL) && !stricmp(aigp->target_name, goal_name))
&& (aigp->ai_mode == goal) )
{
aigp->ai_mode = AI_GOAL_NONE;
@@ -943,7 +954,7 @@ void EndAutoPilot()
{
ai_goal *aigp = &Wings[i].ai_goals[j];
if ( ((aigp->ship_name != NULL) && !stricmp(aigp->ship_name, goal_name))
if ( ((aigp->target_name != NULL) && !stricmp(aigp->target_name, goal_name))
&& (aigp->ai_mode == goal) )
{
aigp->ai_mode = AI_GOAL_NONE;
@@ -975,34 +986,54 @@ camera* nav_get_set_camera()
void nav_warp(bool prewarp=false)
{
// ok... find our end distance - norm1 is still a unit vector in the direction from the player to the navpoint
vec3d targetPos, tpos=Player_obj->pos, pos;
vm_vec_sub(&pos, Navs[CurrentNav].GetPosition(), &Player_obj->pos);
/* ok... find our end distance - norm1 is still a unit vector in the
direction from the flight leader to the navpoint */
vec3d targetPos, tpos=Autopilot_flight_leader->pos, pos, velocity;
/* calculate a vector that we can use to make a path from the flight
leader's location to the nav point */
vm_vec_sub(&pos, Navs[CurrentNav].GetPosition(), &Autopilot_flight_leader->pos);
vm_vec_normalize(&pos);
velocity = pos; // make a copy for later when we do setup veleocity vector
vm_vec_scale(&pos, 250.0f); // we move by increments of 250
while (CanAutopilotPos(tpos))
/* using the vector of the flight leaders's path, simulate moving the
flight along this path by checking the autopilot conditions as specific
intervals along the path*/
while (CanAutopilot(tpos))
{
vm_vec_add(&tpos, &tpos, &pos);
}
vm_vec_sub(&targetPos, &tpos, &Player_obj->pos); //targetPos is actually a projection in a the direction toward the nav
vm_vec_sub(&targetPos, &tpos, &Autopilot_flight_leader->pos);
/* targetPos is actually a vector that describes the exact 3D movement that
the flgith leader needs to execute to reach the location that the auto
pilot is to shut off */
// Check if we are actually just setting up for the cinimatic shot of the
// flight flying on autopilot. Only jump halfway. Also we also need to
// put the camera in the correct position to show the player this cinimatic
if (prewarp)
{
vm_vec_scale(&targetPos, 0.5);
vm_vec_add(&cameraPos, &cameraPos, &targetPos);
}
/* calcuate the speed that everyone is supposed to be going so that there
is no need for anyone to accelerate or decelerate (most obvious with
the player's fighter slowing down as it changes the camera pan speed). */
Assert( Ai_info[Ships[Autopilot_flight_leader->instance].ai_index].waypoint_speed_cap > 0 );
vm_vec_scale(&velocity, (float)Ai_info[Ships[Autopilot_flight_leader->instance].ai_index].waypoint_speed_cap);
// Find all ships that are supposed to autopilot with the player and move them
// to the cinimatic location or the final destination
for (int i = 0; i < MAX_SHIPS; i++)
{
if (Ships[i].objnum != -1 &&
(Ships[i].flags2 & SF2_NAVPOINT_CARRY ||
(Ships[i].wingnum != -1 && Wings[Ships[i].wingnum].flags & WF_NAV_CARRY)
)
)
if (Ships[i].objnum != -1
&& (Ships[i].flags2 & SF2_NAVPOINT_CARRY
|| (Ships[i].wingnum != -1 && Wings[Ships[i].wingnum].flags & WF_NAV_CARRY)))
{
vm_vec_add(&Objects[Ships[i].objnum].pos, &Objects[Ships[i].objnum].pos, &targetPos);
Objects[Ships[i].objnum].phys_info.vel = velocity;
}
}
@@ -1041,7 +1072,7 @@ void NavSystem_Do()
}
if (timestamp() >= EndAPCinematic || Autopilot_AutoDiable())
if (timestamp() >= EndAPCinematic || !CanAutopilot())
{
nav_warp();
EndAutoPilot();
@@ -1060,7 +1091,7 @@ void NavSystem_Do()
if(cam != NULL)
{
cam->set_position(&cameraPos);
cam->set_rotation_facing(&Player_obj->pos);
cam->set_rotation_facing(&Autopilot_flight_leader->pos);
}
CinematicStarted = true;
@@ -1068,7 +1099,7 @@ void NavSystem_Do()
}
else
{
if (Autopilot_AutoDiable())
if (!CanAutopilot())
EndAutoPilot();
}
@@ -1141,7 +1172,10 @@ void NavSystem_Do()
}
}
// autopilot linking
/* Link in any ships that need to be linked in when the player gets close
enough. Always done by the player because: "making sure the AI fighters
are where they're supposed to be at all times is like herding cats" -Woolie Wool
*/
for (int i = 0; i < MAX_SHIPS; i++)
{
if (Ships[i].objnum != -1 && Ships[i].flags2 & SF2_NAVPOINT_NEEDSLINK)
@@ -1179,11 +1213,11 @@ void send_autopilot_msg(char *msg, char *snd)
audio_handle = -1;
}
if (strlen(msg) != 0 && strcmp(msg, "none"))
if (msg[0] != '\0' && strcmp(msg, "none"))
change_message("autopilot builtin message", msg, -1, 0);
// load sound
if (snd != NULL || strlen(snd) == 0 || !strcmp(snd, "none"))
if ((snd != NULL) && (snd[0] != '\0' && !strcmp(snd, "none")))
{
audio_handle = audiostream_open(snd, ASF_MENUMUSIC );
}
@@ -1191,10 +1225,10 @@ void send_autopilot_msg(char *msg, char *snd)
// send/play
if (audio_handle != -1)
{
audiostream_play(audio_handle, Master_event_music_volume, 0);
audiostream_play(audio_handle, (Master_event_music_volume * aav_music_volume), 0);
}
if (strlen(msg) != 0 && strcmp(msg, "none"))
if (msg[0] != '\0' && strcmp(msg, "none"))
message_training_queue("autopilot builtin message", timestamp(0), 5); // display message for five seconds
}
@@ -1247,6 +1281,21 @@ void parse_autopilot_table(char *filename)
required_string("$Link Distance:");
stuff_int(&NavLinkDistance);
if (optional_string("$Interrupt autopilot if enemy within distance:"))
stuff_int(&AutopilotMinEnemyDistance);
else
AutopilotMinEnemyDistance = 5000;
if (optional_string("$Interrupt autopilot if asteroid within distance:"))
stuff_int(&AutopilotMinAsteroidDistance);
else
AutopilotMinAsteroidDistance = 1000;
if (optional_string("$Lock Weapons During Autopilot:"))
stuff_boolean(&LockWeaponsDuringAutopilot);
else
LockWeaponsDuringAutopilot = false;
// optional no cutscene bars
if (optional_string("+No_Cutscene_Bars"))
UseCutsceneBars = false;
@@ -1255,7 +1304,9 @@ void parse_autopilot_table(char *filename)
Cmdline_autopilot_interruptable = 0;
// No Nav selected message
char *msg_tags[] = { "$No Nav Selected:", "$Gliding:", "$Too Close:", "$Hostiles:", "$Linked:", "$Hazard:" };
char *msg_tags[] = { "$No Nav Selected:", "$Gliding:",
"$Too Close:", "$Hostiles:", "$Linked:", "$Hazard:",
"$Support Present:", "$Support Working:" };
for (int i = 0; i < NP_NUM_MESSAGES; i++)
{
required_string(msg_tags[i]);
@@ -1397,15 +1448,7 @@ bool AddNav_Waypoint(char *Nav, char *WP_Path, int node, int flags)
Assert(!(tnav.flags & NP_SHIP));
for (i = 0; i < Num_waypoint_lists; i++)
{
if (!stricmp(WP_Path, Waypoint_lists[i].name))
{
tnav.target_obj = (void *)&Waypoint_lists[i];
}
}
tnav.target_obj = find_matching_waypoint_list(WP_Path);
tnav.waypoint_num = node;
// copy it into it's location
@@ -1537,7 +1580,7 @@ unsigned int DistanceTo(char *nav)
unsigned int DistanceTo(int nav)
{
if (nav >= MAX_NAVPOINTS && nav < 0)
if (nav >= MAX_NAVPOINTS || nav < 0)
return 0xFFFFFFFF;
return (uint)vm_vec_dist_quick(&Player_obj->pos, Navs[nav].GetPosition());
@@ -1554,7 +1597,7 @@ bool IsVisited(char *nav)
bool IsVisited(int nav)
{
if (nav >= MAX_NAVPOINTS && nav < 0)
if (nav >= MAX_NAVPOINTS || nav < 0)
return 0;
if (Navs[nav].flags & NP_VISITED)
+20 -16
View File
@@ -8,6 +8,7 @@
#define _AUTOPILOT_H_
#include "globalincs/pstypes.h"
#include "object/object.h"
#include <map>
// milliseconds between updates
@@ -15,8 +16,8 @@
#define MAX_NAVPOINTS 8
#define NP_WAYPOINT 0x0001 // Nav Point is bound to the poistion of a single node of a waypoint path
#define NP_SHIP 0x0002 // Nav Point is bound to the poisiton of a certain ship
#define NP_WAYPOINT 0x0001 // Nav Point is bound to the position of a single node of a waypoint path
#define NP_SHIP 0x0002 // Nav Point is bound to the position of a certain ship
#define NP_HIDDEN 0x0004 // Nav Point doesn't show on map and isn't selectable
#define NP_NOACCESS 0x0008 // Nav Point isn't selectable
#define NP_VISITED 0x0100 // Whether we've been within 1,000 meters of this waypoint
@@ -33,17 +34,19 @@ struct NavPoint
int waypoint_num; //only used when flags & NP_WAYPOINT
vec3d *GetPosition();
char* GetInteralName();
char* GetInternalName();
};
#define NP_NUM_MESSAGES 6
#define NP_MSG_FAIL_NOSEL 0
#define NP_MSG_FAIL_GLIDING 1
#define NP_MSG_FAIL_TOCLOSE 2
#define NP_MSG_FAIL_HOSTILES 3
#define NP_MSG_MISC_LINKED 4
#define NP_MSG_FAIL_HAZARD 5
#define NP_MSG_FAIL_SUPPORT_PRESENT 6
#define NP_MSG_FAIL_SUPPORT_WORKING 7
#define NP_NUM_MESSAGES 8
struct NavMessage
{
@@ -62,27 +65,28 @@ extern std::map<int,int> autopilot_wings;
bool Sel_NextNav();
// Tell us is autopilot is allow
// Tell us if autopilot is allowed
// This needs:
// * Nav point selected
// * No enemies within 5,000 meters
// * No enemies within AutopilotMinEnemyDistance meters
// * No asteroids within AutopilotMinAsteroidDistance meters
// * Destination > 1,000 meters away
bool CanAutopilot(bool send_msg=false);
bool CanAutopilotPos(vec3d targetPos);
// * Support ship not present or is actively leaving
bool CanAutopilot(vec3d targetPos, bool send_msg=false);
// Check if autopilot is allowed at player's current position
// See CanAutopilot(vec3d, bool) for more information
inline bool CanAutopilot(bool send_msg=false) { return CanAutopilot(Player_obj->pos, send_msg); }
// Engages autopilot
// This does:
// * Checks if Autopilot is allowed. See CanAutopilot() for conditions.
// * Control switched from player to AI
// * Time compression to 32x
// * Tell AI to fly to targetted Nav Point (for all nav-status wings/ships)
// * Sets max waypoint speed to the best-speed of the slowest ship tagged
void StartAutopilot();
// Checks if autopilot should automatically die
// Returns true if:
// * Targetted waypoint < 1,000 meters away
// * Enemy < 5,000 meters
bool Autopilot_AutoDiable();
// * Sets max waypoint speed to the best-speed of the slowest ship tagged
// Returns false if autopilot cannot be started. True otherwise.
bool StartAutopilot();
// Disengages autopilot
// this does:
+2 -2
View File
@@ -53,9 +53,9 @@ typedef union bm_extra_info {
struct {
// Stuff needed for animations
int first_frame; // used for animations -- points to index of first frame
int num_frames; // used for animation -- number of frames in the animation
int num_frames; // used for animation -- number of frames in the animation
int keyframe; // used for animation -- keyframe info
ubyte fps; // used for animation -- frames per second
int keyframe; // used for animation -- keyframe info
struct {
// stuff for static animations
+250 -183
View File
@@ -17,6 +17,8 @@
#include <windows.h> // for MAX_PATH
#endif
#include <limits.h> // for MAX_INT
#include "bmpman/bmpman.h"
#include "pcxutils/pcxutils.h"
#include "palman/palman.h"
@@ -60,7 +62,7 @@ int Bm_paging = 0;
// locals
static unsigned int Bm_next_signature = 0x1234;
static int bm_next_handle = 0;
static int bm_next_handle = 1;
int Bm_low_mem = 0;
// Bm_max_ram - How much RAM bmpman can use for textures.
// Set to <1 to make it use all it wants.
@@ -78,23 +80,33 @@ static int Bm_ignore_load_count = 0;
// 2 = Debug low memory ( only use first frame of each ani )
void bm_set_low_mem( int mode )
{
Assert( (mode >= 0) && (mode<=2 ));
Assert( (mode >= 0) && (mode<=2) );
CLAMP(mode, 0, 2);
Bm_low_mem = mode;
}
int bm_get_next_handle()
{
int n = bm_next_handle;
//bm_next_handle used to wrap around to 1 if it was over 30000. Now, believe it or not, but that is actually not uncommon;
//as bitmaps get allocated and released, bm_next_handle could get there far more often than you'd think.
//The check introduced below is intended to replace this behaviour with one that ensures we won't be seeing handle collisions
//for a very long time.
bm_next_handle++;
if ( bm_next_handle > 30000 ) {
//Due to the way bm_next_handle is used to generate the /actual/ bitmap handles ( (bm_next_handle * MAX_BITMAPS) + free slot index in bm_bitmaps[]),
//this check is necessary to ensure we don't start giving out negative handles all of a sudden.
if (( (bm_next_handle + 1) * MAX_BITMAPS) > INT_MAX)
bm_next_handle = 1;
}
return n;
return bm_next_handle;
}
// Frees a bitmaps data if it should, and
// Returns true if bitmap n can free it's data.
/**
* Frees a bitmaps data if it can
*/
static void bm_free_data(int n, bool release = false)
{
bitmap_entry *be;
@@ -109,12 +121,12 @@ static void bm_free_data(int n, bool release = false)
// If there isn't a bitmap in this structure, don't
// do anything but clear out the bitmap info
if ( be->type==BM_TYPE_NONE)
if (be->type==BM_TYPE_NONE)
goto SkipFree;
// Don't free up memory for user defined bitmaps, since
// BmpMan isn't the one in charge of allocating/deallocing them.
if ( ( be->type==BM_TYPE_USER ) ) {
if (be->type==BM_TYPE_USER) {
#ifdef BMPMAN_NDEBUG
if ( be->data_size != 0 )
bm_texture_ram -= be->data_size;
@@ -124,7 +136,7 @@ static void bm_free_data(int n, bool release = false)
// If this bitmap doesn't have any data to free, skip
// the freeing it part of this.
if ( (bmp->data == 0) ) {
if (bmp->data == 0) {
#ifdef BMPMAN_NDEBUG
if ( be->data_size != 0 )
bm_texture_ram -= be->data_size;
@@ -133,8 +145,6 @@ static void bm_free_data(int n, bool release = false)
}
// Free up the data now!
// mprintf(( "Bitmap %d freed %d bytes\n", n, bm_bitmaps[n].data_size ));
#ifdef BMPMAN_NDEBUG
bm_texture_ram -= be->data_size;
#endif
@@ -154,13 +164,16 @@ SkipFree:
#ifdef BMPMAN_NDEBUG
be->data_size = 0;
#endif
be->signature = Bm_next_signature++;
be->signature = Bm_next_signature++;
}
// a special version of bm_free_data() that can be safely used in gr_*_texture
// to save system memory once textures have been transfered to API memory
// it doesn't restore the slot to a pristine state, it only releases the data
// NOTE: THIS SHOULD ONLY BE USED FROM bm_unload_fast()!!!
/**
* A special version of bm_free_data() that can be safely used in gr_*_texture
* to save system memory once textures have been transfered to API memory
* it doesn't restore the slot to a pristine state, it only releases the data
*
* NOTE: THIS SHOULD ONLY BE USED FROM bm_unload_fast()!!!
*/
static void bm_free_data_fast(int n)
{
bitmap_entry *be;
@@ -173,12 +186,12 @@ static void bm_free_data_fast(int n)
// If there isn't a bitmap in this structure, don't
// do anything but clear out the bitmap info
if ( be->type == BM_TYPE_NONE)
if (be->type == BM_TYPE_NONE)
return;
// Don't free up memory for user defined bitmaps, since
// BmpMan isn't the one in charge of allocating/deallocing them.
if ( ( be->type == BM_TYPE_USER ) ) {
if (be->type == BM_TYPE_USER) {
#ifdef BMPMAN_NDEBUG
if ( be->data_size != 0 )
bm_texture_ram -= be->data_size;
@@ -188,7 +201,7 @@ static void bm_free_data_fast(int n)
// If this bitmap doesn't have any data to free, skip
// the freeing it part of this.
if ( (bmp->data == 0) ) {
if (bmp->data == 0) {
#ifdef BMPMAN_NDEBUG
if ( be->data_size != 0 ) {
bm_texture_ram -= be->data_size;
@@ -199,8 +212,6 @@ static void bm_free_data_fast(int n)
}
// Free up the data now!
// mprintf(( "Bitmap %d freed %d bytes\n", n, bm_bitmaps[n].data_size ));
#ifdef BMPMAN_NDEBUG
bm_texture_ram -= be->data_size;
be->data_size = 0;
@@ -229,11 +240,12 @@ void *bm_malloc( int n, int size )
bm_texture_ram += size;
#endif
// mprintf(( "Bitmap %d allocated %d bytes\n", n, size ));
return vm_malloc(size);
}
// kinda like bm_malloc but only keeps track of how much memory is getting used
/**
* Like bm_malloc but only keeps track of how much memory is getting used
*/
void bm_update_memory_used( int n, int size )
{
Assert( (n >= 0) && (n < MAX_BITMAPS) );
@@ -294,9 +306,11 @@ void bm_init()
}
}
// Returns number of bytes of bitmaps locked this frame
// ntotal = number of bytes of bitmaps locked this frame
// nnew = number of bytes of bitmaps locked this frame that weren't locked last frame
/**
* Returns number of bytes of bitmaps locked this frame
* @param ntotal number of bytes of bitmaps locked this frame
* @param nnew number of bytes of bitmaps locked this frame that weren't locked last frame
*/
void bm_get_frame_usage(int *ntotal, int *nnew)
{
#ifdef BMPMAN_NDEBUG
@@ -318,12 +332,17 @@ void bm_get_frame_usage(int *ntotal, int *nnew)
#endif
}
// Creates a bitmap that exists in RAM somewhere, instead
// of coming from a disk file. You pass in a pointer to a
// block of 32 (or 8)-bit-per-pixel data. Right now, the only
// bpp you can pass in is 32 or 8. On success, it returns the
// bitmap number. You cannot free that RAM until bm_release
// is called on that bitmap.
/**
* Creates a bitmap that exists in RAM somewhere, instead
* of coming from a disk file.
*
* You pass in a pointer to a block of 32 (or 8)-bit-per-pixel data.
* Right now, the only bpp you can pass in is 32 or 8.
*
* On success, it returns the bitmap number.
*
* You cannot free that RAM until bm_release is called on that bitmap.
*/
int bm_create( int bpp, int w, int h, void *data, int flags )
{
if (bpp == 8) {
@@ -389,10 +408,12 @@ int bm_create( int bpp, int w, int h, void *data, int flags )
return bm_bitmaps[n].handle;
}
// slow sub helper function. Given a raw filename and an extension set, try and find the bitmap
// that isn't already loaded and may exist somewhere on the disk
// returns -1 if it could not be found
// index into ext_list[] if it was found as a file, fills img_cfg if available
/**
* Given a raw filename and an extension set, try and find the bitmap
* that isn't already loaded and may exist somewhere on the disk
*
* @return -1 if it could not be found index into ext_list[] if it was found as a file, fills img_cfg if available
*/
int bm_load_sub_slow(char *real_filename, const int num_ext, const char **ext_list, CFILE **img_cfp = NULL, int dir_type = CF_TYPE_ANY)
{
char full_path[MAX_PATH];
@@ -418,10 +439,10 @@ int bm_load_sub_slow(char *real_filename, const int num_ext, const char **ext_li
return -1;
}
// fast sub helper function. Given a raw filename, try and find a bitmap
// that's already loaded
// returns 0 if it could not be found
// 1 if it already exists, fills in handle
/**
* Given a raw filename, try and find a bitmap that's already loaded
* @return 0 if it could not be found, 1 if it already exists, fills in handle
*/
int bm_load_sub_fast(char *real_filename, int *handle, int dir_type = CF_TYPE_ANY, bool animated_type = false)
{
if (Bm_ignore_duplicates)
@@ -455,11 +476,13 @@ int bm_load_sub_fast(char *real_filename, int *handle, int dir_type = CF_TYPE_AN
return 0;
}
// This loads a bitmap so we can draw with it later.
// It returns a negative number if it couldn't load
// the bitmap. On success, it returns the bitmap
// number. Function doesn't actually load the data, only
// width, height, and possibly flags.
/**
* Loads a bitmap so we can draw with it later.
* Function doesn't actually load the data, only width, height, and possibly flags.
*
* @return A negative number if it couldn't load the bitmap.
* @return On success, it returns the bitmap number.
*/
int bm_load( char *real_filename )
{
int i, free_slot = -1;
@@ -485,7 +508,6 @@ int bm_load( char *real_filename )
char *p = strrchr( filename, '.' );
if ( p ) {
mprintf(( "Someone passed an extension to bm_load for file '%s'\n", real_filename ));
//Int3();
*p = 0;
}
@@ -534,7 +556,7 @@ int bm_load( char *real_filename )
}
if (free_slot < 0) {
Int3();
Assertion(free_slot < 0, "Could not find free BMPMAN slot for bitmap: %s", real_filename);
goto Done;
}
@@ -582,9 +604,12 @@ Done:
return handle;
}
// special load function. basically allows you to load a bitmap which already exists (by filename).
// this is useful because in some cases we need to have a bitmap which is locked in screen format
// _and_ texture format, such as pilot pics and squad logos
/**
* Special load function. Basically allows you to load a bitmap which already exists (by filename).
*
* This is useful because in some cases we need to have a bitmap which is locked in screen format
* _and_ texture format, such as pilot pics and squad logos
*/
int bm_load_duplicate(char *filename)
{
int ret;
@@ -601,6 +626,37 @@ int bm_load_duplicate(char *filename)
return ret;
}
/**
* This function is used to reload a different bitmap into an existing slot.
* This should only be used if you are certain the new picture has the same type, dimensions etc.
*
* @return negative if the given handle doesn't exist, the filename was empty or the slot is still locked
* @return the bitmap_handle on success
*/
int bm_reload(int bitmap_handle, char* filename)
{
if ( !bm_inited )
bm_init();
// if no file was passed then get out now
if ( (filename == NULL) || (strlen(filename) <= 0) )
return -1;
int bitmapnum = bitmap_handle % MAX_BITMAPS;
if ( bm_bitmaps[bitmapnum].type == BM_TYPE_NONE )
return -1;
if ( bm_bitmaps[bitmapnum].ref_count )
{
nprintf(("BmpMan", "Trying to reload a bitmap that is still locked. Filename: %s, ref_count: %d", bm_bitmaps[bitmapnum].filename, bm_bitmaps[bitmapnum].ref_count));
return -1;
}
strncpy(bm_bitmaps[bitmapnum].filename, filename, MAX_FILENAME_LEN);
return bitmap_handle;
}
DCF(bm_frag,"Shows BmpMan fragmentation")
{
if ( Dc_command ) {
@@ -668,7 +724,6 @@ static int find_block_of(int n)
return nstart;
}
// Error( LOCATION, "Couldn't find block of %d frames\n", n );
return -1;
}
@@ -677,8 +732,8 @@ int bm_load_and_parse_eff(char *filename, int dir_type, int *nframes, int *nfps,
int frames = 0, fps = 30, keyframe = 0, rval;
char ext[8];
ubyte c_type = BM_TYPE_NONE;
char file_text[50];
char file_text_raw[50];
char file_text[1024];
char file_text_raw[1024];
memset( ext, 0, sizeof(ext) );
memset( file_text, 0, sizeof(file_text) );
@@ -748,15 +803,18 @@ int bm_load_and_parse_eff(char *filename, int dir_type, int *nframes, int *nfps,
return 0;
}
// ------------------------------------------------------------------
// bm_load_animation()
//
// input: filename => filename of animation
// nframes => OUTPUT parameter: number of frames in the animation
// fps => OUTPUT/OPTIONAL parameter: intended fps for the animation
//
// returns: bitmap number of first frame in the animation
//
/**
* Load animation
*
* @param real_filename filename of animation
* @param nframes OUTPUT parameter: number of frames in the animation
* @param fps OUTPUT/OPTIONAL parameter: intended fps for the animation
* @param keyframe Keyframe number
* @param can_drop_frames Toggle to allow dropped frames
* @param dir_type Directory type
*
* @returns Bitmap number of first frame in the animation
*/
int bm_load_animation( char *real_filename, int *nframes, int *fps, int *keyframe, int can_drop_frames, int dir_type)
{
int i, n;
@@ -791,7 +849,6 @@ int bm_load_animation( char *real_filename, int *nframes, int *fps, int *keyfram
char *p = strchr( filename, '.' );
if ( p ) {
mprintf(( "Someone passed an extension to bm_load_animation for file '%s'\n", real_filename ));
//Int3();
*p = 0;
}
@@ -887,8 +944,8 @@ int bm_load_animation( char *real_filename, int *nframes, int *fps, int *keyfram
the_anim.keys[i].frame_num = 0;
cfread(&the_anim.keys[i].frame_num, 2, 1, img_cfp);
cfread(&the_anim.keys[i].offset, 4, 1, img_cfp);
the_anim.keys[i].frame_num = INTEL_INT( the_anim.keys[i].frame_num );
the_anim.keys[i].offset = INTEL_INT( the_anim.keys[i].offset );
the_anim.keys[i].frame_num = INTEL_INT( the_anim.keys[i].frame_num ); //-V570
the_anim.keys[i].offset = INTEL_INT( the_anim.keys[i].offset ); //-V570
}
//some retail anis have their keyframes reversed
key = MAX(the_anim.keys[0].frame_num, the_anim.keys[1].frame_num);
@@ -945,8 +1002,8 @@ int bm_load_animation( char *real_filename, int *nframes, int *fps, int *keyfram
anim_frames = i;
// update all previous frames with the new count
for (i=0; i<anim_frames; i++)
bm_bitmaps[n+i].info.ani.num_frames = anim_frames;
for (int j=0; j<anim_frames; j++)
bm_bitmaps[n+j].info.ani.num_frames = anim_frames;
break;
}
@@ -1031,7 +1088,10 @@ int bm_is_valid(int handle)
return (bm_bitmaps[handle % MAX_BITMAPS].handle == handle);
}
// Gets info. w,h,or flags,nframes or fps can be NULL if you don't care.
/**
* Gets info.
* w,h,flags,nframes or fps can be NULL if you don't care.
*/
int bm_get_info( int handle, int *w, int * h, ubyte * flags, int *nframes, int *fps)
{
bitmap * bmp;
@@ -1046,7 +1106,7 @@ int bm_get_info( int handle, int *w, int * h, ubyte * flags, int *nframes, int *
}
#endif
Assert( bm_bitmaps[bitmapnum].handle == handle ); // INVALID BITMAP HANDLE!
Assertion( bm_bitmaps[bitmapnum].handle == handle, "Invalid bitmap handle %d passed to bm_get_info().\nThis might be due to an invalid animation somewhere else.\n", handle ); // INVALID BITMAP HANDLE!
if ( (bm_bitmaps[bitmapnum].type == BM_TYPE_NONE) || (bm_bitmaps[bitmapnum].handle != handle) ) {
if (w) *w = 0;
@@ -1089,23 +1149,24 @@ unsigned int bm_get_signature(int handle)
if ( !bm_inited ) bm_init();
int bitmapnum = handle % MAX_BITMAPS;
Assert( bm_bitmaps[bitmapnum].handle == handle ); // INVALID BITMAP HANDLE
Assertion( bm_bitmaps[bitmapnum].handle == handle, "Invalid bitmap handle %d passed to bm_get_signature().\nThis might be due to an invalid animation somewhere else.\n", handle ); // INVALID BITMAP HANDLE!
return bm_bitmaps[bitmapnum].signature;
}
//gets the image type
/**
* Gets the image type
*/
ubyte bm_get_type(int handle)
{
if ( !bm_inited ) bm_init();
int bitmapnum = handle % MAX_BITMAPS;
Assert( bm_bitmaps[bitmapnum].handle == handle ); // INVALID BITMAP HANDLE
Assertion( bm_bitmaps[bitmapnum].handle == handle, "Invalid bitmap handle %d passed to bm_get_type().\nThis might be due to an invalid animation somewhere else.\n", handle ); // INVALID BITMAP HANDLE!
return bm_bitmaps[bitmapnum].type;
}
extern int palman_is_nondarkening(int r,int g, int b);
static void bm_convert_format( int bitmapnum, bitmap *bmp, ubyte bpp, ubyte flags )
{
int idx;
@@ -1201,12 +1262,14 @@ void bm_lock_ani( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, ubyt
nframes = bm_bitmaps[first_frame].info.ani.num_frames;
if ( (the_anim = anim_load(bm_bitmaps[first_frame].filename, bm_bitmaps[first_frame].dir_type)) == NULL ) {
// Error(LOCATION, "Error opening %s in bm_lock\n", be->filename);
nprintf(("BMPMAN", "Error opening %s in bm_lock\n", be->filename));
return;
}
if ( (the_anim_instance = init_anim_instance(the_anim, bpp)) == NULL ) {
// Error(LOCATION, "Error opening %s in bm_lock\n", be->filename);
nprintf(("BMPMAN", "Error opening %s in bm_lock\n", be->filename));
anim_free(the_anim);
return;
}
int can_drop_frames = 0;
@@ -1235,11 +1298,7 @@ void bm_lock_ani( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, ubyt
bm->data = (ptr_u)bm_malloc(first_frame + i, size);
frame_data = anim_get_next_raw_buffer(the_anim_instance, 0 ,flags & BMP_AABITMAP ? 1 : 0, bm->bpp);
if ( frame_data == NULL ) {
// Error(LOCATION,"Fatal error locking .ani file: %s\n", be->filename);
}
frame_data = anim_get_next_raw_buffer(the_anim_instance, 0 ,flags & BMP_AABITMAP ? 1 : 0, bm->bpp);
ubyte *dptr, *sptr;
@@ -1248,8 +1307,6 @@ void bm_lock_ani( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, ubyt
if ( (bm->w!=the_anim->width) || (bm->h!=the_anim->height) ) {
// Scale it down
// Int3(); // not ready yet - should only be ingame
// 8 bit
if(bpp == 8){
int w,h;
@@ -1307,8 +1364,6 @@ void bm_lock_ani( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, ubyt
if ( (i < nframes-1) && can_drop_frames ) {
frame_data = anim_get_next_raw_buffer(the_anim_instance, 0, flags & BMP_AABITMAP ? 1 : 0, bm->bpp);
}
//mprintf(( "Checksum = %d\n", be->palette_checksum ));
}
free_anim_instance(the_anim_instance);
@@ -1351,9 +1406,8 @@ void bm_lock_user( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, uby
break;
default:
Int3();
Error( LOCATION, "Unhandled user bitmap conversion from %d to %d bpp", be->info.user.bpp, bmp->bpp );
break;
// Error( LOCATION, "Unhandled user bitmap conversion from %d to %d bpp", be->info.user.bpp, bmp->bpp );
}
bm_convert_format( bitmapnum, bmp, bpp, flags );
@@ -1376,9 +1430,6 @@ void bm_lock_tga( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, ubyt
Assert( (bpp == 16) || (bpp == 24 ) || (bpp == 32) );
}
// should never try to make an aabitmap out of a targa
Assert(!(flags & BMP_AABITMAP));
// allocate bitmap data
byte_size = (bpp >> 3);
@@ -1421,7 +1472,9 @@ void bm_lock_tga( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, ubyt
bm_convert_format( bitmapnum, bmp, bpp, flags );
}
//lock a dds file
/**
* Lock a DDS file
*/
void bm_lock_dds( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, ubyte bpp, ubyte flags )
{
ubyte *data = NULL;
@@ -1485,7 +1538,9 @@ void bm_lock_dds( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, ubyt
#endif
}
// lock a PNG file
/**
* Lock a PNG file
*/
void bm_lock_png( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, ubyte bpp, ubyte flags )
{
ubyte *data = NULL;
@@ -1493,14 +1548,10 @@ void bm_lock_png( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, ubyt
int d_size;
int png_error = PNG_ERROR_INVALID;
char filename[MAX_FILENAME_LEN];
//int size = bmp->w * bmp->h * d_size;
// Unload any existing data
bm_free_data( bitmapnum );
// should never try to make an aabitmap out of a png
Assert(!(flags & BMP_AABITMAP));
// allocate bitmap data
Assert( bmp->w * bmp->h > 0 );
@@ -1534,7 +1585,9 @@ void bm_lock_png( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, ubyt
#endif
}
// lock a JPEG file
/**
* Lock a JPEG file
*/
void bm_lock_jpg( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, ubyte bpp, ubyte flags )
{
ubyte *data = NULL;
@@ -1545,9 +1598,6 @@ void bm_lock_jpg( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, ubyt
// Unload any existing data
bm_free_data( bitmapnum );
// should never try to make an aabitmap out of a jpeg
Assert(!(flags & BMP_AABITMAP));
d_size = (bpp >> 3);
// allocate bitmap data
@@ -1584,11 +1634,12 @@ void bm_lock_jpg( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, ubyt
MONITOR( NumBitmapPage )
MONITOR( SizeBitmapPage )
// This locks down a bitmap and returns a pointer to a bitmap
// that can be accessed until you call bm_unlock. Only lock
// a bitmap when you need it! This will convert it into the
// appropriate format also.
bitmap * bm_lock( int handle, ubyte bpp, ubyte flags )
/**
* This locks down a bitmap and returns a pointer to a bitmap that can be accessed until you call bm_unlock.
*
* Only lock a bitmap when you need it! This will convert it into the appropriate format also.
*/
bitmap * bm_lock( int handle, ubyte bpp, ubyte flags, bool nodebug)
{
bitmap *bmp;
bitmap_entry *be;
@@ -1597,15 +1648,7 @@ bitmap * bm_lock( int handle, ubyte bpp, ubyte flags )
int bitmapnum = handle % MAX_BITMAPS;
#ifndef NDEBUG
if(bm_bitmaps[bitmapnum].handle != handle) {
mprintf(("bm_lock - %s: bm_bitmaps[%d].handle = %d, handle = %d\n", bm_bitmaps[bitmapnum].filename, bitmapnum, bm_bitmaps[bitmapnum].handle, handle));
}
#endif
Assert( bm_bitmaps[bitmapnum].handle == handle ); // INVALID BITMAP HANDLE
// flags &= (~BMP_RLE);
Assertion( bm_bitmaps[bitmapnum].handle == handle, "Invalid handle %d passed to bm_lock. This might be due to an animation elsewhere in the code being too short.\n", handle ); // INVALID BITMAP HANDLE
// to fix a couple of OGL bpp passes, force 8bit on AABITMAP - taylor
if (flags & BMP_AABITMAP)
@@ -1656,7 +1699,7 @@ bitmap * bm_lock( int handle, ubyte bpp, ubyte flags )
#endif
// read the file data
if ( gr_bm_lock( be->filename, handle, bitmapnum, bpp, flags ) == -1 ) {
if ( gr_bm_lock( be->filename, handle, bitmapnum, bpp, flags, nodebug ) == -1 ) {
// oops, this isn't good - reset and return NULL
bm_unlock( bitmapnum );
bm_unload( bitmapnum );
@@ -1695,11 +1738,12 @@ bitmap * bm_lock( int handle, ubyte bpp, ubyte flags )
return bmp;
}
// Unlocks a bitmap
//
// Decrements the ref_count member of the bitmap_entry struct. A bitmap can only be unloaded
// when the ref_count is 0.
//
/**
* Unlocks a bitmap
*
* Decrements the ref_count member of the bitmap_entry struct. A bitmap can only be unloaded
* when the ref_count is 0.
*/
void bm_unlock( int handle )
{
bitmap_entry *be;
@@ -1726,11 +1770,6 @@ void bm_unlock( int handle )
Assert(be->ref_count >= 0); // Trying to unlock data more times than lock was called!!!
}
void bm_update()
{
}
char *bm_get_filename(int handle)
{
int n;
@@ -1760,16 +1799,19 @@ void bm_get_palette(int handle, ubyte *pal, char *name)
}
}
// --------------------------------------------------------------------------------------
// bm_release() - unloads the bitmap's data and entire slot, so bitmap 'n' won't be valid anymore
// NOTE: this releases the slot of EVERY frame in an ANI so don't pass any frame but the first
//
// parameters: n => index into bm_bitmaps ( index returned from bm_load() or bm_create() )
//
// returns: 1 on successful release, 0 otherwise
/**
* Unloads the bitmap's data and entire slot, so bitmap 'handle' won't be valid anymore
* NOTE: this releases the slot of EVERY frame in an ANI so don't pass any frame but the first
*
* @param handle index into ::bm_bitmaps ( index returned from bm_load() or bm_create() )
* @param clear_render_targets Whether to release a render target
*
* @return 1 on successful release, 0 otherwise
*/
int bm_release(int handle, int clear_render_targets)
{
Assert(handle >= 0);
bitmap_entry *be;
int n = handle % MAX_BITMAPS;
@@ -1863,15 +1905,15 @@ int bm_release(int handle, int clear_render_targets)
return 1;
}
// --------------------------------------------------------------------------------------
// bm_unload() - unloads the data, but not the bitmap info.
//
// parameters: n => index into bm_bitmaps ( index returned from bm_load() or bm_create() )
//
// returns: 0 => unload failed
// 1 => unload successful
//
int bm_unload( int handle, int clear_render_targets )
/**
* Unloads the data, but not the bitmap info.
*
* @param handle index into ::bm_bitmaps ( index returned from bm_load() or bm_create() )
* @param clear_render_targets Whether to release a render target
*
* @return 1 on successful release, 0 otherwise
*/
int bm_unload( int handle, int clear_render_targets, bool nodebug )
{
bitmap_entry *be;
bitmap *bmp;
@@ -1893,7 +1935,7 @@ int bm_unload( int handle, int clear_render_targets )
Assert( be->handle == handle ); // INVALID BITMAP HANDLE!
// If it is locked, cannot free it.
if (be->ref_count != 0) {
if (be->ref_count != 0 && !nodebug) {
nprintf(("BmpMan", "Tried to unload %s that has a lock count of %d.. not unloading\n", be->filename, be->ref_count));
return 0;
}
@@ -1905,7 +1947,7 @@ int bm_unload( int handle, int clear_render_targets )
if ( be->load_count > 0 )
be->load_count--;
if ( be->load_count != 0 ) {
if ( be->load_count != 0 && !nodebug) {
nprintf(("BmpMan", "Tried to unload %s that has a load count of %d.. not unloading\n", be->filename, be->load_count + 1));
return 0;
}
@@ -1921,20 +1963,25 @@ int bm_unload( int handle, int clear_render_targets )
return 1;
for (i = 0; i < bm_bitmaps[first].info.ani.num_frames; i++) {
nprintf(("BmpMan", "Unloading %s frame %d. %dx%dx%d\n", be->filename, i, bmp->w, bmp->h, bmp->bpp));
if(!nodebug)
nprintf(("BmpMan", "Unloading %s frame %d. %dx%dx%d\n", be->filename, i, bmp->w, bmp->h, bmp->bpp));
bm_free_data(first+i); // clears flags, bbp, data, etc
}
} else {
nprintf(("BmpMan", "Unloading %s. %dx%dx%d\n", be->filename, bmp->w, bmp->h, bmp->bpp));
if(!nodebug)
nprintf(("BmpMan", "Unloading %s. %dx%dx%d\n", be->filename, bmp->w, bmp->h, bmp->bpp));
bm_free_data(n); // clears flags, bbp, data, etc
}
return 1;
}
// just like bm_unload() except that it doesn't care about what load_count is
// and will just plow through and release the data anyway
// (NOTE that bm_free_data_fast() is used here and NOT bm_free_data()!)
/**
* Just like bm_unload() except that it doesn't care about what load_count is
* and will just plow through and release the data anyway
*
* NOTE: that bm_free_data_fast() is used here and NOT bm_free_data()!
*/
int bm_unload_fast( int handle, int clear_render_targets )
{
bitmap_entry *be;
@@ -1942,7 +1989,6 @@ int bm_unload_fast( int handle, int clear_render_targets )
int n = handle % MAX_BITMAPS;
Assert( (n >= 0) && (n < MAX_BITMAPS) );
be = &bm_bitmaps[n];
bmp = &be->bm;
@@ -1974,7 +2020,9 @@ int bm_unload_fast( int handle, int clear_render_targets )
return 1;
}
// unload all used bitmaps
/**
* Unload all used bitmaps
*/
void bm_unload_all()
{
int i;
@@ -2040,7 +2088,9 @@ DCF(bmpman,"Shows/changes bitmap caching parameters and usage")
}
}
// Marks a texture as being used for this level
/**
* Marks a texture as being used for this level
*/
void bm_page_in_texture( int bitmapnum, int nframes )
{
int i;
@@ -2092,9 +2142,12 @@ void bm_page_in_texture( int bitmapnum, int nframes )
}
}
// marks a texture as being a transparent textyre used for this level
// Marks a texture as being used for this level
// If num_frames is passed, assume this is an animation
/**
* Marks a texture as being a transparent texture used for this level
*
* @param bitmapnum Index into ::bm_bitmaps ( index returned from bm_load() or bm_create() )
* @param nframes Animation number of frames
*/
void bm_page_in_xparent_texture( int bitmapnum, int nframes)
{
int i;
@@ -2139,7 +2192,12 @@ void bm_page_in_xparent_texture( int bitmapnum, int nframes)
}
}
// Marks an aabitmap as being used for this level
/**
* Marks an aabitmap as being used for this level
*
* @param bitmapnum Index into ::bm_bitmaps ( index returned from bm_load() or bm_create() )
* @param nframes Animation number of frames
*/
void bm_page_in_aabitmap( int bitmapnum, int nframes )
{
int i;
@@ -2159,9 +2217,9 @@ void bm_page_in_aabitmap( int bitmapnum, int nframes )
}
}
// Tell the bitmap manager to start keeping track of what bitmaps are used where.
/**
* Tell the bitmap manager to start keeping track of what bitmaps are used where.
*/
void bm_page_in_start()
{
int i;
@@ -2259,12 +2317,13 @@ void bm_page_in_stop()
}
mprintf(( "Bmpman: %d/%d bitmap slots in use.\n", total_bitmaps, MAX_BITMAPS ));
//mprintf(( "Bmpman: Usage went from %d KB to %d KB.\n", usage_before/1024, usage_after/1024 ));
Bm_paging = 0;
}
// for unloading bitmaps while a mission is going
/**
* For unloading bitmaps while a mission is going
*/
int bm_page_out( int bitmap_id )
{
int n = bitmap_id % MAX_BITMAPS;
@@ -2275,7 +2334,6 @@ int bm_page_out( int bitmap_id )
if ( bm_bitmaps[n].type == BM_TYPE_NONE )
return 0;
Assert( bm_bitmaps[n].handle == bitmap_id ); // INVALID BITMAP HANDLE
// it's possible to hit < 0 here when model_page_out_textures() is called from
@@ -2361,7 +2419,9 @@ void bm_set_components_argb_32_tex(ubyte *pixel, ubyte *rv, ubyte *gv, ubyte *bv
*((unsigned int*)pixel) |= (unsigned int)(Gr_current_alpha->mask);
}
// for selecting pixel formats
/**
* For selecting pixel formats
*/
void BM_SELECT_SCREEN_FORMAT()
{
Gr_current_red = &Gr_red;
@@ -2401,7 +2461,9 @@ void BM_SELECT_ALPHA_TEX_FORMAT()
bm_set_components = bm_set_components_argb_16_tex;
}
// get the rgba components of a pixel, any of the parameters can be NULL
/**
* Get the rgba components of a pixel, any of the parameters can be NULL
*/
void bm_get_components(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a)
{
int bit_32 = 0;
@@ -2410,7 +2472,6 @@ void bm_get_components(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a)
bit_32 = 1;
}
if(r != NULL){
if(bit_32){
*r = ubyte(( (*((unsigned int*)pixel) & Gr_current_red->mask)>>Gr_current_red->shift)*Gr_current_red->scale);
@@ -2418,6 +2479,7 @@ void bm_get_components(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a)
*r = ubyte(( ( ((unsigned short*)pixel)[0] & Gr_current_red->mask)>>Gr_current_red->shift)*Gr_current_red->scale);
}
}
if(g != NULL){
if(bit_32){
*g = ubyte(( (*((unsigned int*)pixel) & Gr_current_green->mask) >>Gr_current_green->shift)*Gr_current_green->scale);
@@ -2425,6 +2487,7 @@ void bm_get_components(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a)
*g = ubyte(( ( ((unsigned short*)pixel)[0] & Gr_current_green->mask) >>Gr_current_green->shift)*Gr_current_green->scale);
}
}
if(b != NULL){
if(bit_32){
*b = ubyte(( (*((unsigned int*)pixel) & Gr_current_blue->mask)>>Gr_current_blue->shift)*Gr_current_blue->scale);
@@ -2444,7 +2507,9 @@ void bm_get_components(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a)
}
}
// get filename
/**
* Get filename
*/
void bm_get_filename(int bitmapnum, char *filename)
{
if(!bm_is_valid(bitmapnum))
@@ -2459,7 +2524,9 @@ void bm_get_filename(int bitmapnum, char *filename)
strcpy(filename, bm_bitmaps[n].filename);
}
// needed only for compressed bitmaps
/**
* Needed only for compressed bitmaps
*/
int bm_is_compressed(int num)
{
int n = num % MAX_BITMAPS;
@@ -2515,17 +2582,17 @@ int bm_has_alpha_channel(int handle)
return (bm_bitmaps[n].bm.true_bpp == 32);
}
// the only real purpose for this is to return the correct TCACHE_TYPE for compressed graphics,
// uncompressed graphics are assumed to be of type NORMAL. The only other real format to check
// for is TCACHE_TYPE_SECTIONED - taylor
/**
* Purpose for this is to return the correct TCACHE_TYPE for compressed graphics,
* uncompressed graphics are assumed to be of type NORMAL.
*
* The only other real format to check for is TCACHE_TYPE_SECTIONED - taylor
*/
int bm_get_tcache_type(int num)
{
if ( bm_is_compressed(num) )
return TCACHE_TYPE_COMPRESSED;
// if ( bm_is_render_target(num) )
// return TCACHE_TYPE_RENDER_TARGET;
return TCACHE_TYPE_NORMAL;
}
@@ -2552,7 +2619,9 @@ int bm_get_num_mipmaps(int num)
return bm_bitmaps[n].num_mipmaps;
}
// convert an 8-bit (256 color) image to a 24-bit BGR image sending new bitmap data to "out_data"
/**
* Convert an 8-bit (256 color) image to a 24-bit BGR image sending new bitmap data to "out_data"
*/
int bm_convert_color_index_to_BGR(int num, ubyte **out_data)
{
int n = num % MAX_BITMAPS;
@@ -2635,8 +2704,10 @@ int bm_convert_color_index_to_BGR(int num, ubyte **out_data)
return 0;
}
// list of all bitmaps loaded, but not necessarily in memory
// used to debug bmpman after a mission load
/**
* List of all bitmaps loaded, but not necessarily in memory
* used to debug bmpman after a mission load
*/
void bm_print_bitmaps()
{
#ifdef BMPMAN_NDEBUG
@@ -2655,12 +2726,11 @@ void bm_print_bitmaps()
#endif
}
// this will create a render target as close to the desiered resolution as posable of the following base types:
// this will create a render target as close to the desired resolution as possable of the following base types:
// - BMP_FLAG_RENDER_TARGET_STATIC
// static render targets are ones that you intend to draw to once or not very often in game
// - BMP_FLAG_RENDER_TARGET_DYNAMIC
// dynamic render targets are ones that you will be drawing to all the time (like once per frame)
int bm_make_render_target( int width, int height, int flags )
{
int i, n;
@@ -2685,11 +2755,9 @@ int bm_make_render_target( int width, int height, int flags )
if ( n == -1 )
return -1;
if ( !gr_bm_make_render_target(n, &w, &h, &bpp, &mm_lvl, flags) )
return -1;
Assert( mm_lvl > 0 );
if (flags & BMP_FLAG_RENDER_TARGET_STATIC) {
@@ -2732,7 +2800,6 @@ int bm_make_render_target( int width, int height, int flags )
if (bm_bitmaps[n].mem_taken) {
bm_bitmaps[n].bm.data = (ptr_u) bm_malloc(n, bm_bitmaps[n].mem_taken);
}
// bm_update_memory_used( n, bm_bitmaps[n].mem_taken );
return bm_bitmaps[n].handle;
}
@@ -2766,7 +2833,7 @@ int bm_set_render_target(int handle, int face)
if ( gr_bm_set_render_target(n, face) ) {
if (gr_screen.rendering_to_texture == -1) {
//if we are moveing from the back buffer to a texture save whatever the current settings are
//if we are moving from the back buffer to a texture save whatever the current settings are
gr_screen.save_max_w = gr_screen.max_w;
gr_screen.save_max_h = gr_screen.max_h;
}
+6 -10
View File
@@ -19,11 +19,6 @@
#define BMPMAN_NDEBUG
#endif
// this is causing problems - let's UP IT -- Kazan
// bumped from 3500 to 4500 2004/09/21 - taylor
// bumped to 4750 2005/02/03 - taylor
//#define MAX_BITMAPS 3500 // How many bitmaps the game can handle
#define MAX_BITMAPS 4750 // How many bitmaps the game can handle
// NOTE: MAX_BITMAPS shouldn't need to be bumped again. With the fixed bm_release() and it's
// proper use even the largest missions should stay under this number. With the largest retail
@@ -113,7 +108,7 @@ int bm_create( int bpp, int w, int h, void *data = NULL, int flags = 0);
// Frees up a bitmap's data, but bitmap number 'n' can
// still be used, it will just have to be paged in next
// time it is locked.
int bm_unload( int n, int clear_render_targets = 0 );
int bm_unload( int n, int clear_render_targets = 0, bool nodebug = false);
// like bm_unload() except that it's safe to use to free data without worrying about
// load_count so it's safe to use in relation to bm_release() and in gr_*_texture functions
@@ -137,7 +132,7 @@ extern int bm_load_either(char *filename, int *nframes = NULL, int *fps = NULL,
// that can be accessed until you call bm_unlock. Only lock
// a bitmap when you need it! This will convert it into the
// appropriate format also.
extern bitmap * bm_lock( int bitmapnum, ubyte bpp, ubyte flags );
extern bitmap * bm_lock( int bitmapnum, ubyte bpp, ubyte flags, bool nodebug = false);
// The signature is a field that gets filled in with
// a unique signature for each bitmap. The signature for each bitmap
@@ -160,9 +155,6 @@ int bm_get_info( int bitmapnum, int *w=NULL, int * h=NULL, ubyte * flags=NULL, i
// get filename
extern void bm_get_filename(int bitmapnum, char *filename);
// resyncs all the bitmap palette
extern void bm_update();
// call to load all data for all bitmaps that have been requested to be loaded
extern void bm_gfx_load_all();
extern void bm_unload_all();
@@ -179,6 +171,9 @@ void bm_gfx_get_pixel( int bitmap, float u, float v, ubyte *r, ubyte *g, ubyte *
// nnew = number of bytes of bitmaps locked this frame that weren't locked last frame
void bm_get_frame_usage(int *ntotal, int *nnew);
// Reload a different image into an existing bmpman slot
int bm_reload(int bitmap_handle, char* filename);
/*
* Example on using bm_create
*
@@ -287,4 +282,5 @@ int bm_make_render_target( int width, int height, int flags );
int bm_is_render_target(int bitmap_id);
int bm_set_render_target(int handle, int face = -1);
int bm_load_and_parse_eff(char *filename, int dir_type, int *nframes, int *nfps, int *key, ubyte *type);
#endif
+36 -216
View File
@@ -24,16 +24,12 @@ SCP_vector<camera*> Cameras;
camid Current_camera;
camid Main_camera;
//*************************INTERNAL FUNCS*************************
//static avd_camera *cam_upgrade_to_avd(camera *cam);
//*************************CLASS: camera*************************
//This is where the camera class beings! :D
camera::camera(char *in_name, int in_signature)
{
set_name(in_name);
sig = in_signature;
// flags = CAM_DEFAULT_FLAGS;
reset();
}
@@ -75,31 +71,11 @@ void camera::reset()
pos_y.clear();
pos_z.clear();
/*
ori_p.clear();
ori_b.clear();
ori_h.clear();
*/
/*
ori_progress.clear();
ori_initial = ori_final = vmd_identity_matrix;
*/
for(int i = 0; i < 9; i++)
{
ori[i].clear();
ori[i].set(vmd_identity_matrix.a1d[i]);
}
/*
flags = CAM_DEFAULT_FLAGS;
desired_position = position = vmd_zero_vector;
translation_velocity = translation_vel_limit = translation_acc_limit = vmd_zero_vector;
vm_set_identity(&orientation);
vm_set_identity(&desired_orientation);
rotation_rate = rotation_vel_limit = rotation_acc_limit = vmd_zero_vector;
*/
}
void camera::set_name(char *in_name)
@@ -144,15 +120,19 @@ void camera::set_object_target(object *objp, int n_object_target_submodel)
object_target_submodel = n_object_target_submodel;
}
//Custom function receives the already-modified current position value.
//It should be replaced or added to as the custom function modifier sees fit.
/**
* Custom function receives the already-modified current position value.
* It should be replaced or added to as the custom function modifier sees fit.
*/
void camera::set_custom_position_function(void (*n_func_custom_position)(camera *cam, vec3d *camera_pos))
{
func_custom_position = n_func_custom_position;
}
//Custom function receives the already-modified current orientation value.
//It should be replaced or added to as the custom function modifier sees fit.
/**
* Custom function receives the already-modified current orientation value.
* It should be replaced or added to as the custom function modifier sees fit.
*/
void camera::set_custom_orientation_function(void (*n_func_custom_orientation)(camera *cam, matrix *camera_ori))
{
func_custom_orientation = n_func_custom_orientation;
@@ -212,26 +192,6 @@ void camera::set_rotation(matrix *in_orientation, float in_rotation_time, float
for(int i = 0; i < 9; i++)
ori[i].setAVD(in_orientation->a1d[i], in_rotation_time, in_rotation_acceleration_time, in_rotation_deceleration_time, 0.0f);
//WMC - This stationary check is here because it's a lot more
//accurate to directly save the matrix, if we've been provided one.
//IMPORTANT: Without this chunk, the HUD and view waves around with
// the main camera.
/*
angles a;
vm_extract_angles_matrix(&a, in_orientation);
if(in_rotation_time == 0.0f && in_rotation_acceleration_time == 0.0f)
{
c_ori = *in_orientation;
ori_p.set(a.p);
ori_b.set(a.b);
ori_h.set(a.h);
flags |= CAM_STATIONARY_ORI;
return;
}
//Continue on
this->set_rotation(&a, in_rotation_time, in_rotation_acceleration_time);
*/
}
void camera::set_rotation(angles *in_angles, float in_rotation_time, float in_rotation_acceleration_time, float in_rotation_deceleration_time)
@@ -239,33 +199,6 @@ void camera::set_rotation(angles *in_angles, float in_rotation_time, float in_ro
matrix mtx = IDENTITY_MATRIX;
vm_rotate_matrix_by_angles(&mtx, in_angles);
this->set_rotation(&mtx, in_rotation_time, in_rotation_acceleration_time, in_rotation_deceleration_time);
/*
if(in_rotation_time == 0.0f && in_rotation_acceleration_time == 0.0f)
{
ori_p.set(in_angles->p);
ori_b.set(in_angles->b);
ori_h.set(in_angles->h);
c_ori = vmd_identity_matrix;
vm_rotate_matrix_by_angles(&c_ori, in_angles);
flags |= CAM_STATIONARY_ORI;
return;
}
flags &= ~CAM_STATIONARY_ORI;
if(in_angles == NULL)
{
ori_p.setVD(in_rotation_time, in_rotation_acceleration_time, 0.0f);
ori_b.setVD(in_rotation_time, in_rotation_acceleration_time, 0.0f);
ori_h.setVD(in_rotation_time, in_rotation_acceleration_time, 0.0f);
return;
}
ori_p.setAVD(in_angles->p, in_rotation_time, in_rotation_acceleration_time, in_rotation_acceleration_time, 0.0f);
ori_b.setAVD(in_angles->b, in_rotation_time, in_rotation_acceleration_time, in_rotation_acceleration_time, 0.0f);
ori_h.setAVD(in_angles->h, in_rotation_time, in_rotation_acceleration_time, in_rotation_acceleration_time, 0.0f);
*/
}
void camera::set_rotation_facing(vec3d *in_target, float in_rotation_time, float in_rotation_acceleration_time, float in_rotation_deceleration_time)
@@ -294,27 +227,6 @@ void camera::set_rotation_facing(vec3d *in_target, float in_rotation_time, float
void camera::set_rotation_velocity(angles *in_rotation_rate, float in_acceleration_time)
{
Error(LOCATION, "This function is disabled until further notice.");
/*
ori_p.setVD(in_acceleration_time, in_acceleration_time, in_rotation_rate->p);
ori_b.setVD(in_acceleration_time, in_acceleration_time, in_rotation_rate->b);
ori_h.setVD(in_acceleration_time, in_acceleration_time, in_rotation_rate->h);
*/
/*if(in_rotation_rate == NULL)
{
rotation_rate.p = rotation_rate.b = rotation_rate.h = 0.0f;
rotation_rate_delta_time = rotation_rate_delta_time_left = in_rotation_acceleration_time = 0.0f;
rotation_rate_decel_time_til = -1.0f;
return;
}
rotation_rate_delta_time = rotation_rate_delta_time_left = in_rotation_acceleration_time;
rotation_rate_decel_time_til = -1.0f;
rotation_rate_delta.p = in_rotation_rate->p / in_rotation_acceleration_time;
rotation_rate_delta.b = in_rotation_rate->b / in_rotation_acceleration_time;
rotation_rate_delta.h = in_rotation_rate->h / in_rotation_acceleration_time;*/
}
void camera::do_frame(float in_frametime)
@@ -360,7 +272,6 @@ float camera::get_fov()
void camera::get_info(vec3d *position, matrix *orientation)
{
//WTF?
if(position == NULL && orientation == NULL)
return;
@@ -452,17 +363,6 @@ void camera::get_info(vec3d *position, matrix *orientation)
c_ori = vmd_identity_matrix;
}
//Do human interaction
//WMC - Nevermind for now, maybe toggleable later.
/*
if ( Viewer_obj == object_host.objp || Viewer_mode & VM_CHASE ) {
if ( Viewer_mode & VM_PADLOCK_ANY ) {
player_get_padlock_orient(&c_ori);
} else {
compute_slew_matrix(&c_ori, &Viewer_slew_angles);
}
}*/
matrix mtxA = c_ori;
matrix mtxB = IDENTITY_MATRIX;
float pos = 0.0f;
@@ -474,15 +374,6 @@ void camera::get_info(vec3d *position, matrix *orientation)
vm_matrix_x_matrix(&c_ori, &mtxA, &mtxB);
vm_orthogonalize_matrix(&c_ori);
/*
angles a;
ori_p.get(&a.p, NULL);
ori_b.get(&a.b, NULL);
ori_h.get(&a.h, NULL);
vm_rotate_matrix_by_angles(&c_ori, &a);
*/
//vm_angles_2_matrix(&c_ori, &a);
}
//Do custom orientation stuff, if needed
if(func_custom_orientation != NULL)
@@ -492,6 +383,7 @@ void camera::get_info(vec3d *position, matrix *orientation)
*orientation = c_ori;
}
}
//*************************warp_camera*************************
warp_camera::warp_camera()
{
@@ -504,16 +396,7 @@ warp_camera::warp_camera(object *objp)
vec3d object_pos = objp->pos;
matrix tmp;
ship_get_eye(&object_pos, &tmp, objp);
/*
//matrix tmp_m = vmd_identity_matrix;
camid cid = ship_get_eye( objp );
if(cid.isValid())
{
camera *cam = cid.getCamera();
cam->get_info(&player_pos, NULL);
//tmp_m = *cam->get_orientation();
}
*/
vm_vec_scale_add2( &object_pos, &Player_obj->orient.vec.rvec, 0.0f );
vm_vec_scale_add2( &object_pos, &Player_obj->orient.vec.uvec, 0.952f );
vm_vec_scale_add2( &object_pos, &Player_obj->orient.vec.fvec, -1.782f );
@@ -559,7 +442,6 @@ void warp_camera::set_velocity( vec3d *in_vel, bool instantaneous )
}
//
void warp_camera::do_frame(float in_frametime)
{
vec3d new_vel, delta_pos;
@@ -570,8 +452,6 @@ void warp_camera::do_frame(float in_frametime)
c_vel = new_vel;
// mprintf(( "Camera velocity = %.1f,%.1f, %.1f\n", Camera_velocity.xyz.x, Camera_velocity.xyz.y, Camera_velocity.xyz.z ));
vm_vec_add2( &c_pos, &delta_pos );
float ot = c_time+0.0f;
@@ -591,9 +471,6 @@ void warp_camera::do_frame(float in_frametime)
tmp.xyz.x = 22.0f * (float)sin(tmp_angle);
tmp.xyz.y = -22.0f * (float)cos(tmp_angle);
//mprintf(( "Angle = %.1f, vx=%.1f, vy=%.1f\n", tmp_angle, tmp.xyz.x, tmp.xyz.y ));
//mprintf(( "Changing velocity!\n" ));
this->set_velocity( &tmp, 0 );
}
@@ -628,9 +505,9 @@ subtitle::subtitle(int in_x_pos, int in_y_pos, char* in_text, char* in_imageanim
return;
char text_buf[256];
if (in_text != NULL && strlen(in_text) > 0)
if (in_text != NULL && in_text[0] != '\0')
{
strcpy(text_buf, in_text);
strcpy_s(text_buf, in_text);
sexp_replace_variable_names_with_values(text_buf, 256);
in_text = text_buf;
}
@@ -641,7 +518,7 @@ subtitle::subtitle(int in_x_pos, int in_y_pos, char* in_text, char* in_imageanim
int text_line_lens[MAX_SUBTITLE_LINES];
//Setup text
if ( (in_text != NULL) && (strlen(in_text) > 0) ) {
if ( (in_text != NULL) && (in_text[0] != '\0') ) {
int split_width = (in_width > 0) ? in_width : 200;
num_text_lines = split_str(in_text, split_width, text_line_lens, text_line_ptrs, MAX_SUBTITLE_LINES);
@@ -665,7 +542,7 @@ subtitle::subtitle(int in_x_pos, int in_y_pos, char* in_text, char* in_imageanim
fade_time = fl_abs(in_fade_time);
//Setup image
if ( (in_imageanim != NULL) && (strlen(in_imageanim) > 0) )
if ( (in_imageanim != NULL) && (in_imageanim[0] != '\0') )
{
image_id = bm_load(in_imageanim);
@@ -791,9 +668,10 @@ void subtitle::do_frame(float frametime)
int x = text_pos.x;
int y = text_pos.y;
for(unsigned int i = 0; i < text_lines.size(); i++)
for(SCP_vector<std::string>::iterator line = text_lines.begin(); line != text_lines.end(); ++line)
{
gr_string(x, y, (char*)text_lines[i].c_str(), false);
gr_string(x, y, (char*)line->c_str(), false);
y += font_height;
}
@@ -843,11 +721,8 @@ subtitle::~subtitle()
void subtitle::clone(const subtitle &sub)
{
uint i = 0;
for (i = 0; i < sub.text_lines.size(); i++) {
text_lines.push_back(sub.text_lines[i]);
}
text_lines = sub.text_lines;
text_fontnum = sub.text_fontnum;
// copy the structs
@@ -921,7 +796,7 @@ int camid::getSignature()
bool camid::isValid()
{
if(idx < 0 || idx >= Cameras.size())
if(idx >= Cameras.size())
return false;
if(Cameras[idx] == NULL)
@@ -944,14 +819,6 @@ void cam_close()
{
//Set Current_camera to nothing
Current_camera = camid();
for(unsigned int i = 0; i < Cameras.size(); i++)
{
if(Cameras[i] != NULL)
{
delete Cameras[i];
Cameras[i] = NULL;
}
}
Cameras.clear();
}
@@ -984,29 +851,9 @@ camid cam_create(char *n_name, vec3d *n_pos, matrix *n_ori, object *n_object, in
strncpy(buf, n_name, NAME_LENGTH-1);
//Find a free slot
for(uint i = 0; i < Cameras.size(); i++)
{
if(Cameras[i] == NULL)
{
cam = new camera(buf, sig);
cid = camid(i, sig);
Cameras[i] = cam;
break;
}
else if(Cameras[i]->is_empty())
{
delete Cameras[i];
cam = new camera(buf, sig);
cid = camid(i, sig);
Cameras[i] = cam;
}
}
if(cam == NULL)
{
cam = new camera(buf, sig);
cid = camid(Cameras.size(), sig);
Cameras.push_back(cam);
}
cam = new camera(buf, sig);
cid = camid(Cameras.size(), sig);
Cameras.push_back(cam);
//Set attributes
if(n_pos != NULL)
@@ -1029,7 +876,7 @@ void cam_delete(camid cid)
void cam_do_frame(float frametime)
{
unsigned int i,size=Cameras.size();
size_t i,size=Cameras.size();
for(i = 0; i < size; i++)
{
if(Cameras[i] != NULL)
@@ -1039,7 +886,7 @@ void cam_do_frame(float frametime)
camid cam_get_camera(uint idx)
{
if(idx < 0 || idx >= Cameras.size())
if(idx >= Cameras.size())
return camid();
return camid(idx, Cameras[idx]->get_signature());
@@ -1055,10 +902,12 @@ uint cam_get_num()
return Cameras.size();
}
//Looks up camera by name, returns -1 on failure
/**
* Looks up camera by name, returns -1 on failure
*/
camid cam_lookup(char *name)
{
unsigned int i,size=Cameras.size();
size_t i, size=Cameras.size();
for(i = 0; i < size; i++)
{
if(Cameras[i] != NULL && !stricmp(Cameras[i]->get_name(), name))
@@ -1098,35 +947,6 @@ void cam_reset_camera()
Camera_hud_draw_saved = false;
}
//Functions must delete the original camera after calling this function.
//Note that due to the esoteric nature of this function, it should not
//be used outside camera.cpp
/*
static avd_camera *cam_upgrade_to_avd(camera *cam)
{
for(uint i = 0; i < Cameras.size(); i++)
{
if(Cameras[i] == cam)
break;
}
if(i == Cameras.size())
return NULL;
avd_camera *avdcam = new avd_camera(cam);
//Make the switch
Cameras[i] = avdcam;
return avdcam;
}
*/
void subtitles_init()
{
//Do nothing!!
}
void subtitles_close()
{
Subtitles.clear();
@@ -1134,20 +954,20 @@ void subtitles_close()
void subtitles_do_frame(float frametime)
{
unsigned int i,size=Subtitles.size();
for(i = 0; i < size; i++)
SCP_vector<subtitle>::iterator sub;
for(sub = Subtitles.begin(); sub != Subtitles.end(); ++sub)
{
if ( !Subtitles[i].is_post_shaded( ) )
Subtitles[i].do_frame(frametime);
if ( !sub->is_post_shaded( ) )
sub->do_frame(frametime);
}
}
void subtitles_do_frame_post_shaded(float frametime)
{
unsigned int i,size=Subtitles.size();
for(i = 0; i < size; i++)
SCP_vector<subtitle>::iterator sub;
for(sub = Subtitles.begin(); sub != Subtitles.end(); ++sub)
{
if ( Subtitles[i].is_post_shaded( ) )
Subtitles[i].do_frame(frametime);
if ( sub->is_post_shaded( ) )
sub->do_frame(frametime);
}
}
-9
View File
@@ -33,17 +33,9 @@ protected:
void (*func_custom_orientation)(camera *cam, matrix *ori);
avd_movement fov;
avd_movement pos_x;
avd_movement pos_y;
avd_movement pos_z;
//avd_movement ori_p;
//avd_movement ori_b;
//avd_movement ori_h;
//avd_movement ori_progress;
//matrix ori_initial;
//matrix ori_final;
avd_movement ori[9];
//Cache stuff
@@ -176,7 +168,6 @@ camid cam_get_camera(uint index);
camid cam_get_current();
uint cam_get_num();
void subtitles_init();
void subtitles_close();
void subtitles_do_frame(float frametime);
void subtitles_do_frame_post_shaded(float frametime);
+53 -63
View File
@@ -52,7 +52,7 @@ cf_pathtype Pathtypes[CF_MAX_PATH_TYPES] = {
{ CF_TYPE_INVALID, NULL, NULL, CF_TYPE_INVALID },
// Root must be index 1!!
{ CF_TYPE_ROOT, "", ".mve .ogg", CF_TYPE_ROOT },
{ CF_TYPE_DATA, "data", ".cfg .log .txt", CF_TYPE_ROOT },
{ CF_TYPE_DATA, "data", ".cfg .txt", CF_TYPE_ROOT },
{ CF_TYPE_MAPS, "data" DIR_SEPARATOR_STR "maps", ".pcx .ani .eff .tga .jpg .png .dds", CF_TYPE_DATA },
{ CF_TYPE_TEXT, "data" DIR_SEPARATOR_STR "text", ".txt .net", CF_TYPE_DATA },
{ CF_TYPE_MODELS, "data" DIR_SEPARATOR_STR "models", ".pof", CF_TYPE_DATA },
@@ -78,7 +78,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", CF_TYPE_PLAYERS },
{ CF_TYPE_MULTI_PLAYERS, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "multi", ".plr", CF_TYPE_PLAYERS },
{ CF_TYPE_CACHE, "data" DIR_SEPARATOR_STR "cache", ".clr .tmp .ibx .tsb", CF_TYPE_DATA }, //clr=cached color
{ 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 .dds .fs2 .txt", CF_TYPE_DATA },
{ CF_TYPE_MISSIONS, "data" DIR_SEPARATOR_STR "missions", ".fs2 .fc2 .ntl .ssv", CF_TYPE_DATA },
{ CF_TYPE_CONFIG, "data" DIR_SEPARATOR_STR "config", ".cfg", CF_TYPE_DATA },
@@ -147,9 +147,14 @@ int cfile_in_root_dir(char *exe_path)
token_count++;
tok = strtok(NULL, DIR_SEPARATOR_STR);
} while(tok != NULL);
// root directory if we have <= 1 slash
#ifdef SCP_UNIX
// /freespace works, / does not
if(token_count <= 1) {
#else
// C:/freespace works, C:/ does not
if(token_count <= 2){
#endif
return 1;
}
@@ -813,53 +818,6 @@ CFILE *cfopen_special(char *file_path, char *mode, const int size, const int off
// it's a normal file
return cf_open_fill_cfblock(fp, dir_type);
}
/* char longname[_MAX_PATH];
if ( !cfile_inited ) {
Int3();
return NULL;
}
//================================================
// Check that all the parameters make sense
Assert( file_path && strlen(file_path) );
Assert( mode != NULL );
if ( (ext_num <= 0) || (!ext_list) ) {
Int3();
return NULL;
}
// cfopen_ext() only supports reading files, not creating them
if ( strchr(mode, 'w') ) {
Int3();
return NULL;
}
//================================================
// Search for file on disk, on cdrom, or in a packfile
int offset, size;
char copy_file_path[MAX_PATH_LEN]; // FIX change in memory from cf_find_file_location
strcpy_s(copy_file_path, file_path);
if ( cf_find_file_location_ext(copy_file_path, ext_num, ext_list, dir_type, sizeof(longname) - 1, longname, &size, &offset, localize) ) {
// Fount it, now create a cfile out of it
FILE *fp = fopen( longname, "rb" );
if ( fp ) {
if ( offset ) {
// Found it in a pack file
return cf_open_packed_cfblock(fp, dir_type, offset, size );
} else {
// Found it in a normal file
return cf_open_fill_cfblock(fp, dir_type);
}
}
}
return NULL;*/
}
@@ -1003,6 +961,7 @@ CFILE *cf_open_fill_cfblock(FILE *fp, int type)
cfbp->data = NULL;
cfbp->fp = fp;
cfbp->dir_type = type;
cfbp->max_read_len = 0;
int pos = ftell(fp);
if(pos == -1L)
@@ -1040,6 +999,7 @@ CFILE *cf_open_packed_cfblock(FILE *fp, int type, int offset, int size)
cfbp->data = NULL;
cfbp->fp = fp;
cfbp->dir_type = type;
cfbp->max_read_len = 0;
cf_init_lowlevel_read_code(cfp,offset, size, 0 );
@@ -1077,6 +1037,8 @@ CFILE *cf_open_mapped_fill_cfblock(FILE *fp, int type)
cfp = &Cfile_list[cfile_block_index];
cfp->id = cfile_block_index;
cfp->version = 0;
cfbp->max_read_len = 0;
cfbp->fp = NULL;
#if defined _WIN32
cfbp->hInFile = hFile;
@@ -1140,6 +1102,22 @@ void cf_set_version( CFILE * cfile, int version )
cfile->version = version;
}
// cutoff point where cfread() will throw an error when it hits this limit
// if 'len' is 0 then this check will be disabled
void cf_set_max_read_len( CFILE * cfile, size_t len )
{
Assert( cfile != NULL );
Assert( (cfile->id >= 0) && (cfile->id < MAX_CFILE_BLOCKS) );
Cfile_block *cb = &Cfile_block_list[cfile->id];
if (len) {
cb->max_read_len = cb->raw_position + len;
} else {
cb->max_read_len = 0;
}
}
// routines to read basic data types from CFILE's. Put here to
// simplify mac/pc reading from cfiles.
@@ -1288,7 +1266,7 @@ void cfread_string_len(char *buf,int n, CFILE *file)
{
int len;
len = cfread_int(file);
Assert( len < n );
Assertion( (len < n), "len: %i, n: %i", len, n );
if (len)
cfread(buf, len, 1, file);
@@ -1371,7 +1349,7 @@ int cfwrite_string(char *buf, CFILE *file)
return cfwrite_char(0, file); // write out NULL termination
}
int cfwrite_string_len(char *buf, CFILE *file)
int cfwrite_string_len(const char *buf, CFILE *file)
{
int len = strlen(buf);
@@ -1407,7 +1385,7 @@ int cfilelength( CFILE * cfile )
// returns: number of full elements actually written
//
//
int cfwrite(void *buf, int elsize, int nelem, CFILE *cfile)
int cfwrite(const void *buf, int elsize, int nelem, CFILE *cfile)
{
if(!cf_is_valid(cfile))
return 0;
@@ -1429,18 +1407,22 @@ int cfwrite(void *buf, int elsize, int nelem, CFILE *cfile)
return EOF;
}
int result = 0;
size_t bytes_written = 0;
size_t size = elsize * nelem;
result = fwrite(buf, elsize, nelem, cb->fp);
bytes_written = fwrite(buf, 1, size, cb->fp);
//WMC - update filesize and position
if(result > 0)
{
cb->size = filelength(fileno(cb->fp));
cb->raw_position += result;
if (bytes_written > 0) {
cb->size += bytes_written;
cb->raw_position += bytes_written;
}
return result;
#if defined(CHECK_SIZE) && !defined(NDEBUG)
Assert( cb->size == filelength(fileno(cb->fp)) );
#endif
return ((int)bytes_written / elsize);
}
@@ -1476,10 +1458,14 @@ int cfputc(int c, CFILE *cfile)
//WMC - update filesize and position
if(result != EOF)
{
cb->size = filelength(fileno(cb->fp));
cb->size += 1;
cb->raw_position += 1;
}
#if defined(CHECK_SIZE) && !defined(NDEBUG)
Assert( cb->size == filelength(fileno(cb->fp)) );
#endif
return result;
}
@@ -1516,10 +1502,14 @@ int cfputs(char *str, CFILE *cfile)
//WMC - update filesize and position
if(result != EOF)
{
cb->size = filelength(fileno(cb->fp));
cb->size += strlen(str);
cb->raw_position += strlen(str);
}
#if defined(CHECK_SIZE) && !defined(NDEBUG)
Assert( cb->size == filelength(fileno(cb->fp)) );
#endif
return result;
}
+72 -6
View File
@@ -16,6 +16,9 @@
#include <time.h>
#include "globalincs/pstypes.h"
#include <stdexcept>
#define CF_EOF (-1)
#define CF_SEEK_SET (0)
@@ -98,6 +101,11 @@ typedef struct {
// to add file to list, or 0 to not add it.
extern int (*Get_file_list_filter)(char *filename);
// extra check for child directory under CF_TYPE_*
// NOTE: if specified cf_get_file_list() will not search pack files!
// NOTE: specified string must not contain ':' or spaces or begin with DIR_SEPARATOR!
extern const char *Get_file_list_child;
// cfile directory. valid after cfile_init() returns successfully
#define CFILE_ROOT_DIRECTORY_LEN 256
extern char Cfile_root_dir[CFILE_ROOT_DIRECTORY_LEN];
@@ -135,6 +143,11 @@ int cflush(CFILE *cfile);
// open a file. Once set, you can use minimum version numbers with the read functions.
void cf_set_version( CFILE * cfile, int version );
// will throw an error if cfread*() functions read past this mark
// converted to raw offsets when used, but gets passed actual length from current position
// setting 'len' to zero will disable the check
void cf_set_max_read_len(CFILE *cfile, size_t len);
// Deletes a file. Returns 0 on error, 1 if successful
int cf_delete(char *filename, int dir_type);
@@ -168,7 +181,7 @@ int cfilelength(CFILE *fp);
int cfread(void *buf, int elsize, int nelem, CFILE *fp);
// cfwrite() writes to the file
int cfwrite(void *buf, int elsize, int nelem, CFILE *cfile);
int cfwrite(const void *buf, int elsize, int nelem, CFILE *cfile);
// Reads/writes RLE compressed data.
int cfread_compressed(void *buf, int elsize, int nelem, CFILE *cfile);
@@ -258,8 +271,15 @@ void cfread_angles(angles *ang, CFILE *file, int ver = 0, angles *deflt = NULL);
// Reads variable length, null-termined string. Will only read up
// to n characters.
void cfread_string(char *buf,int n, CFILE *file);
// Read a fixed length that is null-terminatedm, and has the length
// stored in file
/**
* @brief Read a fixed length string that is not null-terminated, with the length stored in file
*
* @param buf Pre-allocated array to store string
* @param n 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);
// functions for writing cfiles
@@ -276,13 +296,19 @@ int cfwrite_angles(angles *ang, CFILE *file);
// writes variable length, null-termined string.
int cfwrite_string(char *buf, CFILE *file);
// write a fixed length that is null-terminatedm, and has the length
// stored in file
int cfwrite_string_len(char *buf, CFILE *file);
/**
* @brief Write a fixed length string (not including its null terminator), with the length stored in file
*
* @param buf String to write to file
* @param file File to write to
*/
int cfwrite_string_len(const char *buf, CFILE *file);
int cf_get_file_list( SCP_vector<SCP_string> &list, int pathtype, char *filter, int sort = CF_SORT_NONE, SCP_vector<file_list_info> *info = NULL );
int cf_get_file_list( int max, char **list, int type, char *filter, int sort = CF_SORT_NONE, file_list_info *info = NULL );
int cf_get_file_list_preallocated( int max, char arr[][MAX_FILENAME_LEN], char **list, int type, char *filter, int sort = CF_SORT_NONE, file_list_info *info = NULL );
void cf_sort_filenames( int n, char **list, int sort, file_list_info *info = NULL );
void cf_sort_filenames( SCP_vector<SCP_string> &list, int sort, SCP_vector<file_list_info> *info = NULL );
// Searches for a file. Follows all rules and precedence and searches
// CD's and pack files.
@@ -322,5 +348,45 @@ int cfile_push_chdir(int type);
// restore directory on top of the stack
int cfile_pop_dir();
namespace cfile
{
// exceptions and other errors
class cfile_error : public std::exception
{
public:
cfile_error() : m_excuse("CFILE Exception")
{
}
cfile_error(const std::string &excuse) : m_excuse(excuse)
{
}
~cfile_error() throw()
{
}
virtual const char *what() const throw()
{
return m_excuse.c_str();
}
private:
std::string m_excuse;
};
class max_read_length : public cfile_error
{
public:
max_read_length(const std::string &excuse) : cfile_error(excuse)
{
}
max_read_length() : cfile_error("Attempted to read beyond length limit")
{
}
};
};
#endif /* __CFILE_H__ */
+11
View File
@@ -26,6 +26,8 @@
#include "cfile/cfilearchive.h"
#include "luaconf.h"
#include <sstream>
#define CHECK_POSITION
@@ -205,6 +207,15 @@ int cfread(void *buf, int elsize, int nelem, CFILE *cfile)
//mprintf(( "CFILE: EOF encountered in file\n" ));
}
if (cb->max_read_len) {
if ( (size_t)(cb->raw_position+size) > cb->max_read_len ) {
std::ostringstream s_buf;
s_buf << "Attempted to read " << size << "-byte(s) beyond length limit";
throw cfile::max_read_length(s_buf.str());
}
}
int bytes_read = fread( buf, 1, size, cb->fp );
if ( bytes_read > 0 ) {
cb->raw_position += bytes_read;
+2 -1
View File
@@ -37,7 +37,8 @@ typedef struct Cfile_block {
int lib_offset;
int raw_position;
int size; // for packed files
size_t max_read_len; // max read offset, for special error handling
} Cfile_block;
#define MAX_CFILE_BLOCKS 64
+79
View File
@@ -12,6 +12,8 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <string>
#include <algorithm>
#ifdef _WIN32
#include <io.h>
@@ -24,7 +26,84 @@
#include "cfile/cfile.h"
void cf_sort_filenames( SCP_vector<SCP_string> &list, int sort, SCP_vector<file_list_info> *info )
{
// NOTE: This really needs to be updated to C++ style sorting at some point
int i, j, incr;
SCP_string t;
file_list_info tt;
int n = (int)list.size();
if (sort == CF_SORT_NAME) {
incr = n / 2;
while (incr > 0) {
for (i=incr; i<n; i++) {
j = i - incr;
while (j >= 0) {
if (stricmp(list[j].c_str(), list[j + incr].c_str()) > 0) {
t = list[j];
list[j] = list[j + incr];
list[j + incr] = t;
if (info) {
tt = (*info)[j];
(*info)[j] = (*info)[j + incr];
(*info)[j + incr] = tt;
}
j -= incr;
} else
break;
}
}
incr /= 2;
}
return;
} else if (sort == CF_SORT_TIME) {
Assert(info);
incr = n / 2;
while (incr > 0) {
for (i=incr; i<n; i++) {
j = i - incr;
while (j >= 0) {
if ( (*info)[j].write_time < (*info)[j + incr].write_time ) {
t = list[j];
list[j] = list[j + incr];
list[j + incr] = t;
tt = (*info)[j];
(*info)[j] = (*info)[j + incr];
(*info)[j + incr] = tt;
j -= incr;
} else
break;
}
}
incr /= 2;
}
return;
} else if (sort == CF_SORT_REVERSE) {
std::reverse( list.begin(), list.end() );
if (info) {
std::reverse( info->begin(), info->end() );
}
return;
}
nprintf(("Error", "Unknown sorting method %d passed to cf_sort_filenames()\n", sort));
}
// Sorts a list of filenames using the specified sorting method (CF_SORT_*).
// n = number of filenames in list to sort
+364 -71
View File
@@ -15,6 +15,7 @@
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <sstream>
#ifdef _WIN32
#include <io.h>
@@ -85,14 +86,14 @@ typedef struct cf_file {
int pack_offset; // For pack files, where it is at. 0 if not in a pack file. This can be used to tell if in a pack file.
} cf_file;
#define CF_NUM_FILES_PER_BLOCK 256
#define CF_MAX_FILE_BLOCKS 128 // Can store 256*128 = 32768 files
#define CF_NUM_FILES_PER_BLOCK 512
#define CF_MAX_FILE_BLOCKS 128 // Can store 512*128 = 65536 files
typedef struct cf_file_block {
cf_file files[CF_NUM_FILES_PER_BLOCK];
} cf_file_block;
static int Num_files = 0;
static uint Num_files = 0;
static cf_file_block *File_blocks[CF_MAX_FILE_BLOCKS];
@@ -108,8 +109,10 @@ cf_file *cf_get_file(int index)
// Create a new file and return a pointer to it.
cf_file *cf_create_file()
{
int block = Num_files / CF_NUM_FILES_PER_BLOCK;
int offset = Num_files % CF_NUM_FILES_PER_BLOCK;
Assertion(Num_files < CF_NUM_FILES_PER_BLOCK * CF_MAX_FILE_BLOCKS, "Too many files found. CFile cannot handle more than %d files.\n", CF_NUM_FILES_PER_BLOCK * CF_MAX_FILE_BLOCKS);
uint block = Num_files / CF_NUM_FILES_PER_BLOCK;
uint offset = Num_files % CF_NUM_FILES_PER_BLOCK;
if ( File_blocks[block] == NULL ) {
File_blocks[block] = (cf_file_block *)vm_malloc( sizeof(cf_file_block) );
@@ -370,6 +373,7 @@ void cf_build_root_list(char *cdrom_dir)
cf_root *root;
char str_temp[CF_MAX_PATHNAME_LENGTH], *cur_pos;
int path_len;
#ifdef SCP_UNIX
// =========================================================================
@@ -426,8 +430,7 @@ void cf_build_root_list(char *cdrom_dir)
if(Cmdline_mod) {
// stackable Mod support -- Kazan
//This for statement is a work of art :D
for (cur_pos=Cmdline_mod; strlen(cur_pos) != 0; cur_pos+= (strlen(cur_pos)+1))
for (cur_pos=Cmdline_mod; *cur_pos != '\0'; cur_pos+= (strlen(cur_pos)+1))
{
memset(str_temp, 0, CF_MAX_PATHNAME_LENGTH);
strncpy(str_temp, cur_pos, CF_MAX_PATHNAME_LENGTH-1);
@@ -444,12 +447,15 @@ void cf_build_root_list(char *cdrom_dir)
Int3();
}
path_len = strlen(root->path);
// do we already have a slash? as in the case of a root directory install
if ( (strlen(root->path) < (CF_MAX_PATHNAME_LENGTH-1)) && (root->path[strlen(root->path)-1] != DIR_SEPARATOR_CHAR) ) {
if ( (path_len < (CF_MAX_PATHNAME_LENGTH-1)) && (root->path[path_len-1] != DIR_SEPARATOR_CHAR) ) {
strcat_s(root->path, DIR_SEPARATOR_STR); // put trailing backslash on for easier path construction
path_len++;
}
strncat(root->path, str_temp, (CF_MAX_PATHNAME_LENGTH - strlen(root->path) - 1));
strncat(root->path, str_temp, (CF_MAX_PATHNAME_LENGTH - path_len - 1));
root->roottype = CF_ROOTTYPE_PATH;
cf_build_pack_list(root);
}
@@ -461,8 +467,10 @@ void cf_build_root_list(char *cdrom_dir)
Error(LOCATION, "Can't get current working directory -- %d", errno );
}
path_len = strlen(root->path);
// do we already have a slash? as in the case of a root directory install
if ( (strlen(root->path) < (CF_MAX_PATHNAME_LENGTH-1)) && (root->path[strlen(root->path)-1] != DIR_SEPARATOR_CHAR) ) {
if ( (path_len < (CF_MAX_PATHNAME_LENGTH-1)) && (root->path[path_len-1] != DIR_SEPARATOR_CHAR) ) {
strcat_s(root->path, DIR_SEPARATOR_STR); // put trailing backslash on for easier path construction
}
@@ -664,9 +672,9 @@ void cf_search_root_pack(int root_index)
Assert( sizeof(VP_header) == 16 );
fread(&VP_header, 1, sizeof(VP_header), fp);
VP_header.version = INTEL_INT( VP_header.version );
VP_header.index_offset = INTEL_INT( VP_header.index_offset );
VP_header.num_files = INTEL_INT( VP_header.num_files );
VP_header.version = INTEL_INT( VP_header.version ); //-V570
VP_header.index_offset = INTEL_INT( VP_header.index_offset ); //-V570
VP_header.num_files = INTEL_INT( VP_header.num_files ); //-V570
mprintf(( "Searching root pack '%s' ... ", root->path ));
@@ -684,21 +692,21 @@ void cf_search_root_pack(int root_index)
fread( &find, sizeof(VP_FILE), 1, fp );
find.offset = INTEL_INT( find.offset );
find.size = INTEL_INT( find.size );
find.write_time = INTEL_INT( find.write_time );
find.offset = INTEL_INT( find.offset ); //-V570
find.size = INTEL_INT( find.size ); //-V570
find.write_time = INTEL_INT( find.write_time ); //-V570
if ( find.size == 0 ) {
int search_path_len = strlen(search_path);
if ( !stricmp( find.filename, ".." )) {
int l = strlen(search_path);
char *p = &search_path[l-1];
char *p = &search_path[search_path_len-1];
while( (p > search_path) && (*p != DIR_SEPARATOR_CHAR) ) {
p--;
}
*p = 0;
} else {
if ( strlen(search_path) && (search_path[strlen(search_path)-1] != DIR_SEPARATOR_CHAR) ) {
strcat_s( search_path, DIR_SEPARATOR_STR );
if ( search_path_len && (search_path[search_path_len-1] != DIR_SEPARATOR_CHAR) ) {
strcat_s( search_path, DIR_SEPARATOR_STR );
}
strcat_s( search_path, find.filename );
}
@@ -821,7 +829,7 @@ void cf_free_secondary_filelist()
// Returns: If not found returns 0.
int cf_find_file_location( char *filespec, int pathtype, int max_out, char *pack_filename, int *size, int *offset, bool localize )
{
int i;
uint i;
int cfs_slow_search = 0;
char longname[MAX_PATH_LEN];
@@ -830,7 +838,7 @@ int cf_find_file_location( char *filespec, int pathtype, int max_out, char *pack
_finddata_t findstruct;
#endif
Assert( (filespec != NULL) && (strlen(filespec) > 0) );
Assert( (filespec != NULL) && (strlen(filespec) > 0) ); //-V805
Assert( (pack_filename == NULL) || (max_out > 1) );
// see if we have something other than just a filename
@@ -860,13 +868,13 @@ int cf_find_file_location( char *filespec, int pathtype, int max_out, char *pack
}
// Search the hard drive for files first.
int num_search_dirs = 0;
uint num_search_dirs = 0;
int search_order[CF_MAX_PATH_TYPES];
if ( CF_TYPE_SPECIFIED(pathtype) ) {
search_order[num_search_dirs++] = pathtype;
} else {
for (i = CF_TYPE_ROOT; i < CF_MAX_PATH_TYPES; i++) {
for (int i = CF_TYPE_ROOT; i < CF_MAX_PATH_TYPES; i++) {
if (i != pathtype)
search_order[num_search_dirs++] = i;
}
@@ -898,23 +906,21 @@ int cf_find_file_location( char *filespec, int pathtype, int max_out, char *pack
cf_create_default_path_string( longname, sizeof(longname)-1, search_order[i], filespec, localize );
#if defined _WIN32
if (!Cmdline_safeloading) {
findhandle = _findfirst(longname, &findstruct);
if (findhandle != -1) {
if (size)
*size = findstruct.size;
findhandle = _findfirst(longname, &findstruct);
if (findhandle != -1) {
if (size)
*size = findstruct.size;
_findclose(findhandle);
_findclose(findhandle);
if (offset)
*offset = 0;
if (offset)
*offset = 0;
if (pack_filename)
strncpy( pack_filename, longname, max_out );
if (pack_filename)
strncpy( pack_filename, longname, max_out );
return 1;
}
} else
return 1;
}
#endif
{
FILE *fp = fopen(longname, "rb" );
@@ -1028,7 +1034,8 @@ extern char *stristr(const char *str, const char *substr);
// (NOTE: This function is exponentially slow, so don't use it unless truely needed!!)
int cf_find_file_location_ext( char *filename, const int ext_num, const char **ext_list, int pathtype, int max_out, char *pack_filename, int *size, int *offset, bool localize )
{
int i, cur_ext;
uint i;
int cur_ext;
int cfs_slow_search = 0;
char longname[MAX_PATH_LEN];
char filespec[MAX_FILENAME_LEN];
@@ -1056,13 +1063,13 @@ int cf_find_file_location_ext( char *filename, const int ext_num, const char **e
}
// Search the hard drive for files first.
int num_search_dirs = 0;
uint num_search_dirs = 0;
int search_order[CF_MAX_PATH_TYPES];
if ( CF_TYPE_SPECIFIED(pathtype) ) {
search_order[num_search_dirs++] = pathtype;
} else {
for (i = CF_TYPE_ROOT; i < CF_MAX_PATH_TYPES; i++)
for (int i = CF_TYPE_ROOT; i < CF_MAX_PATH_TYPES; i++)
search_order[num_search_dirs++] = i;
}
@@ -1109,23 +1116,21 @@ int cf_find_file_location_ext( char *filename, const int ext_num, const char **e
cf_create_default_path_string( longname, sizeof(longname)-1, search_order[i], filespec, localize );
#if defined _WIN32
if (!Cmdline_safeloading) {
findhandle = _findfirst(longname, &findstruct);
if (findhandle != -1) {
if (size)
*size = findstruct.size;
findhandle = _findfirst(longname, &findstruct);
if (findhandle != -1) {
if (size)
*size = findstruct.size;
_findclose(findhandle);
_findclose(findhandle);
if (offset)
*offset = 0;
if (offset)
*offset = 0;
if (pack_filename)
strncpy( pack_filename, longname, max_out );
if (pack_filename)
strncpy( pack_filename, longname, max_out );
return cur_ext;
}
} else
return cur_ext;
}
#endif
{
FILE *fp = fopen(longname, "rb" );
@@ -1168,7 +1173,7 @@ int cf_find_file_location_ext( char *filename, const int ext_num, const char **e
int last_root_index = -1;
int last_path_index = -1;
file_list_index.reserve(Num_files);
file_list_index.reserve( MIN(ext_num * 4, (int)Num_files) );
// next, run though and pick out base matches
for (i = 0; i < Num_files; i++) {
@@ -1214,17 +1219,10 @@ int cf_find_file_location_ext( char *filename, const int ext_num, const char **e
file_list_index.push_back( f );
}
int file_list_size = (int)file_list_index.size();
// quick exit test
if (file_list_size < 1)
goto Bail;
// now try and find our preferred match
for (cur_ext = 0; cur_ext < ext_num; cur_ext++) {
for (i = 0; i < file_list_size; i++) {
cf_file *f = file_list_index[i];
for (SCP_vector<cf_file*>::iterator fli = file_list_index.begin(); fli != file_list_index.end(); ++fli) {
cf_file *f = *fli;
strcat_s( filespec, ext_list[cur_ext] );
@@ -1303,10 +1301,6 @@ int cf_find_file_location_ext( char *filename, const int ext_num, const char **e
}
}
Bail:
// didn't find anything, bail...
file_list_index.clear();
return -1;
}
@@ -1348,8 +1342,245 @@ int cf_matches_spec(char *filespec, char *filename)
}
int (*Get_file_list_filter)(char *filename) = NULL;
const char *Get_file_list_child = NULL;
int Skip_packfile_search = 0;
static bool verify_file_list_child()
{
if (Get_file_list_child == NULL) {
return false;
}
// empty or too long
size_t len = strlen(Get_file_list_child);
if ( !len || (len > MAX_FILENAME_LEN) ) {
return false;
}
// can not being with directory separator
if (Get_file_list_child[0] == DIR_SEPARATOR_CHAR) {
return false;
}
// no ':' or spaces
if ( strchr(Get_file_list_child, ':') || strchr(Get_file_list_child, ' ') ) {
return false;
}
return true;
}
static int cf_file_already_in_list( SCP_vector<SCP_string> &list, char *filename )
{
char name_no_extension[MAX_PATH_LEN];
size_t i, size = list.size();
if (size == 0) {
return 0;
}
strcpy_s(name_no_extension, filename );
char *p = strrchr( name_no_extension, '.' );
if ( p ) *p = 0;
for (i = 0; i < size; i++) {
if ( !stricmp(list[i].c_str(), name_no_extension ) ) {
// Match found!
return 1;
}
}
// Not found
return 0;
}
// An alternative cf_get_file_list*(), true dynamic list version.
// This one has a 'type', which is a CF_TYPE_* value. Because this specifies the directory
// location, 'filter' only needs to be the filter itself, with no path information.
// See above descriptions of cf_get_file_list() for more information about how it all works.
int cf_get_file_list( SCP_vector<SCP_string> &list, int pathtype, char *filter, int sort, SCP_vector<file_list_info> *info )
{
char *ptr;
uint i;
int l, own_flag = 0;
SCP_vector<file_list_info> my_info;
file_list_info tinfo;
if ( !info && (sort == CF_SORT_TIME) ) {
info = &my_info;
own_flag = 1;
}
char filespec[MAX_PATH_LEN];
bool check_duplicates = !list.empty();
if ( check_duplicates && (sort != CF_SORT_NONE) ) {
Int3();
sort = CF_SORT_NONE;
}
if (Get_file_list_child && !verify_file_list_child() ) {
Get_file_list_child = NULL;
}
#if defined _WIN32
cf_create_default_path_string( filespec, sizeof(filespec)-1, pathtype, (char*)Get_file_list_child );
strcat_s(filespec, DIR_SEPARATOR_STR);
strcat_s(filespec, filter);
_finddata_t find;
int find_handle;
find_handle = _findfirst( filespec, &find );
if (find_handle != -1) {
do {
if (strcmp(strstr(filter, "."), strstr(find.name,".")) != 0)
continue;
if ( strlen(find.name) >= MAX_FILENAME_LEN )
continue;
if (!(find.attrib & _A_SUBDIR)) {
if ( !Get_file_list_filter || (*Get_file_list_filter)(find.name) ) {
if ( check_duplicates && cf_file_already_in_list(list, find.name) ) {
continue;
}
ptr = strrchr(find.name, '.');
if (ptr)
l = ptr - find.name;
else
l = strlen(find.name);
list.push_back( SCP_string(find.name, l) );
if (info) {
tinfo.write_time = find.time_write;
info->push_back( tinfo );
}
}
}
} while (!_findnext(find_handle, &find));
_findclose( find_handle );
}
#elif defined SCP_UNIX
cf_create_default_path_string( filespec, sizeof(filespec)-1, pathtype, (char*)Get_file_list_child );
DIR *dirp;
struct dirent *dir;
dirp = opendir (filespec);
if ( dirp ) {
while ((dir = readdir (dirp)) != NULL) {
if ( strlen(dir->d_name) >= MAX_FILENAME_LEN ) {
continue;
}
if (fnmatch(filter, dir->d_name, 0) != 0)
continue;
char fn[MAX_PATH];
snprintf(fn, MAX_PATH-1, "%s/%s", filespec, dir->d_name);
fn[MAX_PATH-1] = 0;
struct stat buf;
if (stat(fn, &buf) == -1) {
continue;
}
if (!S_ISREG(buf.st_mode)) {
continue;
}
if ( !Get_file_list_filter || (*Get_file_list_filter)(dir->d_name) ) {
if ( check_duplicates && cf_file_already_in_list(list, dir->d_name) ) {
continue;
}
ptr = strrchr(dir->d_name, '.');
if (ptr)
l = ptr - dir->d_name;
else
l = strlen(dir->d_name);
list.push_back( SCP_string(dir->d_name, l) );
if (info) {
tinfo.write_time = buf.st_mtime;
info->push_back( tinfo );
}
}
}
closedir(dirp);
}
#endif
bool skip_packfiles = (Skip_packfile_search != 0);
if ( (pathtype == CF_TYPE_PLAYERS) || (pathtype == CF_TYPE_SINGLE_PLAYERS) || (pathtype == CF_TYPE_MULTI_PLAYERS) ) {
skip_packfiles = true;
} else if (Get_file_list_child != NULL) {
skip_packfiles = true;
}
// Search all the packfiles and CD.
if ( !skip_packfiles ) {
for (i=0; i<Num_files; i++ ) {
cf_file * f = cf_get_file(i);
// only search paths we're supposed to...
if ( (pathtype != CF_TYPE_ANY) && (pathtype != f->pathtype_index) ) {
continue;
}
if ( !cf_matches_spec( filter,f->name_ext)) {
continue;
}
if ( cf_file_already_in_list(list, f->name_ext)) {
continue;
}
if ( !Get_file_list_filter || (*Get_file_list_filter)(f->name_ext) ) {
//mprintf(( "Found '%s' in root %d path %d\n", f->name_ext, f->root_index, f->pathtype_index ));
ptr = strrchr(f->name_ext, '.');
if (ptr)
l = ptr - f->name_ext;
else
l = strlen(f->name_ext);
list.push_back( SCP_string(f->name_ext, l) );
if (info) {
tinfo.write_time = f->write_time;
info->push_back( tinfo );
}
}
}
}
if (sort != CF_SORT_NONE) {
cf_sort_filenames( list, sort, info );
}
if (own_flag) {
my_info.clear();
}
Get_file_list_filter = NULL;
Get_file_list_child = NULL;
return (int)list.size();
}
int cf_file_already_in_list( int num_files, char **list, char *filename )
{
int i;
@@ -1377,7 +1608,8 @@ int cf_file_already_in_list( int num_files, char **list, char *filename )
int cf_get_file_list( int max, char **list, int pathtype, char *filter, int sort, file_list_info *info )
{
char *ptr;
int i, l, num_files = 0, own_flag = 0;
uint i;
int l, num_files = 0, own_flag = 0;
if (max < 1) {
Get_file_list_filter = NULL;
@@ -1574,7 +1806,7 @@ int cf_file_already_in_list_preallocated( int num_files, char arr[][MAX_FILENAME
// See above descriptions of cf_get_file_list() for more information about how it all works.
int cf_get_file_list_preallocated( int max, char arr[][MAX_FILENAME_LEN], char **list, int pathtype, char *filter, int sort, file_list_info *info )
{
int i, num_files = 0, own_flag = 0;
int num_files = 0, own_flag = 0;
if (max < 1) {
Get_file_list_filter = NULL;
@@ -1583,7 +1815,7 @@ int cf_get_file_list_preallocated( int max, char arr[][MAX_FILENAME_LEN], char *
}
if (list) {
for (i=0; i<max; i++) {
for (int i=0; i<max; i++) {
list[i] = arr[i];
}
} else {
@@ -1695,7 +1927,7 @@ int cf_get_file_list_preallocated( int max, char arr[][MAX_FILENAME_LEN], char *
// Search all the packfiles and CD.
if ( !Skip_packfile_search ) {
for (i=0; i<Num_files; i++ ) {
for (uint i=0; i<Num_files; i++ ) {
cf_file * f = cf_get_file(i);
// only search paths we're supposed to...
@@ -1830,6 +2062,67 @@ int cf_create_default_path_string( char *path, uint path_max, int pathtype, char
return 1;
}
// Returns the default storage path for files given a
// particular pathtype. In other words, the path to
// the unpacked, non-cd'd, stored on hard drive path.
// If filename isn't null it will also tack the filename
// on the end, creating a completely valid filename.
// Input: pathtype - CF_TYPE_??
// filename - optional, if set, tacks the filename onto end of path.
// Output: path - Fully qualified pathname.
//Returns 0 if the result would be too long (invalid result)
int cf_create_default_path_string( SCP_string &path, int pathtype, char *filename, bool localize )
{
#ifdef SCP_UNIX
if ( filename && strpbrk(filename,"/") ) {
#else
if ( filename && strpbrk(filename,"/\\:") ) {
#endif
// Already has full path
path.assign(filename);
} else {
cf_root *root = cf_get_root(0);
if (!root) {
Assert( filename != NULL );
path.assign(filename);
return 1;
}
Assert(CF_TYPE_SPECIFIED(pathtype));
std::ostringstream s_path;
// force a specific directory to search for player files
if ( (pathtype == CF_TYPE_PLAYERS) || (pathtype == CF_TYPE_SINGLE_PLAYERS) || (pathtype == CF_TYPE_MULTI_PLAYERS) ) {
s_path << Pilot_file_path;
} else {
s_path << root->path;
}
s_path << Pathtypes[pathtype].path;
// Don't add slash for root directory
if (Pathtypes[pathtype].path[0] != '\0') {
if ( *(s_path.str().rbegin()) != DIR_SEPARATOR_CHAR ) {
s_path << DIR_SEPARATOR_STR;
}
// if ( path[strlen(path)-1] != DIR_SEPARATOR_CHAR ) {
// strcat_s(path, path_max, DIR_SEPARATOR_STR);
// }
}
// add filename
if (filename) {
s_path << filename;
}
path = s_path.str().c_str();
}
return 1;
}
void cfile_spew_pack_file_crcs()
{
int i;
+1 -1
View File
@@ -40,6 +40,6 @@ extern cf_pathtype Pathtypes[CF_MAX_PATH_TYPES];
// 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, char *filename=NULL, bool localize = false);
int cf_create_default_path_string( SCP_string &path, int pathtype, char *filename=NULL, bool localize = false );
#endif //_CFILESYSTEM_H
+10 -10
View File
@@ -140,7 +140,7 @@ void pack_file( char *filespec, char *filename, int filesize, _fs_time_t time_wr
}
memset( path, 0, sizeof(path) );
strcpy( path, filename );
strcpy_s( path, filename );
fswrite_int( (int*)&Total_size, fp_out_hdr );
fswrite_int( &filesize, fp_out_hdr );
@@ -186,7 +186,7 @@ void add_directory( char * dirname)
char *tmpptr;
int i = 0;
strcpy(path, dirname);
strcpy_s(path, dirname);
fswrite_int( (int*)&Total_size, fp_out_hdr);
fswrite_int( &i, fp_out_hdr);
@@ -217,7 +217,7 @@ void pack_directory( char * filespec)
while ( (*ts == DIR_SEPARATOR_CHAR) && (ts > filespec) )
*ts = '\0';
strcpy( tmp1, filespec );
strcpy_s( tmp1, filespec );
add_directory(filespec);
strcat( tmp1, DIR_SEPARATOR_STR"*.*" );
@@ -229,7 +229,7 @@ void pack_directory( char * filespec)
if( find_handle != -1 ) {
if ( find.attrib & _A_SUBDIR ) {
if (strcmp( "..", find.name) && strcmp( ".", find.name) && strcmp( ".svn", find.name)) {
strcpy( tmp, filespec );
strcpy_s( tmp, filespec );
strcat( tmp, "\\" );
strcat( tmp, find.name );
pack_directory(tmp);
@@ -241,7 +241,7 @@ void pack_directory( char * filespec)
while( !_findnext( find_handle, &find ) ) {
if ( find.attrib & _A_SUBDIR ) {
if (strcmp( "..", find.name) && strcmp( ".", find.name) && strcmp( ".svn", find.name)) {
strcpy( tmp, filespec );
strcpy_s( tmp, filespec );
strcat( tmp, "\\" );
strcat( tmp, find.name );
pack_directory(tmp);
@@ -278,7 +278,7 @@ void pack_directory( char * filespec)
}
if (S_ISDIR(buf.st_mode)) {
strcpy( tmp, filespec );
strcpy_s( tmp, filespec );
strcat( tmp, "/" );
strcat( tmp, dir->d_name );
pack_directory(tmp);
@@ -340,7 +340,7 @@ void print_instructions()
exit(0);
}
// we end up #include'ing SDL.h which on Windows and Mac will redfine main() which is something
// we end up #include'ing SDL.h which on Windows and Mac will redefine main() which is something
// that we don't want since we don't actually link against SDL, this solves the problem...
#ifdef main
#undef main
@@ -364,14 +364,14 @@ int main(int argc, char *argv[] )
#endif
}
strcpy( archive, argv[1] );
strcpy_s( archive, argv[1] );
p = strchr( archive, '.' );
if (p) *p = 0; // remove extension
strcpy( archive_dat, archive );
strcpy_s( archive_dat, archive );
strcat( archive_dat, ".vp" );
strcpy( archive_hdr, archive );
strcpy_s( archive_hdr, archive );
strcat( archive_hdr, ".hdr" );
fp_out = fopen( archive_dat, "wb" );
+5 -5
View File
@@ -224,7 +224,7 @@ void read_index(int lc = 0)
if (lc == 1)
lowercase( vpinfo.file_name );
strcpy( vpinfo.file_path, path );
strcpy_s( vpinfo.file_path, path );
VP_FileInfo.push_back(vpinfo);
}
}
@@ -261,7 +261,7 @@ void extract_all_files(char *file)
printf("Extracting: %s...\n", file);
for (uint i = 0; i < VP_FileInfo.size(); i++) {
for (size_t i = 0; i < VP_FileInfo.size(); i++) {
// save the file path to a temp location and recursively make the needed directories
if (have_outdir) {
if ( (out_len + 1 + strlen(path)) > MAX_PATH-1 )
@@ -311,7 +311,7 @@ void extract_all_files(char *file)
sprintf(path2, "%s%s%s", out_dir, DIR_SEPARATOR_STR, path);
} else {
strcpy(path2, path);
strcpy_s(path2, path);
}
fp_out = fopen(path2, "wb");
@@ -365,7 +365,7 @@ void list_all_files(char *file)
printf(" Name Size Offset Date/Time Path\n");
printf("-------------------------------------------------------------------------------\n");
for (uint i = 0; i < VP_FileInfo.size(); i++) {
for (size_t i = 0; i < VP_FileInfo.size(); i++) {
plat_time = VP_FileInfo[i].write_time; // gets rid of some platform strangeness this way
strftime(out_time, 32, "%F %H:%M", localtime(&plat_time)); // YYYY-mm-dd HH:mm (ISO 8601 date format, 24-hr time)
@@ -422,7 +422,7 @@ void help()
printf("\n");
}
// we end up #include'ing SDL.h which on Windows and Mac will redfine main() which is something
// we end up #include'ing SDL.h which on Windows and Mac will redefine main() which is something
// that we don't want since we don't actually link against SDL, this solves the problem...
#ifdef main
#undef main
+191 -124
View File
@@ -50,6 +50,7 @@ public:
int get_int();
float get_float();
char *str();
bool check_if_args_is_valid();
};
static cmdline_parm Parm_list(NULL, NULL);
@@ -76,6 +77,9 @@ enum
#define BUILD_CAP_OPENAL (1<<0)
#define BUILD_CAP_NO_D3D (1<<1)
#define BUILD_CAP_NEW_SND (1<<2)
#define PARSE_COMMAND_LINE_STRING "-parse_cmdline_only"
typedef struct
{
@@ -110,85 +114,90 @@ typedef struct
Flag exe_params[] =
{
{ "-spec", "Enable specular", true, EASY_MEM_ALL_ON, EASY_DEFAULT_MEM, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-spec", },
{ "-glow", "Enable glowmaps", true, EASY_MEM_ALL_ON, EASY_DEFAULT_MEM, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-glow", },
{ "-glow", "Enable glow maps", true, EASY_MEM_ALL_ON, EASY_DEFAULT_MEM, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-glow", },
{ "-env", "Enable environment maps", true, EASY_MEM_ALL_ON, EASY_DEFAULT_MEM, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-env", },
{ "-mipmap", "Enable mipmapping", true, 0, EASY_DEFAULT_MEM, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-mipmap", },
{ "-nomotiondebris", "Disable motion debris", true, EASY_ALL_ON, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-nomotiondebris",},
{ "-noscalevid", "Disable scale-to-window for movies", true, 0, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-noscalevid", },
{ "-missile_lighting", "Apply Lighting to Missiles" , true, EASY_ALL_ON, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-missile_lighting", },
{ "-missile_lighting", "Apply lighting to missiles" , true, EASY_ALL_ON, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-missile_lighting", },
{ "-normal", "Enable normal maps", true, EASY_MEM_ALL_ON, EASY_DEFAULT_MEM, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-normal" },
{ "-3dshockwave", "Enable 3D shockwaves", true, EASY_MEM_ALL_ON, EASY_DEFAULT_MEM, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-3dshockwave" },
{ "-3dshockwave", "Enable 3D shockwaves", true, EASY_MEM_ALL_ON, EASY_DEFAULT_MEM, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-3dshockwave" },
{ "-post_process", "Enable post processing", true, 0, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-post_process" },
{ "-soft_particles", "Enable soft particles", true, 0, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-soft_particles" },
{ "-fxaa", "Enable FXAA anti-aliasing", true, 0, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-fxaa" },
{ "-img2dds", "Compress non-compressed images", true, 0, EASY_DEFAULT, "Game Speed", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-img2dds", },
{ "-no_vsync", "Disable vertical sync", true, 0, EASY_DEFAULT, "Game Speed", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_vsync", },
{ "-cache_bitmaps", "Cache bitmaps between missions", true, 0, EASY_DEFAULT_MEM, "Game Speed", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-cache_bitmaps", },
{ "-dualscanlines", "Another pair of scanning lines", true, 0, EASY_DEFAULT, "HUD", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-dualscanlines", },
{ "-dualscanlines", "Add another pair of scanning lines", true, 0, EASY_DEFAULT, "HUD", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-dualscanlines", },
{ "-targetinfo", "Enable info next to target", true, 0, EASY_DEFAULT, "HUD", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-targetinfo", },
{ "-orbradar", "Enables 3d radar", true, 0, EASY_DEFAULT, "HUD", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-orbradar", },
{ "-rearm_timer", "Enable Rearm/Repair Completion Timer", true, 0, EASY_DEFAULT, "HUD", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-rearm_timer", },
{ "-ballistic_gauge", "Enable the analog ballistic ammo gauge", true, 0, EASY_DEFAULT, "HUD", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-ballistic_gauge", },
{ "-orbradar", "Enable 3D radar", true, 0, EASY_DEFAULT, "HUD", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-orbradar", },
{ "-rearm_timer", "Enable rearm/repair completion timer", true, 0, EASY_DEFAULT, "HUD", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-rearm_timer", },
{ "-ballistic_gauge", "Enable analog ballistic ammo gauge", true, 0, EASY_DEFAULT, "HUD", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-ballistic_gauge", },
{ "-ship_choice_3d", "Use 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 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", },
{ "-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", },
{ "-tbp", "Toggle features for The Babylon Project", true, 0, EASY_DEFAULT, "Gameplay", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-tbp", }, // TBP warp effects -Et1
{ "-wcsaga", "Toggle features for Wing Commander Saga", true, 0, EASY_DEFAULT, "Gameplay", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-wcsaga", },
{ "-snd_preload", "Preload mission game sounds", true, EASY_MEM_ALL_ON, EASY_DEFAULT_MEM, "Audio", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-snd_preload", },
{ "-nosound", "Disable sound and music", false, 0, EASY_DEFAULT, "Audio", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-nosound", },
{ "-snd_preload", "Preload mission game sounds", true, EASY_MEM_ALL_ON, EASY_DEFAULT_MEM, "Audio", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-snd_preload", },
{ "-nosound", "Disable all sound", false, 0, EASY_DEFAULT, "Audio", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-nosound", },
{ "-nomusic", "Disable music", false, 0, EASY_DEFAULT, "Audio", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-nomusic", },
{ "-standalone", "Run as Stand Alone Server", false, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-standalone", },
{ "-standalone", "Run as standalone server", false, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-standalone", },
{ "-startgame", "Skip mainhall and start hosting", false, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-startgame", },
{ "-closed", "Start hosted server as closed", false, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-closed", },
{ "-restricted", "Host confirms join requests", false, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-restricted", },
{ "-multilog", "", false, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-multilog", },
{ "-clientdamage", "", false, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-clientdamage", },
{ "-mpnoreturn", "Disables flight deck option", true, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-mpnoreturn", },
{ "-mpnoreturn", "Disable flight deck option", true, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-mpnoreturn", },
{ "-oldfire", "", false, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-oldfire", },
{ "-nohtl", "Software mode (very slow)", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-nohtl", },
{ "-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", },
{ "-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", },
{ "-noparseerrors", "Disable parsing errors", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-noparseerrors", },
{ "-safeloading", "", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-safeloading", },
{ "-query_speech", "Does this build have speech?", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-query_speech", },
{ "-d3d_bad_tsys", "Enable inefficient textures", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-d3d_bad_tsys", },
{ "-novbo", "Disable OpenGL VBO", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-novbo", },
{ "-noibx", "Don't use cached index buffers (IBX)", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-noibx", },
{ "-loadallweps", "Load all weapons, even those not used", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-loadallweps", },
{ "-disable_fbo", "Disable OpenGL RenderTargets", true, 0, EASY_DEFAULT, "Troubleshoot", "", },
{ "-no_glsl", "Disable GLSL (shader) support", true, 0, EASY_DEFAULT, "Troubleshoot", "", },
{ "-ati_swap", "Fix Color issues on some ATI cards", true, 0, EASY_DEFAULT, "Troubleshoot", "http://scp.indiegames.us/mantis/view.php?id=1669", },
{ "-query_speech", "Check if this build has speech", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-query_speech", },
{ "-novbo", "Disable OpenGL VBO", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-novbo", },
{ "-noibx", "Don't use cached index buffers (IBX)", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-noibx", },
{ "-loadallweps", "Load all weapons, even those not used", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-loadallweps", },
{ "-disable_fbo", "Disable OpenGL RenderTargets", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-disable_fbo", },
{ "-no_glsl", "Disable GLSL (shader) support", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_glsl", },
{ "-ati_swap", "Fix colour issues on some ATI cards", true, 0, EASY_DEFAULT, "Troubleshoot", "http://scp.indiegames.us/mantis/view.php?id=1669", },
{ "-no_3d_sound", "Use only 2D/stereo for sound effects", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_3d_sound", },
{ "-disable_glsl_model","Don't use shaders for model rendering", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-disable_glsl_model", },
#ifndef SCP_UNIX
{ "-disable_di_mouse", "Don't use DirectInput for mouse control", true, 0, EASY_DEFAULT, "Troubleshoot", "", },
#endif
{ "-use_gldrawelements","Don't use glDrawRangeElements", true, 0, EASY_DEFAULT, "Troubleshoot", "", },
{ "-ingame_join", "Allows ingame joining", true, 0, EASY_DEFAULT, "Experimental", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-ingame_join", },
{ "-voicer", "Voice recognition", true, 0, EASY_DEFAULT, "Experimental", "", },
{ "-post_process", "Enable post processing", true, 0, EASY_DEFAULT, "Experimental", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-post_process" },
{ "-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", },
{ "-fb_explosions", "Enable Framebuffer Shockwaves", true, 0, EASY_DEFAULT, "Experimental", "", },
{ "-fps", "Show frames per second on HUD", false, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-fps", },
{ "-pos", "Show position of camera", false, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-pos", },
{ "-window", "Run in window", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-window", },
{ "-fullscreen_window", "Run in fullscreen window", false, 0, EASY_DEFAULT, "Dev Tool", "", },
{ "-timerbar", "", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-timerbar", },
#ifndef SCP_UNIX
{ "-fullscreen_window", "Run in fullscreen window", false, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-fullscreen_window", },
#endif
{ "-stats", "Show statistics", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-stats", },
{ "-coords", "Show coordinates", false, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-coords", },
{ "-coords", "Show coordinates", false, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-coords", },
{ "-show_mem_usage", "Show memory usage", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-show_mem_usage", },
{ "-pofspew", "", false, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-pofspew", },
{ "-tablecrcs", "", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-tablecrcs", },
{ "-missioncrcs", "", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-missioncrcs", },
{ "-dis_collisions", "Disable collisions", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-dis_collisions", },
{ "-dis_weapons", "Disable weapon rendering", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-dis_weapons", },
{ "-output_sexps", "Outputs SEXPs to sexps.html", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-output_sexps", },
{ "-output_scripting", "Outputs scripting to scripting.html", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-output_scripting", },
{ "-save_render_target", "Save render targets to file", true, 0, EASY_DEFAULT, "Dev Tool", "", },
{ "-debug_window", "Display debug window", true, 0, EASY_DEFAULT, "Dev Tool", "", },
{ "-verify_vps", "Spew VP crcs to vp_crcs.txt", true, 0, EASY_DEFAULT, "Dev Tool", "", },
#ifdef SCP_UNIX
{ "-dis_weapons", "Disable weapon rendering", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-dis_weapons", },
{ "-output_sexps", "Output SEXPs to sexps.html", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-output_sexps", },
{ "-output_scripting", "Output scripting to scripting.html", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-output_scripting", },
{ "-save_render_target", "Save render targets to file", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-save_render_target", },
{ "-debug_window", "Display debug window", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-debug_window", },
{ "-verify_vps", "Spew VP CRCs to vp_crcs.txt", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-verify_vps", },
#ifdef SCP_UNIX
{ "-nograb", "Don't grab mouse/keyboard in a window", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-nograb", },
#endif
#endif
};
// here are the command line parameters that we will be using for FreeSpace
@@ -207,7 +216,6 @@ cmdline_parm gameclosed_arg("-closed", NULL); // Cmdline_closed_game
cmdline_parm gamerestricted_arg("-restricted", NULL); // Cmdline_restricted_game
cmdline_parm port_arg("-port", NULL);
cmdline_parm multilog_arg("-multilog", NULL); // Cmdline_multi_log
cmdline_parm server_firing_arg("-oldfire", NULL); // Cmdline_server_firing
cmdline_parm client_dodamage("-clientdamage", NULL); // Cmdline_client_dodamage
cmdline_parm pof_spew("-pofspew", NULL); // Cmdline_spew_pof_info
cmdline_parm mouse_coords("-coords", NULL); // Cmdline_mouse_coords
@@ -230,7 +238,6 @@ int Cmdline_multi_log = 0;
int Cmdline_multi_stream_chat_to_file = 0;
int Cmdline_network_port = -1;
int Cmdline_restricted_game = 0;
int Cmdline_server_firing = 0;
int Cmdline_spew_pof_info = 0;
int Cmdline_start_netgame = 0;
int Cmdline_timeout = -1;
@@ -248,8 +255,6 @@ cmdline_parm spec_static_arg("-spec_static", NULL);
cmdline_parm spec_point_arg("-spec_point", NULL);
cmdline_parm spec_tube_arg("-spec_tube", NULL);
cmdline_parm ambient_factor_arg("-ambient_factor", NULL); // Cmdline_ambient_factor
cmdline_parm cell_arg("-cell", NULL); // Cmdline_cell
cmdline_parm decals("-decals", NULL); // Cmdline_decals
cmdline_parm env("-env", NULL); // Cmdline_env
cmdline_parm mipmap_arg("-mipmap", NULL); // Cmdline_mipmap
cmdline_parm missile_lighting_arg("-missile_lighting", NULL); // Cmdline_missile_lighting
@@ -261,15 +266,17 @@ cmdline_parm noemissive_arg("-no_emissive_light", NULL); // Cmdline_no_emissive
cmdline_parm normal_arg("-normal", NULL); // Cmdline_normal -- enable normal mapping
cmdline_parm height_arg("-height", NULL); // Cmdline_height -- enable support for parallax mapping
cmdline_parm enable_3d_shockwave_arg("-3dshockwave", NULL);
cmdline_parm softparticles_arg("-soft_particles", NULL);
cmdline_parm postprocess_arg("-post_process", NULL);
cmdline_parm bloom_intensity_arg("-bloom_intensity", NULL);
cmdline_parm fxaa_arg("-fxaa", NULL);
cmdline_parm fxaa_preset_arg("-fxaa_preset", NULL);
cmdline_parm fb_explosions_arg("-fb_explosions", NULL);
float Cmdline_clip_dist = Default_min_draw_distance;
float Cmdline_fov = 0.75f;
float Cmdline_ogl_spec = 80.0f;
int Cmdline_ambient_factor = 128;
int Cmdline_cell = 0;
int Cmdline_decals = 0;
int Cmdline_env = 0;
int Cmdline_mipmap = 0;
int Cmdline_missile_lighting = 0;
@@ -281,8 +288,13 @@ int Cmdline_no_emissive = 0;
int Cmdline_normal = 0;
int Cmdline_height = 0;
int Cmdline_enable_3d_shockwave = 0;
int Cmdline_softparticles = 0;
int Cmdline_postprocess = 0;
int Cmdline_bloom_intensity = 75;
bool Cmdline_fxaa = false;
int Cmdline_fxaa_preset = 6;
extern int Fxaa_preset_last_frame;
bool Cmdline_fb_explosions = 0;
// Game Speed related
cmdline_parm cache_bitmaps_arg("-cache_bitmaps", NULL); // Cmdline_cache_bitmaps
@@ -332,12 +344,8 @@ int Cmdline_voice_recognition = 0;
// MOD related
cmdline_parm mod_arg("-mod", NULL, true); // Cmdline_mod -- DTP modsupport
cmdline_parm tbp("-tbp", NULL); // Cmdline_tbp -- TBP warp effects -Et1
cmdline_parm wcsaga("-wcsaga", NULL); // Cmdline_wcsaga
char *Cmdline_mod = NULL; //DTP for mod arguement
int Cmdline_tbp = 0;
int Cmdline_wcsaga = 0;
// Multiplayer/Network related
cmdline_parm almission_arg("-almission", NULL); // Cmdline_almission -- DTP for autoload Multi mission
@@ -355,29 +363,35 @@ char *Cmdline_spew_table_crcs = NULL;
int Cmdline_objupd = 3; // client object updates on LAN by default
// Troubleshooting
cmdline_parm d3d_lesstmem_arg("-d3d_bad_tsys", NULL); // Cmdline_d3d_lesstmem
cmdline_parm loadallweapons_arg("-loadallweps", NULL); // Cmdline_load_all_weapons
cmdline_parm htl_arg("-nohtl", NULL); // Cmdline_nohtl -- don't use HT&L
cmdline_parm noibx_arg("-noibx", NULL); // Cmdline_noibx
cmdline_parm nomovies_arg("-nomovies", NULL); // Cmdline_nomovies -- Allows video streaming
cmdline_parm no_set_gamma_arg("-no_set_gamma", NULL); // Cmdline_no_set_gamma
cmdline_parm no_vbo_arg("-novbo", NULL); // Cmdline_novbo
cmdline_parm safeloading_arg("-safeloading", NULL); // Cmdline_safeloading -- Uses old loading method -C
cmdline_parm no_fbo_arg("-disable_fbo", NULL); // Cmdline_no_fbo
cmdline_parm noglsl_arg("-no_glsl", NULL); // Cmdline_noglsl -- disable GLSL support in OpenGL
cmdline_parm atiswap_arg("-ati_swap", NULL); // Cmdline_atiswap - Fix ATI color swap issue for screenshots.
cmdline_parm no3dsound_arg("-no_3d_sound", NULL); // Cmdline_no_3d_sound - Disable use of full 3D sounds
cmdline_parm no_glsl_models_arg("-disable_glsl_model", NULL); // Cmdline_no_glsl_model_rendering -- switches model rendering to fixed pipeline
cmdline_parm no_di_mouse_arg("-disable_di_mouse", NULL); // Cmdline_no_di_mouse -- Disables directinput use for mouse control
cmdline_parm no_drawrangeelements("-use_gldrawelements", NULL); // Cmdline_drawelements -- Uses glDrawElements instead of glDrawRangeElements
cmdline_parm keyboard_layout("-keyboard_layout", NULL);
int Cmdline_d3d_lesstmem = 0;
int Cmdline_load_all_weapons = 0;
int Cmdline_nohtl = 0;
int Cmdline_noibx = 0;
int Cmdline_nomovies = 0;
int Cmdline_no_set_gamma = 0;
int Cmdline_novbo = 0; // turn off OGL VBO support, troubleshooting
int Cmdline_safeloading = 0;
int Cmdline_no_fbo = 0;
int Cmdline_noglsl = 0;
int Cmdline_ati_color_swap = 0;
int Cmdline_no_3d_sound = 0;
int Cmdline_no_glsl_model_rendering = 0;
int Cmdline_no_di_mouse = 0;
int Cmdline_drawelements = 0;
char* Cmdline_keyboard_layout = NULL;
// Developer/Testing related
cmdline_parm start_mission_arg("-start_mission", NULL); // Cmdline_start_mission
@@ -385,17 +399,18 @@ cmdline_parm dis_collisions("-dis_collisions", NULL); // Cmdline_dis_collisions
cmdline_parm dis_weapons("-dis_weapons", NULL); // Cmdline_dis_weapons
cmdline_parm noparseerrors_arg("-noparseerrors", NULL); // Cmdline_noparseerrors -- turns off parsing errors -C
cmdline_parm nowarn_arg("-no_warn", NULL); // Cmdline_nowarn
cmdline_parm extra_warn_arg("-extra_warn", NULL); // Cmdline_extra_warn
cmdline_parm fps_arg("-fps", NULL); // Cmdline_show_fps
cmdline_parm show_mem_usage_arg("-show_mem_usage", NULL); // Cmdline_show_mem_usage
cmdline_parm pos_arg("-pos", NULL); // Cmdline_show_pos
cmdline_parm stats_arg("-stats", NULL); // Cmdline_show_stats
cmdline_parm timerbar_arg("-timerbar", NULL); // Cmdline_timerbar
cmdline_parm save_render_targets_arg("-save_render_target", NULL); // Cmdline_save_render_targets
cmdline_parm debug_window_arg("-debug_window", NULL); // Cmdline_debug_window
cmdline_parm window_arg("-window", NULL); // Cmdline_window
cmdline_parm fullscreen_window_arg("-fullscreen_window",NULL);
cmdline_parm res_arg("-res", NULL); // Cmdline_lores
cmdline_parm verify_vps_arg("-verify_vps", NULL); // Cmdline_verify_vps -- spew VP crcs to vp_crcs.txt
cmdline_parm parse_cmdline_only(PARSE_COMMAND_LINE_STRING, NULL);
#ifdef SCP_UNIX
cmdline_parm no_grab("-nograb", NULL); // Cmdline_no_grab
#endif
@@ -405,10 +420,10 @@ int Cmdline_dis_collisions = 0;
int Cmdline_dis_weapons = 0;
int Cmdline_noparseerrors = 0;
int Cmdline_nowarn = 0; // turn warnings off in FRED
int Cmdline_extra_warn = 0;
int Cmdline_show_mem_usage = 0;
int Cmdline_show_pos = 0;
int Cmdline_show_stats = 0;
int Cmdline_timerbar = 0;
int Cmdline_save_render_targets = 0;
int Cmdline_debug_window = 0;
int Cmdline_window = 0;
@@ -424,6 +439,12 @@ cmdline_parm get_flags_arg("-get_flags", NULL);
cmdline_parm output_sexp_arg("-output_sexps", NULL); //WMC - outputs all SEXPs to sexps.html
cmdline_parm output_scripting_arg("-output_scripting", NULL); //WMC
float Cmdline_percentflashtobang = -1.0;
int Cmdline_enforce_concurrent_sound_count = 1;
cmdline_parm percent_flashtobang_arg("-percent_flashtobang", NULL);
cmdline_parm do_not_enforce_concurrent_sound("-donotenforce", NULL);
#ifndef NDEBUG
@@ -571,10 +592,12 @@ void os_parse_parms(char *cmdline)
if ( !cmdline_offset )
break;
// the new offset should be our currently location + the length of the current option
get_new_offset = (strlen(cmdline) - strlen(cmdline_offset) + strlen(parmp->name));
int parmp_len = strlen(parmp->name);
if ( (*(cmdline_offset + strlen(parmp->name))) && !is_extra_space(*(cmdline_offset + strlen(parmp->name))) ) {
// the new offset should be our currently location + the length of the current option
get_new_offset = (strlen(cmdline) - strlen(cmdline_offset) + parmp_len);
if ( (*(cmdline_offset + parmp_len)) && !is_extra_space(*(cmdline_offset + parmp_len)) ) {
// we found a similar, but not exact, match for this option, continue checking for the correct one
} else {
// we found what we were looking for so break out and process it
@@ -603,8 +626,8 @@ void os_validate_parms(char *cmdline)
char *token;
int parm_found;
token = strtok(cmdline, seps);
while(token != NULL) {
token = strtok(cmdline, seps);
while(token != NULL) {
if (token[0] == '-') {
parm_found = 0;
@@ -630,11 +653,17 @@ void os_validate_parms(char *cmdline)
snprintf(buffer, 128, "Unrecognized command line parameter, \"%s\", continue?", token);
message = CFStringCreateWithCString(NULL, buffer, kCFStringEncodingASCII);
if ( CFUserNotificationDisplayAlert(0, kCFUserNotificationPlainAlertLevel, NULL, NULL, NULL, CFSTR("Unknown Command"), message, NULL, CFSTR("Quit"), NULL, &result) )
if ( CFUserNotificationDisplayAlert(0, kCFUserNotificationPlainAlertLevel, NULL, NULL, NULL, CFSTR("Unknown Command"), message, NULL, CFSTR("Quit"), NULL, &result) ) {
CFRelease(message);
exit(0);
}
if (result != kCFUserNotificationDefaultResponse)
if (result != kCFUserNotificationDefaultResponse) {
CFRelease(message);
exit(0);
}
CFRelease(message);
#else
// if we got a -help, --help, -h, or -? then show the help text, otherwise show unknown option
if ( !stricmp(token, "-help") || !stricmp(token, "--help") || !stricmp(token, "-h") || !stricmp(token, "-?") ) {
@@ -677,6 +706,12 @@ void os_init_cmdline(char *cmdline)
{
FILE *fp;
bool parse_config = true;
if (strstr(cmdline, PARSE_COMMAND_LINE_STRING) != NULL) {
parse_config = false;
}
// read the cmdline.cfg file from the data folder, and pass the command line arguments to
// the the parse_parms and validate_parms line. Read these first so anything actually on
// the command line will take precedence
@@ -701,7 +736,7 @@ void os_init_cmdline(char *cmdline)
#endif
// if the file exists, get a single line, and deal with it
if ( fp ) {
if ( fp && parse_config ) {
char *buf, *p;
size_t len = filelength( fileno(fp) ) + 2;
@@ -800,6 +835,21 @@ cmdline_parm::~cmdline_parm()
#endif
}
// checks if the objects args variable is valid
// returns true if it is, shows an error box and returns false if not valid.
bool cmdline_parm::check_if_args_is_valid() {
if ( args == NULL ) {
Error(__FILE__, __LINE__,
"Command line flag passed that requires an argument, but the argument is missing!\r\n"
"The flag is '%s', make sure that you have an argument that follows it.\r\n"
"You may need to close your launcher and remove the flag manually from %s/data/cmdline_fso.cfg\r\n",
name, "<Freespace directory>");
return false;
} else {
return true;
}
}
// returns - true if the parameter exists on the command line, otherwise false
int cmdline_parm::found()
@@ -810,7 +860,8 @@ int cmdline_parm::found()
// returns - the interger representation for the parameter arguement
int cmdline_parm::get_int()
{
Assert(args);
check_if_args_is_valid();
int offset = 0;
if (stacks) {
@@ -833,7 +884,8 @@ int cmdline_parm::get_int()
// returns - the float representation for the parameter arguement
float cmdline_parm::get_float()
{
Assert(args!=NULL);
check_if_args_is_valid();
int offset = 0;
if (stacks) {
@@ -856,7 +908,8 @@ float cmdline_parm::get_float()
// returns - the string value for the parameter arguement
char *cmdline_parm::str()
{
Assert(args);
check_if_args_is_valid();
return args;
}
@@ -885,14 +938,10 @@ bool SetCmdlineParams()
{
Cmdline_nowarn = 1;
}
/* karajorma - let's just use -nohtl instead
if (fred2_htl_arg.found())
{
Cmdline_FRED2_htl = 1;
}*/
if (timerbar_arg.found()) {
Cmdline_timerbar = 1;
if (extra_warn_arg.found())
{
Cmdline_extra_warn = 1;
}
if ( missioncrcspew_arg.found() ) {
@@ -913,9 +962,11 @@ bool SetCmdlineParams()
}
}
// is this a standalone server??
if (standalone_arg.found()) {
Is_standalone = 1;
if (!Fred_running) { //There is no standalone FRED
// is this a standalone server??
if (standalone_arg.found()) {
Is_standalone = 1;
}
}
// object update control
@@ -1007,10 +1058,6 @@ bool SetCmdlineParams()
Cmdline_multi_log = 1;
}
// maybe use old-school server-side firing
if (server_firing_arg.found() ){
Cmdline_server_firing = 1;
}
// maybe use old-school client damage
if(client_dodamage.found()){
@@ -1120,10 +1167,6 @@ bool SetCmdlineParams()
Cmdline_show_pos = 1;
}
if ( safeloading_arg.found() ) {
Cmdline_safeloading = 1;
}
if ( nomotiondebris_arg.found() ) {
Cmdline_nomotiondebris = 1;
}
@@ -1137,7 +1180,12 @@ bool SetCmdlineParams()
}
if ( fov_arg.found() ) {
VIEWER_ZOOM_DEFAULT = Cmdline_fov = fov_arg.get_float();
Cmdline_fov = fov_arg.get_float();
if (Cmdline_fov > 0.1) {
VIEWER_ZOOM_DEFAULT = Cmdline_fov;
} else {
VIEWER_ZOOM_DEFAULT = Cmdline_fov = 0.75f;
}
}
if( clip_dist_arg.found() ) {
@@ -1149,16 +1197,6 @@ bool SetCmdlineParams()
Cmdline_orb_radar = 1;
}
// TBP warp effects -Et1
// Chief1983 - Add 3d shockwave, ship choice 3d and weapon choice 3d if TBP is checked
if( tbp.found() )
{
Cmdline_tbp = 1;
Cmdline_enable_3d_shockwave = 1;
Cmdline_ship_choice_3d = 1;
Cmdline_weapon_choice_3d = 1;
}
if ( use_3dwarp.found() ) {
Cmdline_3dwarp = 1;
}
@@ -1187,10 +1225,6 @@ bool SetCmdlineParams()
static_tube_factor = spec_tube_arg.get_float();
}
if ( cell_arg.found() ) {
Cmdline_cell = 1;
}
if ( spec_arg.found() )
{
Cmdline_spec = 1;
@@ -1231,6 +1265,24 @@ bool SetCmdlineParams()
Cmdline_noglsl = 1;
}
if (no_glsl_models_arg.found() ) {
Cmdline_no_glsl_model_rendering = 1;
}
if (fxaa_arg.found() ) {
Cmdline_fxaa = true;
if (fxaa_preset_arg.found()) {
Cmdline_fxaa_preset = fxaa_preset_arg.get_int();
}
Fxaa_preset_last_frame = Cmdline_fxaa_preset;
}
if (no_di_mouse_arg.found() ) {
Cmdline_no_di_mouse = 1;
}
if ( img2dds_arg.found() )
Cmdline_img2dds = 1;
@@ -1290,10 +1342,10 @@ bool SetCmdlineParams()
ubyte build_caps = 0;
/* portej05 defined this always */
build_caps |= BUILD_CAP_NO_D3D;
#ifdef USE_OPENAL
build_caps |= BUILD_CAP_OPENAL;
#endif
build_caps |= BUILD_CAP_NO_D3D;
build_caps |= BUILD_CAP_NEW_SND;
fwrite(&build_caps, 1, 1, fp);
}
@@ -1311,13 +1363,21 @@ bool SetCmdlineParams()
output_sexps("sexps.html");
}
Cmdline_d3d_lesstmem = !d3d_lesstmem_arg.found();
if ( no_vbo_arg.found() )
{
Cmdline_novbo = 1;
}
if ( no_drawrangeelements.found() )
{
Cmdline_drawelements = 1;
}
if( keyboard_layout.found())
{
Cmdline_keyboard_layout = keyboard_layout.str();
}
if ( snd_preload_arg.found() )
{
Cmdline_snd_preload = 1;
@@ -1327,22 +1387,10 @@ bool SetCmdlineParams()
Cmdline_env = 1;
}
if ( decals.found() ) {
#ifdef WIN32
MessageBox(NULL, "Decals have been disabled in builds after May 4, 2006. Please remove the \"-decals\" command line from the launcher to prevent this message from appearing the the future.", "", MB_OK | MB_ICONINFORMATION);
#endif
}
if ( ballistic_gauge.found() ) {
Cmdline_ballistic_gauge = 1;
}
if (wcsaga.found())
{
Cmdline_wcsaga = 1;
}
if ( cache_bitmaps_arg.found() ) {
Cmdline_cache_bitmaps = 1;
}
@@ -1368,11 +1416,7 @@ bool SetCmdlineParams()
if ( ogl_spec_arg.found() ) {
Cmdline_ogl_spec = ogl_spec_arg.get_float();
if ( Cmdline_ogl_spec < 0.0f )
Cmdline_ogl_spec = 0.0f;
if ( Cmdline_ogl_spec > 128.0f )
Cmdline_ogl_spec = 128.0f;
CLAMP(Cmdline_ogl_spec, 0.0f, 128.0f);
}
if ( rearm_timer_arg.found() )
@@ -1390,6 +1434,9 @@ bool SetCmdlineParams()
if ( verify_vps_arg.found() )
Cmdline_verify_vps = 1;
if ( no3dsound_arg.found() )
Cmdline_no_3d_sound = 1;
if ( atiswap_arg.found() )
{
Cmdline_ati_color_swap = 1;
@@ -1400,6 +1447,16 @@ bool SetCmdlineParams()
Cmdline_enable_3d_shockwave = 1;
}
if ( softparticles_arg.found() )
{
Cmdline_softparticles = 1;
}
if ( fb_explosions_arg.found() )
{
Cmdline_fb_explosions = 1;
}
if ( postprocess_arg.found() )
{
Cmdline_postprocess = 1;
@@ -1410,6 +1467,16 @@ bool SetCmdlineParams()
Cmdline_bloom_intensity = bloom_intensity_arg.get_int();
}
if ( percent_flashtobang_arg.found() )
{
Cmdline_percentflashtobang = percent_flashtobang_arg.get_float();
}
if ( do_not_enforce_concurrent_sound.found() )
{
Cmdline_enforce_concurrent_sound_count = 0;
}
return true;
}
@@ -1455,4 +1522,4 @@ int parse_cmdline(char *cmdline)
// If you're looking for the list of if (someparam.found()) { cmdline_someparam = something; } look above at this function
// I did this because of fred2_parse_cmdline()
return SetCmdlineParams();
}
}
+13 -10
View File
@@ -41,7 +41,6 @@ extern int Cmdline_multi_log;
extern int Cmdline_multi_stream_chat_to_file;
extern int Cmdline_network_port;
extern int Cmdline_restricted_game;
extern int Cmdline_server_firing;
extern int Cmdline_spew_pof_info;
extern int Cmdline_start_netgame;
extern int Cmdline_timeout;
@@ -62,8 +61,6 @@ extern float static_light_factor;
extern float static_point_factor;
extern float static_tube_factor;
extern int Cmdline_ambient_factor;
extern int Cmdline_cell;
extern int Cmdline_decals;
extern int Cmdline_env;
extern int Cmdline_mipmap;
extern int Cmdline_missile_lighting;
@@ -74,8 +71,12 @@ extern int Cmdline_spec;
extern int Cmdline_normal;
extern int Cmdline_height;
extern int Cmdline_enable_3d_shockwave;
extern int Cmdline_softparticles;
extern int Cmdline_postprocess;
extern int Cmdline_bloom_intensity;
extern bool Cmdline_fxaa;
extern int Cmdline_fxaa_preset;
extern bool Cmdline_fb_explosions;
// Game Speed related
extern int Cmdline_cache_bitmaps;
@@ -104,9 +105,6 @@ extern int Cmdline_voice_recognition;
// MOD related
extern char *Cmdline_mod; // DTP for mod support
extern int Cmdline_tbp;
extern int Cmdline_wcsaga;
// Multiplayer/Network related
extern char *Cmdline_almission; // DTP for autoload mission (for multi only)
extern int Cmdline_ingamejoin;
@@ -116,17 +114,20 @@ extern char *Cmdline_spew_table_crcs;
extern int Cmdline_objupd;
// Troubleshooting
extern int Cmdline_d3d_lesstmem;
extern int Cmdline_load_all_weapons;
extern int Cmdline_nohtl;
extern int Cmdline_noibx;
extern int Cmdline_nomovies; // WMC Toggles movie playing support
extern int Cmdline_no_set_gamma;
extern int Cmdline_novbo;
extern int Cmdline_safeloading;
extern int Cmdline_no_fbo;
extern int Cmdline_noglsl;
extern int Cmdline_ati_color_swap;
extern int Cmdline_no_3d_sound;
extern int Cmdline_no_glsl_model_rendering;
extern int Cmdline_no_di_mouse;
extern int Cmdline_drawelements;
extern char* Cmdline_keyboard_layout;
// Developer/Testing related
extern char *Cmdline_start_mission;
@@ -134,10 +135,10 @@ extern int Cmdline_dis_collisions;
extern int Cmdline_dis_weapons;
extern int Cmdline_noparseerrors;
extern int Cmdline_nowarn;
extern int Cmdline_extra_warn;
extern int Cmdline_show_mem_usage;
extern int Cmdline_show_pos;
extern int Cmdline_show_stats;
extern int Cmdline_timerbar;
extern int Cmdline_save_render_targets;
extern int Cmdline_debug_window;
extern int Cmdline_verify_vps;
@@ -145,7 +146,9 @@ extern int Cmdline_verify_vps;
extern int Cmdline_no_grab;
#endif
// Temp, only for evaluating new defaults
extern float Cmdline_percentflashtobang;
extern int Cmdline_enforce_concurrent_sound_count;
//extern char FreeSpace_Directory[]; // allievating a cfilesystem problem caused by fred -- Kazan
#endif
+9 -194
View File
@@ -10,8 +10,6 @@
#include "cmeasure/cmeasure.h"
//#include "freespace2/freespace.h"
//#include "model/model.h"
#include "ship/ship.h"
#include "math/staticrand.h"
#include "object/object.h"
@@ -21,192 +19,9 @@
#include "network/multimsgs.h"
#include "mission/missionparse.h"
//cmeasure_info Cmeasure_info[MAX_CMEASURE_TYPES];
//cmeasure Cmeasures[MAX_CMEASURES];
//int Num_cmeasure_types = 0;
//int Num_cmeasures = 0;
//int Cmeasure_inited = 0;
int Cmeasures_homing_check = 0;
int Countermeasures_enabled = 1; // Debug, set to 0 means no one can fire countermeasures.
// This will get called at the start of each level.
//Not anymore - WMC
/*
void cmeasure_init()
{
int i;
if ( !Cmeasure_inited )
Cmeasure_inited = 1;
// Reset everything between levels
Num_cmeasures = 0;
for (i=0; i<MAX_CMEASURES; i++ ) {
Cmeasures[i].subtype = CMEASURE_UNUSED;
}
}*/
/*
void cmeasure_render(object * objp)
{
// JAS TODO: Replace with proper fireball
cmeasure *cmp;
cmeasure_info *cmip;
cmp = &Cmeasures[objp->instance];
cmip = &Cmeasure_info[cmp->subtype];
if ( cmp->subtype == CMEASURE_UNUSED ) {
Int3(); // Hey, what are we doing in here?
return;
}
if ( cmip->model_num > -1 ) {
model_clear_instance(cmip->model_num);
model_render(cmip->model_num, &objp->orient, &objp->pos, MR_NO_LIGHTING );
} else {
mprintf(( "Not rendering countermeasure because model_num is negative\n" ));
}
}*/
/*
void cmeasure_delete( object * objp )
{
int num;
num = objp->instance;
// Assert( Cmeasures[num].objnum == OBJ_INDEX(objp));
Cmeasures[num].subtype = CMEASURE_UNUSED;
Num_cmeasures--;
Assert( Num_cmeasures >= 0 );
}*/
// broke cmeasure_move into two functions -- process_pre and process_post (as was done with
// all *_move functions). Nothing to do for process_pre
/*
void cmeasure_process_pre( object *objp, float frame_time)
{
}*/
/*
void cmeasure_process_post(object * objp, float frame_time)
{
int num;
num = objp->instance;
// Assert( Cmeasures[num].objnum == objnum );
cmeasure *cmp = &Cmeasures[num];
if ( cmp->lifeleft >= 0.0f) {
cmp->lifeleft -= frame_time;
if ( cmp->lifeleft < 0.0f ) {
objp->flags |= OF_SHOULD_BE_DEAD;
// demo_do_flag_dead(OBJ_INDEX(objp));
}
}
}*/
// creates one countermeasure. A ship fires 1 of these per launch. rand_val is used
// in multiplayer. If -1, then create a random number. If non-negative, use this
// number for static_rand functions
/*
int cmeasure_create( object * source_obj, vec3d * pos, int cm_type, int rand_val )
{
int n, objnum, parent_objnum, arand;
object * obj;
ship *shipp;
cmeasure *cmp;
cmeasure_info *cmeasurep;
Cmeasures_homing_check = 2; // Tell homing code to scan everything for two frames. If only one frame, get sync problems due to objects being created at end of frame!
parent_objnum = OBJ_INDEX(source_obj);
Assert( source_obj->type == OBJ_SHIP );
Assert( source_obj->instance >= 0 && source_obj->instance < MAX_SHIPS );
shipp = &Ships[source_obj->instance];
if ( Num_cmeasures >= MAX_CMEASURES)
return -1;
for (n=0; n<MAX_CMEASURES; n++ )
if ( Cmeasures[n].subtype == CMEASURE_UNUSED)
break;
if ( n == MAX_CMEASURES)
return -1;
nprintf(("Network", "Cmeasure created by %s\n", Ships[source_obj->instance].ship_name));
cmp = &Cmeasures[n];
cmeasurep = &Cmeasure_info[cm_type];
if ( pos == NULL )
pos = &source_obj->pos;
objnum = obj_create( OBJ_CMEASURE, parent_objnum, n, &source_obj->orient, pos, 1.0f, OF_RENDERS | OF_PHYSICS );
Assert( objnum >= 0 && objnum < MAX_OBJECTS );
// Create Debris piece n!
if ( rand_val == -1 )
arand = myrand(); // use a random number to get lifeleft, and random vector for displacement from ship
else
arand = rand_val;
cmp->lifeleft = static_randf(arand) * (cmeasurep->life_max - cmeasurep->life_min) / cmeasurep->life_min;
if (source_obj->flags & OF_PLAYER_SHIP){
cmp->lifeleft *= The_mission.ai_profile->cmeasure_life_scale[Game_skill_level];
}
cmp->lifeleft = cmeasurep->life_min + cmp->lifeleft * (cmeasurep->life_max - cmeasurep->life_min);
// cmp->objnum = objnum;
cmp->team = shipp->team;
cmp->subtype = cm_type;
cmp->objnum = objnum;
cmp->source_objnum = parent_objnum;
cmp->source_sig = Objects[objnum].signature;
cmp->flags = 0;
nprintf(("Jim", "Frame %i: Launching countermeasure #%i\n", Framecount, Objects[objnum].signature));
obj = &Objects[objnum];
Num_cmeasures++;
//Set countermeasure velocity
vec3d vel, rand_vec;
//Get cmeasure rear velocity in world
vm_vec_scale_add(&vel, &source_obj->phys_info.vel, &source_obj->orient.vec.fvec, -25.0f);
//Get random velocity vector
static_randvec(arand+1, &rand_vec);
//Add it to the rear velocity
vm_vec_scale_add2(&vel, &rand_vec, 2.0f);
obj->phys_info.vel = vel;
vm_vec_zero(&obj->phys_info.rotvel);
vm_vec_zero(&obj->phys_info.max_vel);
vm_vec_zero(&obj->phys_info.max_rotvel);
// blow out his reverse thrusters. Or drag, same thing.
obj->phys_info.rotdamp = 10000.0f;
obj->phys_info.side_slip_time_const = 10000.0f;
obj->phys_info.max_vel.xyz.z = -25.0f;
vm_vec_copy_scale(&obj->phys_info.desired_vel, &obj->orient.vec.fvec, obj->phys_info.max_vel.xyz.z );
return arand; // need to return this value for multiplayer purposes
}*/
//Used to set a countermeasure velocity after being launched from a ship as a countermeasure
//ie not as a primary or secondary.
void cmeasure_set_ship_launch_vel(object *objp, object *parent_objp, int arand)
@@ -229,12 +44,6 @@ void cmeasure_set_ship_launch_vel(object *objp, object *parent_objp, int arand)
vm_vec_zero(&objp->phys_info.max_vel);
vm_vec_zero(&objp->phys_info.max_rotvel);
//Idunnit. -WMC
//objp->phys_info.flags |= PF_CONST_VEL;
//WMC - I don't think this stuff is needed with the flag I set
//WMC - Or maybe it is.
// blow out his reverse thrusters. Or drag, same thing.
objp->phys_info.rotdamp = 10000.0f;
objp->phys_info.side_slip_time_const = 10000.0f;
@@ -259,12 +68,18 @@ void cmeasure_select_next(ship *shipp)
}
}
//snd_play( &Snds[SND_CMEASURE_CYCLE] );
mprintf(("Countermeasure type set to %i in frame %i\n", shipp->current_cmeasure, Framecount));
}
// If this is a player countermeasure, let the player know he evaded a missile
/**
* @brief If this is a player countermeasure, let the player know they evaded a missile.
* @param objp [description]
*
* During single player games, this function notifies the player that evasion has occurred.
* Multiplayer games ensure that #send_countermeasure_success_packet() is called to notify the other player.
*/
void cmeasure_maybe_alert_success(object *objp)
{
//Is this a countermeasure, and does it have a parent
-45
View File
@@ -16,63 +16,18 @@
#include "globalincs/systemvars.h"
struct object;
//struct vec3d;
//#define MAX_CMEASURES 64
// Goes in cmeasure.subtype
//#define CMEASURE_UNUSED -1
//#define MAX_CMEASURE_TYPES 3
#define CMEASURE_WAIT 333 // delay in milliseconds between countermeasure firing.
//#define CMF_DUD_HEAT 0x01 // If set, this cmeasure is a dud to heat seekers. Set at create time.
//#define CMF_DUD_ASPECT 0x02 // If set, this cmeasure is a dud to aspect seekers. Set at create time.
//#define CMF_DUD (CMF_DUD_HEAT | CMF_DUD_ASPECT)
// Maximum distance at which a countermeasure can be tracked
// If this value is too large, missiles will always be tracking countermeasures.
#define MAX_CMEASURE_TRACK_DIST 300.0f
/*
typedef struct cmeasure_info {
char cmeasure_name[NAME_LENGTH];
//float max_speed; // launch speed, relative to ship
float fire_wait; // time between launches
float life_min, life_max; // lifetime will be in range min..max.
int launch_sound; // Sound played when launched.
char pof_name[NAME_LENGTH];
int model_num; // What this renders as
} cmeasure_info;
typedef struct cmeasure {
int flags; // You know, flag type things.
int subtype; // See CMEASURE_??? defines
int objnum;
int source_objnum; // What object this came from
int source_sig; // Signature of the source object
int team; // Team of the ship where the cmeasure came from
float lifeleft; // When 0 or less object dies
} cmeasure;
*/
//extern cmeasure_info Cmeasure_info[MAX_CMEASURE_TYPES];
//extern cmeasure Cmeasures[MAX_CMEASURES];
//extern int Num_cmeasure_types;
//extern int Num_cmeasures;
extern int Cmeasures_homing_check;
extern int Countermeasures_enabled;
//extern void cmeasure_init();
//extern void cmeasure_render( object * obj );
//extern void cmeasure_delete( object * obj );
//extern void cmeasure_process_pre( object * obj, float frame_time);
//extern void cmeasure_process_post( object * obj, float frame_time);
//extern int cmeasure_create( object * source_obj, vec3d *pos, int cm_type, int rand_val = -1 );
extern void cmeasure_set_ship_launch_vel(object *objp, object *parent_objp, int arand);
extern void cmeasure_select_next(object *objp);
extern void cmeasure_maybe_alert_success(object *objp);
extern float Skill_level_cmeasure_life_scale[NUM_SKILL_LEVELS];
#endif // _CMEASURE_H
File diff suppressed because it is too large. Load diff
+141 -143
View File
@@ -48,171 +48,169 @@ typedef struct config_item {
int used; // has control been used yet in mission? If so, this is the timestamp
} config_item;
// --------------------------------------------------
// Keyboard #defines for the actions
// This is the value of the id field in config_item
// --------------------------------------------------
/**
* All available actions
* This is the value of the id field in config_item
*/
enum IoActionId {
// targeting a ship
TARGET_NEXT =0, //!< target next
TARGET_PREV =1, //!< target previous
TARGET_NEXT_CLOSEST_HOSTILE =2, //!< target the next hostile target
TARGET_PREV_CLOSEST_HOSTILE =3, //!< target the previous closest hostile
TOGGLE_AUTO_TARGETING =4, //!< toggle auto-targeting
TARGET_NEXT_CLOSEST_FRIENDLY =5, //!< target the next friendly ship
TARGET_PREV_CLOSEST_FRIENDLY =6, //!< target the closest friendly ship
TARGET_SHIP_IN_RETICLE =7, //!< target ship closest to center of reticle
TARGET_CLOSEST_SHIP_ATTACKING_TARGET =8, //!< target the closest ship attacking current target
TARGET_LAST_TRANMISSION_SENDER =9, //!< TARGET_LAST_TRANMISSION_SENDER
STOP_TARGETING_SHIP =10, //!< stop targeting ship
// targeting a ship
// targeting a ship's subsystem
TARGET_SUBOBJECT_IN_RETICLE =11, //!< target ships subsystem in reticle
TARGET_NEXT_SUBOBJECT =12, //!< target next subsystem on current target
TARGET_PREV_SUBOBJECT =13, //!< TARGET_PREV_SUBOBJECT
STOP_TARGETING_SUBSYSTEM =14, //!< stop targeting subsystems on ship
#define TARGET_NEXT 0
#define TARGET_PREV 1
#define TARGET_NEXT_CLOSEST_HOSTILE 2
#define TARGET_PREV_CLOSEST_HOSTILE 3
#define TOGGLE_AUTO_TARGETING 4
#define TARGET_NEXT_CLOSEST_FRIENDLY 5
#define TARGET_PREV_CLOSEST_FRIENDLY 6
#define TARGET_SHIP_IN_RETICLE 7
#define TARGET_CLOSEST_SHIP_ATTACKING_TARGET 8
#define TARGET_LAST_TRANMISSION_SENDER 9
#define STOP_TARGETING_SHIP 10
// speed matching
MATCH_TARGET_SPEED =15, //!< match target speed
TOGGLE_AUTO_MATCH_TARGET_SPEED =16, //!< toggle auto-match target speed
// targeting a ship's subsystem
#define TARGET_SUBOBJECT_IN_RETICLE 11
#define TARGET_NEXT_SUBOBJECT 12
#define TARGET_PREV_SUBOBJECT 13
#define STOP_TARGETING_SUBSYSTEM 14
// weapons
FIRE_PRIMARY =17, //!< FIRE_PRIMARY
FIRE_SECONDARY =18, //!< FIRE_SECONDARY
CYCLE_NEXT_PRIMARY =19, //!< cycle to next primary weapon
CYCLE_PREV_PRIMARY =20, //!< cycle to previous primary weapon
CYCLE_SECONDARY =21, //!< cycle to next secondary weapon
CYCLE_NUM_MISSLES =22, //!< cycle number of missiles fired from secondary bank
LAUNCH_COUNTERMEASURE =23, //!< LAUNCH_COUNTERMEASURE
// speed matching
#define MATCH_TARGET_SPEED 15
#define TOGGLE_AUTO_MATCH_TARGET_SPEED 16
// controls
FORWARD_THRUST =24, //!< FORWARD_THRUST
REVERSE_THRUST =25, //!< REVERSE_THRUST
BANK_LEFT =26, //!< BANK_LEFT
BANK_RIGHT =27, //!< BANK_RIGHT
PITCH_FORWARD =28, //!< PITCH_FORWARD
PITCH_BACK =29, //!< PITCH_BACK
YAW_LEFT =30, //!< YAW_LEFT
YAW_RIGHT =31, //!< YAW_RIGHT
// weapons
#define FIRE_PRIMARY 17
#define FIRE_SECONDARY 18
#define CYCLE_NEXT_PRIMARY 19
#define CYCLE_PREV_PRIMARY 20
#define CYCLE_SECONDARY 21
#define CYCLE_NUM_MISSLES 22
#define LAUNCH_COUNTERMEASURE 23
// throttle control
ZERO_THROTTLE =32, //!< ZERO_THROTTLE
MAX_THROTTLE =33, //!< MAX_THROTTLE
ONE_THIRD_THROTTLE =34, //!< ONE_THIRD_THROTTLE
TWO_THIRDS_THROTTLE =35, //!< TWO_THIRDS_THROTTLE
PLUS_5_PERCENT_THROTTLE =36, //!< PLUS_5_PERCENT_THROTTLE
MINUS_5_PERCENT_THROTTLE =37, //!< MINUS_5_PERCENT_THROTTLE
// controls
#define FORWARD_THRUST 24
#define REVERSE_THRUST 25
#define BANK_LEFT 26
#define BANK_RIGHT 27
#define PITCH_FORWARD 28
#define PITCH_BACK 29
#define YAW_LEFT 30
#define YAW_RIGHT 31
// squadmate messaging keys
ATTACK_MESSAGE =38, //!< wingman message: attack current target
DISARM_MESSAGE =39, //!< wingman message: disarm current target
DISABLE_MESSAGE =40, //!< wingman message: disable current target
ATTACK_SUBSYSTEM_MESSAGE =41, //!< wingman message: disable current target
CAPTURE_MESSAGE =42, //!< wingman message: capture current target
ENGAGE_MESSAGE =43, //!< wingman message: engage enemy
FORM_MESSAGE =44, //!< wingman message: form on my wing
IGNORE_MESSAGE =45, //!< IGNORE_MESSAGE
PROTECT_MESSAGE =46, //!< wingman message: protect current target
COVER_MESSAGE =47, //!< wingman message: cover me
WARP_MESSAGE =48, //!< wingman message: warp out
REARM_MESSAGE =49, //!< REARM_MESSAGE
TARGET_CLOSEST_SHIP_ATTACKING_SELF =50, //!< target closest ship that is attacking player
// throttle control
#define ZERO_THROTTLE 32
#define MAX_THROTTLE 33
#define ONE_THIRD_THROTTLE 34
#define TWO_THIRDS_THROTTLE 35
#define PLUS_5_PERCENT_THROTTLE 36
#define MINUS_5_PERCENT_THROTTLE 37
// Views
VIEW_CHASE =51, //!< VIEW_CHASE
VIEW_EXTERNAL =52, //!< VIEW_EXTERNAL
VIEW_EXTERNAL_TOGGLE_CAMERA_LOCK =53, //!< VIEW_EXTERNAL_TOGGLE_CAMERA_LOCK
VIEW_SLEW =54, //!< VIEW_SLEW
VIEW_OTHER_SHIP =55, //!< VIEW_OTHER_SHIP
VIEW_DIST_INCREASE =56, //!< VIEW_DIST_INCREASE
VIEW_DIST_DECREASE =57, //!< VIEW_DIST_DECREASE
VIEW_CENTER =58, //!< VIEW_CENTER
PADLOCK_UP =59, //!< PADLOCK_UP
PADLOCK_DOWN =60, //!< PADLOCK_DOWN
PADLOCK_LEFT =61, //!< PADLOCK_LEFT
PADLOCK_RIGHT =62, //!< PADLOCK_RIGHT
// squadmate messaging keys
#define ATTACK_MESSAGE 38
#define DISARM_MESSAGE 39
#define DISABLE_MESSAGE 40
#define ATTACK_SUBSYSTEM_MESSAGE 41
#define CAPTURE_MESSAGE 42
#define ENGAGE_MESSAGE 43
#define FORM_MESSAGE 44
#define IGNORE_MESSAGE 45
#define PROTECT_MESSAGE 46
#define COVER_MESSAGE 47
#define WARP_MESSAGE 48
#define REARM_MESSAGE 49
RADAR_RANGE_CYCLE =63, //!< cycle to next radar range
SQUADMSG_MENU =64, //!< toggle the squadmate messaging menu
SHOW_GOALS =65, //!< show the mission goals screen
END_MISSION =66, //!< end the mission
TARGET_TARGETS_TARGET =67, //!< target your target's target
AFTERBURNER =68, //!< AFTERBURNER
#define TARGET_CLOSEST_SHIP_ATTACKING_SELF 50
INCREASE_WEAPON =69, //!< increase weapon recharge rate
DECREASE_WEAPON =70, //!< decrease weapon recharge rate
INCREASE_SHIELD =71, //!< increase shield recharge rate
DECREASE_SHIELD =72, //!< decrease shield recharge rate
INCREASE_ENGINE =73, //!< increase energy to engines
DECREASE_ENGINE =74, //!< decrease energy to engines
ETS_EQUALIZE =75, //!< equalize recharge rates
SHIELD_EQUALIZE =76, //!< equalize shield energy to all quadrants
SHIELD_XFER_TOP =77, //!< transfer shield energy to front
SHIELD_XFER_BOTTOM =78, //!< transfer shield energy to rear
SHIELD_XFER_LEFT =79, //!< transfer shield energy to left
SHIELD_XFER_RIGHT =80, //!< transfer shield energy to right
// Views
#define VIEW_CHASE 51
#define VIEW_EXTERNAL 52
#define VIEW_EXTERNAL_TOGGLE_CAMERA_LOCK 53
#define VIEW_SLEW 54
#define VIEW_OTHER_SHIP 55
#define VIEW_DIST_INCREASE 56
#define VIEW_DIST_DECREASE 57
#define VIEW_CENTER 58
#define PADLOCK_UP 59
#define PADLOCK_DOWN 60
#define PADLOCK_LEFT 61
#define PADLOCK_RIGHT 62
XFER_SHIELD =81, //!< transfer energy to shield from weapons
XFER_LASER =82, //!< transfer energy to weapons from shield
//Backslash -- this was a convenient place for Glide When Pressed, since Show Damage Popup isn't used
GLIDE_WHEN_PRESSED =83, //!< GLIDE_WHEN_PRESSED
BANK_WHEN_PRESSED =84, //!< BANK_WHEN_PRESSED
SHOW_NAVMAP =85, //!< SHOW_NAVMAP
ADD_REMOVE_ESCORT =86, //!< ADD_REMOVE_ESCORT
ESCORT_CLEAR =87, //!< ESCORT_CLEAR
TARGET_NEXT_ESCORT_SHIP =88, //!< TARGET_NEXT_ESCORT_SHIP
TARGET_CLOSEST_REPAIR_SHIP =89, //!< target the closest repair ship
TARGET_NEXT_UNINSPECTED_CARGO =90, //!< TARGET_NEXT_UNINSPECTED_CARGO
TARGET_PREV_UNINSPECTED_CARGO =91, //!< TARGET_PREV_UNINSPECTED_CARGO
TARGET_NEWEST_SHIP =92, //!< TARGET_NEWEST_SHIP
TARGET_NEXT_LIVE_TURRET =93, //!< TARGET_NEXT_LIVE_TURRET
TARGET_PREV_LIVE_TURRET =94, //!< TARGET_PREV_LIVE_TURRET
#define RADAR_RANGE_CYCLE 63
#define SQUADMSG_MENU 64
#define SHOW_GOALS 65
#define END_MISSION 66
#define TARGET_TARGETS_TARGET 67
#define AFTERBURNER 68
TARGET_NEXT_BOMB =95, //!< TARGET_NEXT_BOMB
TARGET_PREV_BOMB =96, //!< TARGET_PREV_BOMB
#define INCREASE_WEAPON 69
#define DECREASE_WEAPON 70
#define INCREASE_SHIELD 71
#define DECREASE_SHIELD 72
#define INCREASE_ENGINE 73
#define DECREASE_ENGINE 74
#define ETS_EQUALIZE 75
#define SHIELD_EQUALIZE 76
#define SHIELD_XFER_TOP 77
#define SHIELD_XFER_BOTTOM 78
#define SHIELD_XFER_LEFT 79
#define SHIELD_XFER_RIGHT 80
// multiplayer messaging keys
MULTI_MESSAGE_ALL =97, //!< message all netplayers
MULTI_MESSAGE_FRIENDLY =98, //!< message all friendlies
MULTI_MESSAGE_HOSTILE =99, //!< message all hostiles
MULTI_MESSAGE_TARGET =100, //!< message targeted ship (if player)
#define XFER_SHIELD 81
#define XFER_LASER 82
//#define SHOW_DAMAGE_POPUP 83 // AL: this binding should be removing next time the controls are reorganized
// multiplayer misc keys
MULTI_OBSERVER_ZOOM_TO =101, //!< if i'm an observer, zoom to my targeted object
#define GLIDE_WHEN_PRESSED 83
//Backslash -- this was a convenient place for Glide When Pressed, since Show Damage Popup isn't used
#define BANK_WHEN_PRESSED 84
#define SHOW_NAVMAP 85
#define ADD_REMOVE_ESCORT 86
#define ESCORT_CLEAR 87
#define TARGET_NEXT_ESCORT_SHIP 88
TIME_SPEED_UP =102, //!< TIME_SPEED_UP
TIME_SLOW_DOWN =103, //!< TIME_SLOW_DOWN
#define TARGET_CLOSEST_REPAIR_SHIP 89
#define TARGET_NEXT_UNINSPECTED_CARGO 90
#define TARGET_PREV_UNINSPECTED_CARGO 91
#define TARGET_NEWEST_SHIP 92
#define TARGET_NEXT_LIVE_TURRET 93
#define TARGET_PREV_LIVE_TURRET 94
TOGGLE_HUD_CONTRAST =104, //!< toggle between high and low HUD contrast
#define TARGET_NEXT_BOMB 95
#define TARGET_PREV_BOMB 96
MULTI_TOGGLE_NETINFO =105, //!< toggle network info
// multiplayer messaging keys
#define MULTI_MESSAGE_ALL 97
#define MULTI_MESSAGE_FRIENDLY 98
#define MULTI_MESSAGE_HOSTILE 99
#define MULTI_MESSAGE_TARGET 100
MULTI_SELF_DESTRUCT =106, //!< self destruct (multiplayer only)
// multiplayer misc keys
#define MULTI_OBSERVER_ZOOM_TO 101
TOGGLE_HUD =107, //!< TOGGLE_HUD
RIGHT_SLIDE_THRUST =108, //!< RIGHT_SLIDE_THRUST
LEFT_SLIDE_THRUST =109, //!< LEFT_SLIDE_THRUST
UP_SLIDE_THRUST =110, //!< UP_SLIDE_THRUST
DOWN_SLIDE_THRUST =111, //!< DOWN_SLIDE_THRUST
HUD_TARGETBOX_TOGGLE_WIREFRAME =112, //!< HUD_TARGETBOX_TOGGLE_WIREFRAME
VIEW_TOPDOWN =113, //!< VIEW_TOPDOWN
VIEW_TRACK_TARGET =114, //!< VIEW_TRACK_TARGET
#define TIME_SPEED_UP 102
#define TIME_SLOW_DOWN 103
//AutoPilot - Kazan
AUTO_PILOT_TOGGLE =115, //!< Autopilot key control
NAV_CYCLE =116, //!< NAV_CYCLE
#define TOGGLE_HUD_CONTRAST 104
//Gliding
TOGGLE_GLIDING =117, //!< TOGGLE_GLIDING
#define MULTI_TOGGLE_NETINFO 105
#define MULTI_SELF_DESTRUCT 106
#define TOGGLE_HUD 107
#define RIGHT_SLIDE_THRUST 108
#define LEFT_SLIDE_THRUST 109
#define UP_SLIDE_THRUST 110
#define DOWN_SLIDE_THRUST 111
#define HUD_TARGETBOX_TOGGLE_WIREFRAME 112
#define VIEW_TOPDOWN 113
#define VIEW_TRACK_TARGET 114
//AutoPilot - Kazan
#define AUTO_PILOT_TOGGLE 115
#define NAV_CYCLE 116
//Gliding
#define TOGGLE_GLIDING 117
// this should be the total number of control action defines above (or last define + 1)
#define CCFG_MAX 118
/**
* This must always be below the last defined action
*/
CCFG_MAX //!< The total number of defined control actions (or last define + 1)
};
extern int Failed_key_index;
extern int Invert_heading;
+279 -17
View File
@@ -7,13 +7,17 @@
*
*/
#include <stdio.h>
#include <stdarg.h>
#include "cfile/cfile.h"
#include "controlconfig/controlsconfig.h"
#include "io/key.h"
#include "io/joy.h"
#include "localization/localize.h"
#include "parse/parselo.h"
#include "globalincs/systemvars.h"
#include "globalincs/def_files.h"
#define TARGET_TAB 0
#define SHIP_TAB 1
@@ -159,10 +163,10 @@ config_item Control_config[CCFG_MAX + 1] = {
{ KEY_SHIFTED | KEY_B, -1, TARGET_TAB, true, "Target Previous Hostile Bomb or Bomber" },
// multiplayer messaging keys
{ KEY_1, -1, COMPUTER_TAB, true, "(Multiplayer) Message All", CC_TYPE_CONTINUOUS },
{ KEY_2, -1, COMPUTER_TAB, true, "(Multiplayer) Message Friendly", CC_TYPE_CONTINUOUS },
{ KEY_3, -1, COMPUTER_TAB, true, "(Multiplayer) Message Hostile", CC_TYPE_CONTINUOUS },
{ KEY_4, -1, COMPUTER_TAB, true, "(Multiplayer) Message Target", CC_TYPE_CONTINUOUS },
{ KEY_1, -1, COMPUTER_TAB, true, "(Multiplayer) Message All" },
{ KEY_2, -1, COMPUTER_TAB, true, "(Multiplayer) Message Friendly" },
{ KEY_3, -1, COMPUTER_TAB, true, "(Multiplayer) Message Hostile" },
{ KEY_4, -1, COMPUTER_TAB, true, "(Multiplayer) Message Target" },
{ KEY_ALTED | KEY_X, -1, COMPUTER_TAB, true, "(Multiplayer) Observer Zoom to Target"},
{ KEY_SHIFTED | KEY_PERIOD, -1, COMPUTER_TAB, true, "Increase Time Compression" },
{ KEY_SHIFTED | KEY_COMMA, -1, COMPUTER_TAB, true, "Decrease Time Compression" },
@@ -285,7 +289,7 @@ char *Joy_button_text_french[] = {
"Bouton 13", "Bouton 14", "Bouton 15", "Bouton 16", "Bouton 17", "Bouton 18",
"Bouton 19", "Bouton 20", "Bouton 21", "Bouton 22", "Bouton 23", "Bouton 24",
"Bouton 25", "Bouton 26", "Bouton 27", "Bouton 28", "Bouton 29", "Bouton 30",
"Bouton 31", "Bouton 32", "Chapeau Arrière", "Chapeau Avant", "Chapeau Gauche", "Chapeau Droite"
"Bouton 31", "Bouton 32", "Chapeau Arriere", "Chapeau Avant", "Chapeau Gauche", "Chapeau Droite"
};
// This is the text that is displayed on the screen for the keys a player selects
@@ -445,21 +449,48 @@ int translate_key_to_index(char *key)
// or there is no key current bound to the function, NULL is returned.
char *translate_key(char *key)
{
int index = -1, code = -1;
int index = -1, key_code = -1, joy_code = -1;
char *key_text = NULL;
char *joy_text = NULL;
static char text[40] = {"None"};
index = translate_key_to_index(key);
if (index < 0)
if (index < 0) {
return NULL;
code = Control_config[index].key_id;
Failed_key_index = index;
if (code < 0) {
code = Control_config[index].joy_id;
if (code >= 0)
return Joy_button_text[code];
}
return textify_scancode(code);
key_code = Control_config[index].key_id;
joy_code = Control_config[index].joy_id;
Failed_key_index = index;
if (key_code >= 0) {
key_text = textify_scancode(key_code);
}
if (joy_code >= 0) {
joy_text = Joy_button_text[joy_code];
}
// both key and joystick button are mapped to this control
if ((key_code >= 0 ) && (joy_code >= 0) ) {
strcpy_s(text, key_text);
strcat_s(text, " or ");
strcat_s(text, joy_text);
}
// if we only have one
else if (key_code >= 0 ) {
strcpy_s(text, key_text);
}
else if (joy_code >= 0) {
strcpy_s(text, joy_text);
}
else {
strcpy_s(text, "None");
}
return text;
}
char *textify_scancode(int code)
@@ -497,9 +528,12 @@ char *textify_scancode(int code)
}
//XSTR:ON
void control_config_common_load_overrides();
// initialize common control config stuff - call at game startup after localization has been initialized
void control_config_common_init()
{
control_config_common_load_overrides();
if(Lcl_gr){
Scan_code_text = Scan_code_text_german;
Joy_button_text = Joy_button_text_german;
@@ -517,3 +551,231 @@ void control_config_common_init()
Joy_button_text = Joy_button_text_english;
}
}
#include <map>
#include <string>
std::map<std::string, int> mEnumNameToVal;
void LoadEnumsIntoMap();
void control_config_common_load_overrides()
{
LoadEnumsIntoMap();
if (cf_exists_full("controlconfigdefaults.tbl", CF_TYPE_TABLES))
read_file_text("controlconfigdefaults.tbl", CF_TYPE_TABLES);
else
read_file_text_from_array(defaults_get_file("controlconfigdefaults.tbl"));
reset_parse();
// start parsing
required_string("#ControlConfigOverride");
// read fonts
while (required_string_either("#End","$Bind Name:"))
{
const int iBufferLength = 64;
char szTempBuffer[iBufferLength];
required_string("$Bind Name:");
stuff_string(szTempBuffer, F_NAME, iBufferLength);
const size_t cCntrlAryLength = sizeof(Control_config) / sizeof(Control_config[0]);
for (size_t i = 0; i < cCntrlAryLength; ++i)
{
config_item& r_ccConfig = Control_config[i];
if (!strcmp(szTempBuffer, r_ccConfig.text))
{
/**
* short key_default;
* short joy_default;
* char tab;
* bool hasXSTR;
* char type;
*/
int iTemp;
if (optional_string("$Key Default:"))
{stuff_string(szTempBuffer, F_NAME, iBufferLength);
r_ccConfig.key_default = (short)mEnumNameToVal[szTempBuffer];}
if (optional_string("$Joy Default:"))
{stuff_int(&iTemp); r_ccConfig.joy_default = (short)iTemp;}
if (optional_string("$Key Mod Shift:"))
{stuff_int(&iTemp); r_ccConfig.key_default |= (iTemp == 1) ? KEY_SHIFTED : 0;}
if (optional_string("$Key Mod Alt:"))
{stuff_int(&iTemp); r_ccConfig.key_default |= (iTemp == 1) ? KEY_ALTED : 0;}
if (optional_string("$Key Mod Ctrl:"))
{stuff_int(&iTemp); r_ccConfig.key_default |= (iTemp == 1) ? KEY_CTRLED : 0;}
if (optional_string("$Category:"))
{stuff_string(szTempBuffer, F_NAME, iBufferLength);
r_ccConfig.tab = (char)mEnumNameToVal[szTempBuffer];}
if (optional_string("$Has XStr:"))
{stuff_int(&iTemp); r_ccConfig.hasXSTR = (iTemp == 1);}
if (optional_string("$Type:"))
{stuff_string(szTempBuffer, F_NAME, iBufferLength);
r_ccConfig.type = (char)mEnumNameToVal[szTempBuffer];}
// Nerf the buffer now.
szTempBuffer[0] = '\0';
}
else if ((i + 1) == cCntrlAryLength)
{
error_display(1, "Bind Name not found: %s\n", szTempBuffer);
advance_to_eoln(NULL);
ignore_white_space();
return;
}
}
}
required_string("#End");
}
#define ADD_ENUM_TO_ENUM_MAP(Enum) mEnumNameToVal[#Enum] = (Enum);
void LoadEnumsIntoMap()
{
mEnumNameToVal["KEY_SHIFTED"] = KEY_SHIFTED;
/*
ADD_ENUM_TO_ENUM_MAP(KEY_SHIFTED)
ADD_ENUM_TO_ENUM_MAP(KEY_ALTED)
ADD_ENUM_TO_ENUM_MAP(KEY_CTRLED)
ADD_ENUM_TO_ENUM_MAP(KEY_DEBUGGED)
ADD_ENUM_TO_ENUM_MAP(KEY_DEBUGGED1)
ADD_ENUM_TO_ENUM_MAP(KEY_MASK)
ADD_ENUM_TO_ENUM_MAP(KEY_DEBUG_KEY)
*/
ADD_ENUM_TO_ENUM_MAP(KEY_0)
ADD_ENUM_TO_ENUM_MAP(KEY_1)
ADD_ENUM_TO_ENUM_MAP(KEY_2)
ADD_ENUM_TO_ENUM_MAP(KEY_3)
ADD_ENUM_TO_ENUM_MAP(KEY_4)
ADD_ENUM_TO_ENUM_MAP(KEY_5)
ADD_ENUM_TO_ENUM_MAP(KEY_6)
ADD_ENUM_TO_ENUM_MAP(KEY_7)
ADD_ENUM_TO_ENUM_MAP(KEY_8)
ADD_ENUM_TO_ENUM_MAP(KEY_9)
ADD_ENUM_TO_ENUM_MAP(KEY_A)
ADD_ENUM_TO_ENUM_MAP(KEY_B)
ADD_ENUM_TO_ENUM_MAP(KEY_C)
ADD_ENUM_TO_ENUM_MAP(KEY_D)
ADD_ENUM_TO_ENUM_MAP(KEY_E)
ADD_ENUM_TO_ENUM_MAP(KEY_F)
ADD_ENUM_TO_ENUM_MAP(KEY_G)
ADD_ENUM_TO_ENUM_MAP(KEY_H)
ADD_ENUM_TO_ENUM_MAP(KEY_I)
ADD_ENUM_TO_ENUM_MAP(KEY_J)
ADD_ENUM_TO_ENUM_MAP(KEY_K)
ADD_ENUM_TO_ENUM_MAP(KEY_L)
ADD_ENUM_TO_ENUM_MAP(KEY_M)
ADD_ENUM_TO_ENUM_MAP(KEY_N)
ADD_ENUM_TO_ENUM_MAP(KEY_O)
ADD_ENUM_TO_ENUM_MAP(KEY_P)
ADD_ENUM_TO_ENUM_MAP(KEY_Q)
ADD_ENUM_TO_ENUM_MAP(KEY_R)
ADD_ENUM_TO_ENUM_MAP(KEY_S)
ADD_ENUM_TO_ENUM_MAP(KEY_T)
ADD_ENUM_TO_ENUM_MAP(KEY_U)
ADD_ENUM_TO_ENUM_MAP(KEY_V)
ADD_ENUM_TO_ENUM_MAP(KEY_W)
ADD_ENUM_TO_ENUM_MAP(KEY_X)
ADD_ENUM_TO_ENUM_MAP(KEY_Y)
ADD_ENUM_TO_ENUM_MAP(KEY_Z)
ADD_ENUM_TO_ENUM_MAP(KEY_MINUS)
ADD_ENUM_TO_ENUM_MAP(KEY_EQUAL)
ADD_ENUM_TO_ENUM_MAP(KEY_DIVIDE)
ADD_ENUM_TO_ENUM_MAP(KEY_SLASH)
ADD_ENUM_TO_ENUM_MAP(KEY_SLASH_UK)
ADD_ENUM_TO_ENUM_MAP(KEY_COMMA)
ADD_ENUM_TO_ENUM_MAP(KEY_PERIOD)
ADD_ENUM_TO_ENUM_MAP(KEY_SEMICOL)
ADD_ENUM_TO_ENUM_MAP(KEY_LBRACKET)
ADD_ENUM_TO_ENUM_MAP(KEY_RBRACKET)
ADD_ENUM_TO_ENUM_MAP(KEY_RAPOSTRO)
ADD_ENUM_TO_ENUM_MAP(KEY_LAPOSTRO)
ADD_ENUM_TO_ENUM_MAP(KEY_ESC)
ADD_ENUM_TO_ENUM_MAP(KEY_ENTER)
ADD_ENUM_TO_ENUM_MAP(KEY_BACKSP)
ADD_ENUM_TO_ENUM_MAP(KEY_TAB)
ADD_ENUM_TO_ENUM_MAP(KEY_SPACEBAR)
ADD_ENUM_TO_ENUM_MAP(KEY_NUMLOCK)
ADD_ENUM_TO_ENUM_MAP(KEY_SCROLLOCK)
ADD_ENUM_TO_ENUM_MAP(KEY_CAPSLOCK)
ADD_ENUM_TO_ENUM_MAP(KEY_LSHIFT)
ADD_ENUM_TO_ENUM_MAP(KEY_RSHIFT)
ADD_ENUM_TO_ENUM_MAP(KEY_LALT)
ADD_ENUM_TO_ENUM_MAP(KEY_RALT)
ADD_ENUM_TO_ENUM_MAP(KEY_LCTRL)
ADD_ENUM_TO_ENUM_MAP(KEY_RCTRL)
ADD_ENUM_TO_ENUM_MAP(KEY_F1)
ADD_ENUM_TO_ENUM_MAP(KEY_F2)
ADD_ENUM_TO_ENUM_MAP(KEY_F3)
ADD_ENUM_TO_ENUM_MAP(KEY_F4)
ADD_ENUM_TO_ENUM_MAP(KEY_F5)
ADD_ENUM_TO_ENUM_MAP(KEY_F6)
ADD_ENUM_TO_ENUM_MAP(KEY_F7)
ADD_ENUM_TO_ENUM_MAP(KEY_F8)
ADD_ENUM_TO_ENUM_MAP(KEY_F9)
ADD_ENUM_TO_ENUM_MAP(KEY_F10)
ADD_ENUM_TO_ENUM_MAP(KEY_F11)
ADD_ENUM_TO_ENUM_MAP(KEY_F12)
ADD_ENUM_TO_ENUM_MAP(KEY_PAD0)
ADD_ENUM_TO_ENUM_MAP(KEY_PAD1)
ADD_ENUM_TO_ENUM_MAP(KEY_PAD2)
ADD_ENUM_TO_ENUM_MAP(KEY_PAD3)
ADD_ENUM_TO_ENUM_MAP(KEY_PAD4)
ADD_ENUM_TO_ENUM_MAP(KEY_PAD5)
ADD_ENUM_TO_ENUM_MAP(KEY_PAD6)
ADD_ENUM_TO_ENUM_MAP(KEY_PAD7)
ADD_ENUM_TO_ENUM_MAP(KEY_PAD8)
ADD_ENUM_TO_ENUM_MAP(KEY_PAD9)
ADD_ENUM_TO_ENUM_MAP(KEY_PADMINUS)
ADD_ENUM_TO_ENUM_MAP(KEY_PADPLUS)
ADD_ENUM_TO_ENUM_MAP(KEY_PADPERIOD)
ADD_ENUM_TO_ENUM_MAP(KEY_PADDIVIDE)
ADD_ENUM_TO_ENUM_MAP(KEY_PADMULTIPLY)
ADD_ENUM_TO_ENUM_MAP(KEY_PADENTER)
ADD_ENUM_TO_ENUM_MAP(KEY_INSERT)
ADD_ENUM_TO_ENUM_MAP(KEY_HOME)
ADD_ENUM_TO_ENUM_MAP(KEY_PAGEUP)
ADD_ENUM_TO_ENUM_MAP(KEY_DELETE)
ADD_ENUM_TO_ENUM_MAP(KEY_END)
ADD_ENUM_TO_ENUM_MAP(KEY_PAGEDOWN)
ADD_ENUM_TO_ENUM_MAP(KEY_UP)
ADD_ENUM_TO_ENUM_MAP(KEY_DOWN)
ADD_ENUM_TO_ENUM_MAP(KEY_LEFT)
ADD_ENUM_TO_ENUM_MAP(KEY_RIGHT)
ADD_ENUM_TO_ENUM_MAP(KEY_PRINT_SCRN)
ADD_ENUM_TO_ENUM_MAP(KEY_PAUSE)
ADD_ENUM_TO_ENUM_MAP(KEY_BREAK)
ADD_ENUM_TO_ENUM_MAP(TARGET_TAB)
ADD_ENUM_TO_ENUM_MAP(SHIP_TAB)
ADD_ENUM_TO_ENUM_MAP(WEAPON_TAB)
ADD_ENUM_TO_ENUM_MAP(COMPUTER_TAB)
}
-72
View File
@@ -1,72 +0,0 @@
/*
* Copyright (C) Volition, Inc. 1999. All rights reserved.
*
* All source code herein is the property of Volition, Inc. You may not sell
* or otherwise commercially exploit the source or things you created based on the
* source.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "globalincs/crypt.h"
// we end up #include'ing SDL.h which on Windows and Mac will redfine main() which is something
// that we don't want since we don't actually link against SDL, this solves the problem...
#ifdef main
#undef main
#endif
int main(int argc, char **argv)
{
int i;
char *crypt_string;
if ( argc == 1 ) {
printf("Usage: cryptstring <string1> <string2> ...\n");
printf("Output will be <crypt1> <crypt2>\n");
exit(1);
}
for ( i = 1; i < argc; i++ ) {
char *s;
s = argv[i];
// if the length of the string is greater than the number of crypted symbols we
// return, then pass only the maximum length
if ( strlen(s) > CRYPT_STRING_LENGTH )
s += (strlen(s) - CRYPT_STRING_LENGTH);
crypt_string = jcrypt(s);
printf("%s\n", crypt_string);
}
return 0;
}
char *jcrypt (char *plainstring)
{
int i,t,len;
static char cryptstring[CRYPT_STRING_LENGTH + 1];
len=strlen (plainstring);
if (len > CRYPT_STRING_LENGTH)
len = CRYPT_STRING_LENGTH;
for (i = 0;i < len; i++) {
cryptstring[i]=0;
for (t = 0; t < len; t++) {
cryptstring[i]^=(plainstring[t] ^ plainstring[i%(t+1)]);
cryptstring[i]%=90;
cryptstring[i]+=33;
}
}
cryptstring[i]=0;
return ((char *)cryptstring);
}
+23 -56
View File
@@ -35,7 +35,6 @@ char *Cutscene_mask_name[GR_NUM_RESOLUTIONS] = {
"2_ViewFootage-m"
};
size_t Num_cutscenes;
int Cutscenes_viewable;
int Description_index;
SCP_vector<cutscene_info> Cutscenes;
@@ -43,13 +42,9 @@ SCP_vector<cutscene_info> Cutscenes;
//extern int All_movies_enabled; // If set, all movies may be viewed. Keyed off cheat code.
void cutscene_close()
{
for(size_t i = 0; i < Num_cutscenes; i++)
{
if(Cutscenes[i].description)
{
vm_free(Cutscenes[i].description);
}
}
for(SCP_vector<cutscene_info>::iterator cut = Cutscenes.begin(); cut != Cutscenes.end(); ++cut)
if(cut->description)
vm_free(cut->description);
}
// initialization stuff for cutscenes
@@ -73,7 +68,7 @@ void cutscene_init()
reset_parse();
// parse in all the cutscenes
Num_cutscenes = 0;
Cutscenes.clear();
skip_to_string("#Cutscenes");
ignore_white_space();
@@ -97,7 +92,6 @@ void cutscene_init()
stuff_int( &cutinfo.cd );
Cutscenes.push_back(cutinfo);
Num_cutscenes++;
}
required_string("#End");
@@ -112,25 +106,18 @@ void cutscene_init()
// returns -1 on failure.
int cutscenes_get_cd_num( char *filename )
{
#if defined(OEM_BUILD)
return 0; // only 1 cd for OEM
#else
size_t i;
for (i = 0; i < Num_cutscenes; i++ ) {
if ( !stricmp(Cutscenes[i].filename, filename) ) {
return (Cutscenes[i].cd - 1);
for (SCP_vector<cutscene_info>::iterator cut = Cutscenes.begin(); cut != Cutscenes.end(); ++cut) {
if ( !stricmp(cut->filename, filename) ) {
return (cut->cd - 1);
}
}
return -1;
#endif // defined(OEM_BUILD)
}
// marks a cutscene as viewable
void cutscene_mark_viewable(char *filename)
{
size_t i;
char cut_file[MAX_FILENAME_LEN];
char file[MAX_FILENAME_LEN];
@@ -145,10 +132,10 @@ void cutscene_mark_viewable(char *filename)
// change to lower case
strlwr(file);
for (i = 0; i < Num_cutscenes; i++ ) {
int i = 0;
for (SCP_vector<cutscene_info>::iterator cut = Cutscenes.begin(); cut != Cutscenes.end(); ++cut) {
// change the cutscene file name to lower case
strcpy_s(cut_file, Cutscenes[i].filename);
strcpy_s(cut_file, cut->filename);
strlwr(cut_file);
// see if the stripped filename matches the cutscene filename
@@ -156,6 +143,7 @@ void cutscene_mark_viewable(char *filename)
Cutscenes_viewable |= (1<<i);
return;
}
i++;
}
}
@@ -171,7 +159,6 @@ void cutscene_mark_viewable(char *filename)
#define PLAY_BUTTON 6
#define EXIT_BUTTON 7
static int Num_files;
static SCP_vector<int> Cutscene_list;
//static int Stats_scroll_offset; // not used - taylor
static int Selected_line = 0; // line that is currently selected for binding
@@ -266,9 +253,7 @@ int cutscenes_validate_cd(char *mve_name, int prompt_for_cd)
int cd_mve_is_on;
char volume_name[128];
#ifdef RELEASE_REAL
int num_attempts = 0;
#endif
while(1) {
int path_set_ok;
@@ -279,12 +264,7 @@ int cutscenes_validate_cd(char *mve_name, int prompt_for_cd)
break;
}
#if defined(OEM_BUILD)
sprintf(volume_name, NOX("FS2_OEM"));
#else
sprintf(volume_name, NOX("FREESPACE2_%c"), '1' + cd_mve_is_on);
#endif
cd_drive_num = find_freespace_cd(volume_name);
path_set_ok = set_cdrom_path(cd_drive_num);
@@ -294,7 +274,6 @@ int cutscenes_validate_cd(char *mve_name, int prompt_for_cd)
break;
}
#ifdef RELEASE_REAL
if ( !prompt_for_cd ) {
cd_present = 0;
break;
@@ -304,11 +283,7 @@ int cutscenes_validate_cd(char *mve_name, int prompt_for_cd)
char popup_msg[256];
int popup_rval;
#if defined(DVD_MESSAGE_HACK)
sprintf(popup_msg, XSTR( "Movie not found\n\nInsert FreeSpace DVD to continue", 203));
#else
sprintf(popup_msg, XSTR( "Movie not found\n\nInsert FreeSpace CD #%d to continue", 203), cd_mve_is_on+1);
#endif
popup_rval = popup(PF_BODY_BIG, 2, POPUP_CANCEL, POPUP_OK, popup_msg);
if ( popup_rval != 1 ) {
@@ -320,11 +295,6 @@ int cutscenes_validate_cd(char *mve_name, int prompt_for_cd)
cd_present = 0;
break;
}
#else
cd_present = 0;
break;
#endif
}
return cd_present;
@@ -335,7 +305,7 @@ void cutscenes_screen_play()
char name[MAX_FILENAME_LEN]; // *full_name
int which_cutscene;
Assert( (Selected_line >= 0) && (Selected_line < Num_files) );
Assert( (Selected_line >= 0) && (Selected_line < (int)Cutscene_list.size()) );
which_cutscene = Cutscene_list[Selected_line];
strcpy_s(name, Cutscenes[which_cutscene].filename );
@@ -376,7 +346,7 @@ void cutscenes_screen_scroll_line_down()
{
int h;
if (Selected_line < Num_files - 1) {
if (Selected_line < (int)Cutscene_list.size() - 1) {
Selected_line++;
gamesnd_play_iface(SND_SCROLL);
@@ -413,7 +383,7 @@ void cutscenes_screen_scroll_screen_down()
int h;
h = Cutscene_list_coords[gr_screen.res][3] / gr_get_font_height();
if (Scroll_offset + h < Num_files) {
if (Scroll_offset + h < (int)Cutscene_list.size()) {
Scroll_offset++;
if (Selected_line < Scroll_offset){
Selected_line = Scroll_offset;
@@ -468,7 +438,6 @@ int cutscenes_screen_button_pressed(int n)
void cutscenes_screen_init()
{
int i;
size_t j;
ui_button_info *b;
Ui_window.create(0, 0, gr_screen.max_w_unscaled, gr_screen.max_h_unscaled, 0);
@@ -512,12 +481,12 @@ void cutscenes_screen_init()
// if (All_movies_enabled)
// Cutscenes_viewable = 0xffffffff; // Cheat code enables all movies.
Num_files = 0;
Cutscene_list.clear();
for ( j = 0; j < Num_cutscenes; j++ ) {
size_t size = Cutscenes.size();
for (size_t j=0;j < size;j++) {
if ( Cutscenes_viewable & (1<<j) ) {
Cutscene_list.push_back((int)j);
Num_files++;
}
}
}
@@ -533,7 +502,6 @@ void cutscenes_screen_close()
void cutscenes_screen_do_frame()
{
int i, k, y, z;
size_t t;
int font_height = gr_get_font_height();
int select_tease_line = -1;
@@ -576,11 +544,10 @@ void cutscenes_screen_do_frame()
// the "show-all" hotkey
case KEY_CTRLED | KEY_SHIFTED | KEY_S:
{
Num_files = 0;
Cutscene_list.clear();
for (t = 0; t < Num_cutscenes; t++) {
size_t size = Cutscenes.size();
for (size_t t = 0; t < size; t++) {
Cutscene_list.push_back((int)t);
Num_files++;
}
break;
@@ -598,14 +565,14 @@ void cutscenes_screen_do_frame()
if (List_region.button_down()) {
List_region.get_mouse_pos(NULL, &y);
z = Scroll_offset + y / font_height;
if ((z >= 0) && (z < Num_files))
if ((z >= 0) && (z < (int)Cutscene_list.size()))
select_tease_line = z;
}
if (List_region.pressed()) {
List_region.get_mouse_pos(NULL, &y);
z = Scroll_offset + y / font_height;
if ((z >= 0) && (z < Num_files))
if ((z >= 0) && (z < (int)Cutscene_list.size()))
Selected_line = z;
}
@@ -630,7 +597,7 @@ void cutscenes_screen_do_frame()
y = 0;
z = Scroll_offset;
while (y + font_height <= Cutscene_list_coords[gr_screen.res][3]) {
if (z >= Num_files){
if (z >= (int)Cutscene_list.size()){
break;
}
@@ -672,7 +639,7 @@ void cutscenes_screen_do_frame()
y = 0;
z = Text_offset;
while (y + font_height <= Cutscene_desc_coords[gr_screen.res][3]) {
if (z >= Text_size)
if (z >= Text_size || z >= MAX_TEXT_LINES-1)
break;
len = Text_line_size[z];
-1
View File
@@ -27,7 +27,6 @@ typedef struct cutscene_info
} cutscene_info;
extern SCP_vector<cutscene_info> Cutscenes;
extern size_t Num_cutscenes;
extern int Cutscenes_viewable;
// initializa table data
+28 -112
View File
@@ -10,18 +10,14 @@ extern void *g_vBackBuf1, *g_vBackBuf2;
static ushort *backBuf1, *backBuf2;
static int lookup_initialized;
static void dispatchDecoder16(ushort **pFrame, unsigned char codeType, unsigned char **pData, unsigned char **pOffData, int *pDataRemain, int *curXb, int *curYb);
static void dispatchDecoder16(ushort **pFrame, ubyte codeType, ubyte **pData, ubyte **pOffData, int *pDataRemain, int *curXb, int *curYb);
static void genLoopkupTable();
void decodeFrame16(unsigned char *pFrame, unsigned char *pMap, int mapRemain, unsigned char *pData, int dataRemain)
void decodeFrame16(ubyte *pFrame, ubyte *pMap, int mapRemain, unsigned char *pData, int dataRemain)
{
unsigned char *pOrig;
unsigned char *pOffData, *pEnd;
ubyte *pOrig, *pOffData, *pEnd, op;
ushort offset;
int length;
int op;
int i, j;
int xb, yb;
int length = 0, i, j, xb, yb;
if (!lookup_initialized) {
genLoopkupTable();
@@ -156,21 +152,7 @@ static void patternRow4Pixels2(ushort *pFrame, unsigned char pat0, ushort *p)
unsigned char mask=0x03;
unsigned char shift=0;
ushort pel;
/* ORIGINAL VERSION IS BUGGY
int skip=1;
while (mask != 0) {
pel = p[(mask & pat0) >> shift];
pFrame[0] = pel;
pFrame[2] = pel;
pFrame[g_width + 0] = pel;
pFrame[g_width + 2] = pel;
pFrame += skip;
skip = 4 - skip;
mask <<= 2;
shift += 2;
}
*/
while (mask != 0) {
pel = p[(mask & pat0) >> shift];
pFrame[0] = pel;
@@ -208,10 +190,9 @@ static void patternQuadrant4Pixels(ushort *pFrame, unsigned char pat0, unsigned
for (i=0; i<16; i++) {
pFrame[i&3] = p[(pat & mask) >> shift];
if ((i&3) == 3)
if ((i&3) == 3) {
pFrame += g_width;
}
mask <<= 2;
shift += 2;
}
@@ -232,19 +213,6 @@ static void patternRow2Pixels2(ushort *pFrame, unsigned char pat, ushort *p)
ushort pel;
unsigned char mask=0x1;
/* ORIGINAL VERSION IS BUGGY
int skip=1;
while (mask != 0x10) {
pel = p[(mask & pat) ? 1 : 0];
pFrame[0] = pel;
pFrame[2] = pel;
pFrame[g_width + 0] = pel;
pFrame[g_width + 2] = pel;
pFrame += skip;
skip = 4 - skip;
mask <<= 1;
}
*/
while (mask != 0x10) {
pel = p[(mask & pat) ? 1 : 0];
@@ -266,10 +234,9 @@ static void patternQuadrant2Pixels(ushort *pFrame, unsigned char pat0, unsigned
for (i=0; i<16; i++) {
pFrame[i&3] = p[(pat & mask) ? 1 : 0];
if ((i&3) == 3)
if ((i&3) == 3) {
pFrame += g_width;
}
mask <<= 1;
}
@@ -288,76 +255,63 @@ static void dispatchDecoder16(ushort **pFrame, unsigned char codeType, unsigned
switch(codeType) {
case 0x0:
copyFrame(*pFrame, *pFrame + (backBuf2 - backBuf1));
break; // ADDED
break; // ADDED
case 0x1:
break;
break;
case 0x2:
/* relFar(*(*pOffData)++, 1, &x, &y); */
k = *(*pOffData)++;
x = far_p_table[k*2+0];
y = far_p_table[k*2+1];
copyFrame(*pFrame, *pFrame + x + y*g_width);
(*pDataRemain)--;
break;
break;
case 0x3:
/* relFar(*(*pOffData)++, -1, &x, &y); */
k = *(*pOffData)++;
x = far_n_table[k*2+0];
y = far_n_table[k*2+1];
copyFrame(*pFrame, *pFrame + x + y*g_width);
(*pDataRemain)--;
break;
(*pDataRemain)--;
break;
case 0x4:
/* relClose(*(*pOffData)++, &x, &y); */
k = *(*pOffData)++;
x = close_table[k*2+0];
y = close_table[k*2+1];
copyFrame(*pFrame, *pFrame + (backBuf2 - backBuf1) + x + y*g_width);
(*pDataRemain)--;
break;
break;
case 0x5:
x = (char)*(*pData)++;
y = (char)*(*pData)++;
copyFrame(*pFrame, *pFrame + (backBuf2 - backBuf1) + x + y*g_width);
*pDataRemain -= 2;
break;
break;
case 0x6:
nprintf(("MVE", "STUB: encoding 6 not tested\n"));
for (i=0; i<2; i++) {
*pFrame += 16;
if (++*curXb == (g_width >> 3)) {
*pFrame += 7*g_width;
*curXb = 0;
if (++*curYb == (g_height >> 3))
if (++*curYb == (g_height >> 3)) {
return;
}
}
}
break;
break;
case 0x7:
p[0] = GETPIXELI(pData, 0);
p[1] = GETPIXELI(pData, 0);
if (!((p[0]/*|p[1]*/)&0x8000)) {
for (i=0; i<8; i++) {
patternRow2Pixels(*pFrame, *(*pData), p);
(*pData)++;
*pFrame += g_width;
}
} else {
@@ -366,26 +320,21 @@ static void dispatchDecoder16(ushort **pFrame, unsigned char codeType, unsigned
*pFrame += 2*g_width;
patternRow2Pixels2(*pFrame, *(*pData) >> 4, p);
(*pData)++;
*pFrame += 2*g_width;
}
}
break;
break;
case 0x8:
p[0] = GETPIXEL(pData, 0);
if (!(p[0] & 0x8000)) {
for (i=0; i<4; i++) {
p[0] = GETPIXELI(pData, 0);
p[1] = GETPIXELI(pData, 0);
pat[0] = (*pData)[0];
pat[1] = (*pData)[1];
(*pData) += 2;
patternQuadrant2Pixels(*pFrame, pat[0], pat[1], p);
if (i & 1) {
*pFrame -= (4*g_width - 4);
} else {
@@ -394,7 +343,6 @@ static void dispatchDecoder16(ushort **pFrame, unsigned char codeType, unsigned
}
} else {
p[2] = GETPIXEL(pData, 8);
if (!(p[2]&0x8000)) {
for (i=0; i<4; i++) {
if ((i & 1) == 0) {
@@ -404,7 +352,6 @@ static void dispatchDecoder16(ushort **pFrame, unsigned char codeType, unsigned
pat[0] = *(*pData)++;
pat[1] = *(*pData)++;
patternQuadrant2Pixels(*pFrame, pat[0], pat[1], p);
if (i & 1) {
*pFrame -= (4*g_width - 4);
} else {
@@ -419,21 +366,18 @@ static void dispatchDecoder16(ushort **pFrame, unsigned char codeType, unsigned
}
patternRow2Pixels(*pFrame, *(*pData), p);
(*pData)++;
*pFrame += g_width;
}
}
}
break;
break;
case 0x9:
p[0] = GETPIXELI(pData, 0);
p[1] = GETPIXELI(pData, 0);
p[2] = GETPIXELI(pData, 0);
p[3] = GETPIXELI(pData, 0);
*pDataRemain -= 8;
if (!(p[0] & 0x8000)) {
if (!(p[2] & 0x8000)) {
for (i=0; i<8; i++) {
@@ -452,7 +396,6 @@ static void dispatchDecoder16(ushort **pFrame, unsigned char codeType, unsigned
patternRow4Pixels2(*pFrame, (*pData)[2], p);
*pFrame += 2*g_width;
patternRow4Pixels2(*pFrame, (*pData)[3], p);
(*pData) += 4;
*pDataRemain -= 4;
}
@@ -469,9 +412,7 @@ static void dispatchDecoder16(ushort **pFrame, unsigned char codeType, unsigned
for (i=0; i<4; i++) {
pat[0] = (*pData)[0];
pat[1] = (*pData)[1];
(*pData) += 2;
patternRow4Pixels(*pFrame, pat[0], pat[1], p);
*pFrame += g_width;
patternRow4Pixels(*pFrame, pat[0], pat[1], p);
@@ -480,11 +421,10 @@ static void dispatchDecoder16(ushort **pFrame, unsigned char codeType, unsigned
*pDataRemain -= 8;
}
}
break;
break;
case 0xa:
p[0] = GETPIXEL(pData, 0);
if (!(p[0] & 0x8000)) {
for (i=0; i<4; i++) {
p[0] = GETPIXELI(pData, 0);
@@ -495,11 +435,8 @@ static void dispatchDecoder16(ushort **pFrame, unsigned char codeType, unsigned
pat[1] = (*pData)[1];
pat[2] = (*pData)[2];
pat[3] = (*pData)[3];
(*pData) += 4;
patternQuadrant4Pixels(*pFrame, pat[0], pat[1], pat[2], pat[3], p);
if (i & 1) {
*pFrame -= (4*g_width - 4);
} else {
@@ -508,7 +445,6 @@ static void dispatchDecoder16(ushort **pFrame, unsigned char codeType, unsigned
}
} else {
p[0] = GETPIXEL(pData, 16);
if (!(p[0] & 0x8000)) {
for (i=0; i<4; i++) {
if ((i&1) == 0) {
@@ -517,16 +453,12 @@ static void dispatchDecoder16(ushort **pFrame, unsigned char codeType, unsigned
p[2] = GETPIXELI(pData, 0);
p[3] = GETPIXELI(pData, 0);
}
pat[0] = (*pData)[0];
pat[1] = (*pData)[1];
pat[2] = (*pData)[2];
pat[3] = (*pData)[3];
(*pData) += 4;
patternQuadrant4Pixels(*pFrame, pat[0], pat[1], pat[2], pat[3], p);
if (i & 1) {
*pFrame -= (4*g_width - 4);
} else {
@@ -541,24 +473,21 @@ static void dispatchDecoder16(ushort **pFrame, unsigned char codeType, unsigned
p[2] = GETPIXELI(pData, 0);
p[3] = GETPIXELI(pData, 0);
}
pat[0] = (*pData)[0];
pat[1] = (*pData)[1];
patternRow4Pixels(*pFrame, pat[0], pat[1], p);
*pFrame += g_width;
(*pData) += 2;
}
}
}
break;
break;
case 0xb:
for (i=0; i<8; i++) {
#if BYTE_ORDER == BIG_ENDIAN
ubyte frame_tmp[16];
memcpy(&frame_tmp, *pData, 16);
ushort *swap_tmp;
for (j = 0; j < 16; j += 2) {
swap_tmp = (ushort*)(frame_tmp + j);
@@ -572,7 +501,7 @@ static void dispatchDecoder16(ushort **pFrame, unsigned char codeType, unsigned
*pData += 16;
*pDataRemain -= 16;
}
break;
break;
case 0xc:
for (i=0; i<4; i++) {
@@ -580,74 +509,61 @@ static void dispatchDecoder16(ushort **pFrame, unsigned char codeType, unsigned
p[1] = GETPIXEL(pData, 2);
p[2] = GETPIXEL(pData, 4);
p[3] = GETPIXEL(pData, 6);
for (j=0; j<2; j++) {
for (k=0; k<4; k++) {
(*pFrame)[2*k] = p[k];
(*pFrame)[2*k+1] = p[k];
// (*pFrame)[j+2*k] = p[k];
// (*pFrame)[g_width+j+2*k] = p[k];
}
*pFrame += g_width;
}
*pData += 8;
*pDataRemain -= 8;
}
break;
break;
case 0xd:
for (i=0; i<2; i++) {
p[0] = GETPIXEL(pData, 0);
p[1] = GETPIXEL(pData, 2);
for (j=0; j<4; j++) {
for (k=0; k<4; k++) {
(*pFrame)[k*g_width+j] = p[0];
(*pFrame)[k*g_width+j+4] = p[1];
}
}
*pFrame += 4*g_width;
*pData += 4;
*pDataRemain -= 4;
}
break;
break;
case 0xe:
p[0] = GETPIXEL(pData, 0);
for (i = 0; i < 8; i++) {
for (j = 0; j < 8; j++) {
(*pFrame)[j] = p[0];
}
*pFrame += g_width;
}
*pData += 2;
*pDataRemain -= 2;
break;
break;
case 0xf:
p[0] = GETPIXEL(pData, 0);
p[1] = GETPIXEL(pData, 1);
for (i=0; i<8; i++) {
for (j=0; j<8; j++) {
(*pFrame)[j] = p[(i+j)&1];
}
*pFrame += g_width;
}
*pData += 4;
*pDataRemain -= 4;
break;
break;
default:
break;
break;
}
*pFrame = pDstBak+8;
+2
View File
@@ -127,6 +127,7 @@ bool movie_play(char *name)
} else {
// uh-oh, movie is invalid... Abory, Retry, Fail?
mprintf(("MOVIE ERROR: Found invalid movie! (%s)\n", name));
Mouse_hidden--; // show the mouse cursor!
return false;
}
} else if (rc == MOVIE_MVE) {
@@ -143,6 +144,7 @@ bool movie_play(char *name)
} else {
// uh-oh, movie is invalid... Abory, Retry, Fail?
mprintf(("MOVIE ERROR: Found invalid movie! (%s)\n", name));
Mouse_hidden--; // show the mouse cursor!
return false;
}
}
+19 -24
View File
@@ -1,7 +1,5 @@
#ifdef USE_OPENAL
static int audio_exp_table[256] =
{
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
@@ -24,38 +22,35 @@ static int audio_exp_table[256] =
static int getWord(unsigned char **fin)
{
int value = ((*fin)[1] << 8) | (*fin)[0];
*fin += 2;
return value;
int value = ((*fin)[1] << 8) | (*fin)[0];
*fin += 2;
return value;
}
static void sendWord(short **fout, int nOffset)
{
*(*fout)++ = nOffset;
*(*fout)++ = (short)nOffset;
}
static void processSwath(short *fout, unsigned char *data, int swath, int *offsets)
{
int i;
for (i=0; i<swath; i++)
{
offsets[i&1] += audio_exp_table[data[i]];
sendWord(&fout, offsets[i&1]);
}
int i;
for (i=0; i<swath; i++) {
offsets[i&1] += audio_exp_table[data[i]];
sendWord(&fout, offsets[i&1]);
}
}
void mveaudio_uncompress(short *buffer, unsigned char *data, int length)
void mveaudio_uncompress(short *buffer, unsigned char *data)
{
int nCurOffsets[2];
int swath;
int nCurOffsets[2];
int swath;
data += 4;
swath = getWord(&data) / 2;
nCurOffsets[0] = getWord(&data);
nCurOffsets[1] = getWord(&data);
sendWord(&buffer, nCurOffsets[0]);
sendWord(&buffer, nCurOffsets[1]);
processSwath(buffer, data, swath, nCurOffsets);
data += 4;
swath = getWord(&data) / 2;
nCurOffsets[0] = getWord(&data);
nCurOffsets[1] = getWord(&data);
sendWord(&buffer, nCurOffsets[0]);
sendWord(&buffer, nCurOffsets[1]);
processSwath(buffer, data, swath, nCurOffsets);
}
#endif
+72 -74
View File
@@ -19,7 +19,7 @@
#include "osapi/osapi.h"
#include "io/timer.h"
#include "sound/sound.h"
#include "sound/ds.h"
#include "sound/openal.h"
#include "bmpman/bmpman.h"
//#include "sound/audiostr.h"
@@ -45,7 +45,6 @@ static int mve_audio_canplay = 0;
static int mve_audio_compressed = 0;
static int audiobuf_created;
#ifdef USE_OPENAL
// struct for the audio stream information
typedef struct MVE_AUDIO_T {
ALenum format;
@@ -60,8 +59,7 @@ typedef struct MVE_AUDIO_T {
mve_audio_t *mas; // mve_audio_stream
// audio decompressor
extern void mveaudio_uncompress(short *buffer, unsigned char *data, int length);
#endif // USE_OPENAL
extern void mveaudio_uncompress(short *buffer, unsigned char *data);
// video variables
int g_width, g_height;
@@ -139,8 +137,9 @@ static void mve_timer_start(void)
static int mve_do_timer_wait(void)
{
if (!timer_started)
if (!timer_started) {
return 0;
}
#ifdef SCP_UNIX
int nsec = 0;
@@ -149,11 +148,13 @@ static int mve_do_timer_wait(void)
gettimeofday(&tv, NULL);
if (tv.tv_sec > timer_expire.tv_sec)
if (tv.tv_sec > timer_expire.tv_sec) {
goto end;
}
if ( (tv.tv_sec == timer_expire.tv_sec) && (tv.tv_usec >= timer_expire.tv_usec) )
if ( (tv.tv_sec == timer_expire.tv_sec) && (tv.tv_usec >= timer_expire.tv_usec) ) {
goto end;
}
ts.tv_sec = timer_expire.tv_sec - tv.tv_sec;
ts.tv_nsec = 1000 * (timer_expire.tv_usec - tv.tv_usec);
@@ -172,25 +173,24 @@ static int mve_do_timer_wait(void)
}
end:
timer_expire.tv_usec += micro_frame_delay;
timer_expire.tv_usec += micro_frame_delay;
if (timer_expire.tv_usec > 1000000) {
nsec = timer_expire.tv_usec / 1000000;
timer_expire.tv_sec += nsec;
timer_expire.tv_usec -= nsec * 1000000;
}
if (timer_expire.tv_usec > 1000000) {
nsec = timer_expire.tv_usec / 1000000;
timer_expire.tv_sec += nsec;
timer_expire.tv_usec -= nsec * 1000000;
}
#else
int tv, ts, ts2;
tv = timer_get_microseconds();
if (tv > timer_expire)
if (tv > timer_expire) {
goto end;
}
ts = timer_expire - tv;
ts2 = ts/1000;
Sleep(ts2);
end:
@@ -218,8 +218,9 @@ static void mve_timer_stop()
// setup the audio information from the data stream
void mve_audio_createbuf(ubyte minor, ubyte *data)
{
if (audiobuf_created)
if (audiobuf_created) {
return;
}
// if game sound disabled don't try and play movie audio
if (!Sound_enabled) {
@@ -227,30 +228,29 @@ void mve_audio_createbuf(ubyte minor, ubyte *data)
return;
}
#ifdef USE_OPENAL
int flags, desired_buffer, sample_rate;
int flags, desired_buffer, sample_rate;
mas = (mve_audio_t *) vm_malloc ( sizeof(mve_audio_t) );
mas = (mve_audio_t *) vm_malloc ( sizeof(mve_audio_t) );
memset(mas, 0, sizeof(mve_audio_t));
mas->format = AL_INVALID;
flags = mve_get_ushort(data + 2);
sample_rate = mve_get_ushort(data + 4);
desired_buffer = mve_get_int(data + 6);
flags = mve_get_ushort(data + 2);
sample_rate = mve_get_ushort(data + 4);
desired_buffer = mve_get_int(data + 6);
mas->channels = (flags & 0x0001) ? 2 : 1;
mas->channels = (flags & 0x0001) ? 2 : 1;
mas->bitsize = (flags & 0x0002) ? 16 : 8;
mas->sample_rate = sample_rate;
if (minor > 0) {
mve_audio_compressed = flags & 0x0004 ? 1 : 0;
} else {
if (minor > 0) {
mve_audio_compressed = flags & 0x0004 ? 1 : 0;
} else {
mve_audio_compressed = 0;
}
}
if (mas->bitsize == 16) {
if (mas->bitsize == 16) {
if (mas->channels == 2) {
mas->format = AL_FORMAT_STEREO16;
} else if (mas->channels == 1) {
@@ -278,9 +278,8 @@ void mve_audio_createbuf(ubyte minor, ubyte *data)
OpenAL_ErrorPrint( alSourcef(mas->source_id, AL_GAIN, 1.0f) );
memset(mas->audio_buffer, 0, MVE_AUDIO_BUFFERS * sizeof(ALuint));
#endif // USE_OPENAL
mve_audio_buffer_tail = 0;
mve_audio_buffer_tail = 0;
audiobuf_created = 1;
}
@@ -289,29 +288,27 @@ void mve_audio_createbuf(ubyte minor, ubyte *data)
void mve_audio_play()
{
if (mve_audio_canplay) {
#ifdef USE_OPENAL
ALint status, bqueued;
OpenAL_ErrorCheck( alGetSourcei(mas->source_id, AL_SOURCE_STATE, &status), return );
OpenAL_ErrorCheck( alGetSourcei(mas->source_id, AL_BUFFERS_QUEUED, &bqueued), return );
mve_audio_playing = 1;
if (status != AL_PLAYING && bqueued > 0) {
OpenAL_ErrorPrint( alSourcePlay(mas->source_id) );
}
#endif // USE_OPENAL
}
}
// call this in shutdown to stop and close audio
static void mve_audio_stop()
{
if (!audiobuf_created)
if (!audiobuf_created) {
return;
}
#ifdef USE_OPENAL
ALint p = 0;
mve_audio_playing = 0;
@@ -332,7 +329,6 @@ static void mve_audio_stop()
vm_free(mas);
mas = NULL;
}
#endif // USE_OPENAL
}
int mve_audio_data(ubyte major, ubyte *data)
@@ -342,7 +338,6 @@ int mve_audio_data(ubyte major, ubyte *data)
int nsamp;
if (mve_audio_canplay) {
#ifdef USE_OPENAL
chan = mve_get_ushort(data + 2);
nsamp = mve_get_ushort(data + 4);
@@ -352,13 +347,15 @@ int mve_audio_data(ubyte major, ubyte *data)
OpenAL_ErrorCheck( alGetSourcei(mas->source_id, AL_BUFFERS_PROCESSED, &bprocessed), return 0 );
while (bprocessed-- > 2)
while (bprocessed-- > 2) {
OpenAL_ErrorPrint( alSourceUnqueueBuffers(mas->source_id, 1, &bid) );
}
OpenAL_ErrorCheck( alGetSourcei(mas->source_id, AL_BUFFERS_QUEUED, &bqueued), return 0 );
if (bqueued == 0)
if (bqueued == 0) {
mprintf(("MVE: Buffer underun (First is normal)\n"));
}
OpenAL_ErrorCheck( alGetSourcei(mas->source_id, AL_SOURCE_STATE, &status), return 0 );
@@ -371,37 +368,34 @@ int mve_audio_data(ubyte major, ubyte *data)
/* HACK: +4 mveaudio_uncompress adds 4 more bytes */
if (major == 8) {
if (mve_audio_compressed) {
if (mve_audio_compressed) {
nsamp += 4;
buf = (short *)vm_malloc(nsamp);
mveaudio_uncompress(buf, data, -1); /* XXX */
mveaudio_uncompress(buf, data); /* XXX */
} else {
nsamp -= 8;
data += 8;
buf = (short *)vm_malloc(nsamp);
memcpy(buf, data, nsamp);
}
}
} else {
buf = (short *)vm_malloc(nsamp);
memset(buf, 0, nsamp); /* XXX */
}
if (!mas->audio_buffer[mve_audio_buffer_tail]) {
OpenAL_ErrorCheck( alGenBuffers(1,&mas->audio_buffer[mve_audio_buffer_tail]), { vm_free(buf); return 0; } );
}
OpenAL_ErrorCheck( alBufferData(mas->audio_buffer[mve_audio_buffer_tail], mas->format, buf, nsamp, mas->sample_rate), { vm_free(buf); return 0; } );
OpenAL_ErrorCheck( alSourceQueueBuffers(mas->source_id, 1, &mas->audio_buffer[mve_audio_buffer_tail]), { vm_free(buf); return 0;} );
//fprintf(stderr,"Queued buffer %d(%d)\n", mve_audio_buftail, mas->audio_buffer[mve_audio_buftail]);
if (++mve_audio_buffer_tail == MVE_AUDIO_BUFFERS)
if (++mve_audio_buffer_tail == MVE_AUDIO_BUFFERS) {
mve_audio_buffer_tail = 0;
}
bqueued++;
vm_free(buf);
@@ -409,7 +403,6 @@ int mve_audio_data(ubyte major, ubyte *data)
mprintf(("MVE: Buffer overrun: Queue full\n"));
}
}
#endif // USE_OPENAL
}
return 1;
@@ -421,8 +414,9 @@ int mve_audio_data(ubyte major, ubyte *data)
int mve_video_createbuf(ubyte minor, ubyte *data)
{
if (videobuf_created)
if (videobuf_created) {
return 1;
}
short w, h;
short count, truecolor;
@@ -452,11 +446,11 @@ int mve_video_createbuf(ubyte minor, ubyte *data)
return 0;
}
if (truecolor)
if (truecolor) {
g_vBackBuf2 = (ushort *)g_vBackBuf1 + (g_width * g_height);
else
} else {
g_vBackBuf2 = (ubyte *)g_vBackBuf1 + (g_width * g_height);
}
memset(g_vBackBuf1, 0, g_width * g_height * 4);
g_truecolor = truecolor;
@@ -468,10 +462,11 @@ int mve_video_createbuf(ubyte minor, ubyte *data)
float screen_ratio = (float)gr_screen.max_w / (float)gr_screen.max_h;
float movie_ratio = (float)g_width / (float)g_height;
if (screen_ratio > movie_ratio)
if (screen_ratio > movie_ratio) {
scale_by = (float)gr_screen.max_h / (float)g_height;
else
} else {
scale_by = (float)gr_screen.max_w / (float)g_width;
}
// don't bother setting anything if we aren't going to need it
if (!Cmdline_noscalevid && (scale_by != 1.0f)) {
@@ -517,26 +512,26 @@ static void mve_convert_and_draw()
ubyte r, g, b;
ushort bit_16;
if (g_truecolor)
if (g_truecolor) {
pSrcs = pixels;
else
} else {
pSrcs8 = pixels8;
}
pDests = pixelbuf;
if (gr_screen.mode != GR_OPENGL) {
if (g_screenWidth > g_width)
if (g_screenWidth > g_width) {
pDests += ((g_screenWidth - g_width) / 2) / 2;
if (g_screenHeight > g_height)
}
if (g_screenHeight > g_height) {
pDests += ((g_screenHeight - g_height) / 2) * g_screenWidth;
}
}
for (y=0; y<g_height; y++) {
for (x = 0; x < g_width; x++) {
if (g_truecolor) {
Assert( pSrcs != NULL );
pDests[x] = (1<<15)|*pSrcs;
pSrcs++;
} else {
@@ -631,8 +626,9 @@ void mve_video_display()
int mve_video_init(ubyte *data)
{
if (video_inited)
if (video_inited) {
return 1;
}
short width, height;
@@ -678,8 +674,10 @@ int mve_video_init(ubyte *data)
GL_state.SetAlphaBlendMode(ALPHA_BLEND_NONE);
GL_state.SetZbufferType(ZBUFFER_TYPE_NONE);
GL_state.Texture.SetWrapS(GL_CLAMP_TO_EDGE);
GL_state.Texture.SetWrapT(GL_CLAMP_TO_EDGE);
glTexParameteri(GL_texture_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_texture_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
// NOTE: using NULL instead of pixelbuf crashes some drivers, but then so does pixelbuf
glTexImage2D(GL_state.Texture.GetTarget(), 0, GL_RGB5_A1, wp2, hp2, 0, GL_BGRA_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV, NULL);
@@ -689,9 +687,8 @@ int mve_video_init(ubyte *data)
}
memset(g_palette, 0, 768);
video_inited = 1;
return 1;
}
@@ -731,10 +728,11 @@ void mve_video_data(ubyte *data, int len)
g_vBackBuf2 = temp;
}
if (g_truecolor)
if (g_truecolor) {
decodeFrame16((ubyte *)g_vBackBuf1, g_pCurMap, g_nMapLength, data+14, len-14);
else
} else {
decodeFrame8((ubyte *)g_vBackBuf1, g_pCurMap, g_nMapLength, data+14, len-14);
}
}
void mve_end_chunk()
@@ -763,8 +761,9 @@ void mve_play(MVESTREAM *mve)
int init_timer = 0, timer_error = 0;
int cont = 1;
if (!timer_started)
if (!timer_started) {
mve_timer_start();
}
while (cont && mve_playing && !timer_error) {
cont = mve_play_next_chunk(mve);
@@ -803,6 +802,5 @@ void mve_shutdown()
}
mve_audio_stop();
mve_timer_stop();
}
+177 -35
View File
@@ -10,6 +10,7 @@
#endif
#include "globalincs/pstypes.h"
#include "globalincs/def_files.h"
#include "cfile/cfile.h"
#include "graphics/gropengl.h"
#include "graphics/gropengltexture.h"
@@ -20,7 +21,7 @@
#include "io/key.h"
#include "osapi/osapi.h"
#include "sound/sound.h"
#include "sound/ds.h"
#include "sound/openal.h"
#include "bmpman/bmpman.h"
#include "cutscene/oggplayer.h"
#include "io/timer.h"
@@ -42,6 +43,9 @@ static int g_screenX = 0;
static int g_screenY = 0;
static GLuint GLtex = 0;
static GLuint ytex = 0;
static GLuint utex = 0;
static GLuint vtex = 0;
static GLint gl_screenYH = 0;
static GLint gl_screenXW = 0;
static GLfloat gl_screenU = 0;
@@ -74,7 +78,7 @@ static int audiofd_fragsize = 0;
static longlong videobuf_granulepos = -1;
static double videobuf_time = 0;
static bool use_shaders = true;
// -----------------------------------------------------------------------------
// Utility items
//
@@ -82,8 +86,8 @@ static double videobuf_time = 0;
// helper; just grab some more compressed bitstream and sync it for page extraction
static int OGG_buffer_data(THEORAFILE *movie)
{
char *buffer = ogg_sync_buffer(&movie->osyncstate, 4096);
int bytes = cfread(buffer, 1, 4096, movie->cfp);
char *buffer = ogg_sync_buffer(&movie->osyncstate, 8192); // Doubled read size to fix choppy audio with high bitrate movies - Valathil
int bytes = cfread(buffer, 1, 8192, movie->cfp);
ogg_sync_wrote(&movie->osyncstate, bytes);
@@ -326,6 +330,8 @@ static void OGG_video_init(theora_info *tinfo)
{
float scale_by = 0.0f;
GLhandleARB shader_id = 0;
if (video_inited)
return;
@@ -339,33 +345,137 @@ static void OGG_video_init(theora_info *tinfo)
opengl_set_texture_target(GL_TEXTURE_2D);
opengl_tcache_get_adjusted_texture_size(g_screenWidth, g_screenHeight, &wp2, &hp2);
glGenTextures(1, &GLtex);
if(!Use_GLSL)
use_shaders = false;
Assert( GLtex != 0 );
if(use_shaders) {
glGenTextures(1, &ytex);
glGenTextures(1, &utex);
glGenTextures(1, &vtex);
if ( GLtex == 0 ) {
nprintf(("MOVIE", "ERROR: Can't create a GL texture"));
video_inited = 1;
return;
Assert( ytex != 0 );
Assert( utex != 0 );
Assert( vtex != 0 );
if ( ytex + utex + vtex == 0 ) {
nprintf(("MOVIE", "ERROR: Can't create a GL texture"));
video_inited = 1;
return;
}
char *vert = NULL, *frag = NULL;
opengl_shader_t new_shader;
// choose appropriate files
char *vert_name = "video-v.sdr";
char *frag_name = "video-f.sdr";
mprintf(("Compiling video-processing shader ... \n"));
// read vertex shader
CFILE *cf_shader = cfopen(vert_name, "rt", CFILE_NORMAL, CF_TYPE_EFFECTS);
if (cf_shader != NULL) {
int len = cfilelength(cf_shader);
vert = (char*) vm_malloc(len + 1);
cfread(vert, len + 1, 1, cf_shader);
cfclose(cf_shader);
} else {
mprintf((" Loading built-in default shader for: %s\n", vert_name));
vert = defaults_get_file(vert_name);
}
if(!vert)
use_shaders = false;
// read fragment shader
cf_shader = cfopen(frag_name, "rt", CFILE_NORMAL, CF_TYPE_EFFECTS);
if (cf_shader != NULL) {
int len = cfilelength(cf_shader);
frag = (char*) vm_malloc(len + 1);
cfread(frag, len + 1, 1, cf_shader);
cfclose(cf_shader);
} else {
mprintf((" Loading built-in default shader for: %s\n", frag_name));
frag = defaults_get_file(frag_name);
}
if(!vert)
use_shaders = false;
Verify( vert != NULL );
Verify( frag != NULL );
shader_id = opengl_shader_create(vert, frag);
vglUseProgramObjectARB(shader_id);
if (!shader_id)
use_shaders = false;
}
if(!use_shaders) {
glGenTextures(1, &GLtex);
Assert( GLtex != 0 );
if ( GLtex == 0 ) {
nprintf(("MOVIE", "ERROR: Can't create a GL texture"));
video_inited = 1;
return;
}
}
gr_set_lighting(false, false);
GL_state.Texture.DisableAll();
GL_state.Texture.SetActiveUnit(0);
GL_state.Texture.SetTarget(GL_texture_target);
GL_state.Texture.Enable(GLtex);
if(!use_shaders) {
GL_state.Texture.SetActiveUnit(0);
GL_state.Texture.SetTarget(GL_texture_target);
GL_state.Texture.Enable(GLtex);
glTexParameteri(GL_texture_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_texture_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_state.Texture.GetTarget(), 0, GL_RGB8, wp2, hp2, 0, GL_BGR, GL_UNSIGNED_BYTE, NULL);
}
GL_state.SetTextureSource(TEXTURE_SOURCE_DECAL);
GL_state.SetAlphaBlendMode(ALPHA_BLEND_NONE);
GL_state.SetZbufferType(ZBUFFER_TYPE_NONE);
if(use_shaders) {
GL_state.Texture.SetActiveUnit(0);
GL_state.Texture.SetTarget(GL_texture_target);
GL_state.Texture.Enable(ytex);
glTexParameteri(GL_texture_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_texture_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
GL_state.Texture.SetWrapS(GL_CLAMP_TO_EDGE);
GL_state.Texture.SetWrapT(GL_CLAMP_TO_EDGE);
// NOTE: using NULL instead of pixelbuf crashes some drivers, but then so does pixelbuf
glTexImage2D(GL_state.Texture.GetTarget(), 0, GL_LUMINANCE8, 2048, 2048, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
// NOTE: using NULL instead of pixelbuf crashes some drivers, but then so does pixelbuf
glTexImage2D(GL_state.Texture.GetTarget(), 0, GL_RGB8, wp2, hp2, 0, GL_BGR, GL_UNSIGNED_BYTE, NULL);
GL_state.Texture.SetActiveUnit(1);
GL_state.Texture.SetTarget(GL_texture_target);
GL_state.Texture.Enable(utex);
glTexParameteri(GL_texture_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_texture_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
// NOTE: using NULL instead of pixelbuf crashes some drivers, but then so does pixelbuf
glTexImage2D(GL_state.Texture.GetTarget(), 0, GL_LUMINANCE8, 1024, 1024, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
GL_state.Texture.SetActiveUnit(2);
GL_state.Texture.SetTarget(GL_texture_target);
GL_state.Texture.Enable(vtex);
glTexParameteri(GL_texture_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_texture_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
// NOTE: using NULL instead of pixelbuf crashes some drivers, but then so does pixelbuf
glTexImage2D(GL_state.Texture.GetTarget(), 0, GL_LUMINANCE8, 1024, 1024, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
}
float screen_ratio = (float)gr_screen.max_w / (float)gr_screen.max_h;
float movie_ratio = (float)g_screenWidth / (float)g_screenHeight;
@@ -388,15 +498,17 @@ static void OGG_video_init(theora_info *tinfo)
glColor3f(1.0f, 1.0f, 1.0f);
}
pixelbuf = (ubyte *) vm_malloc_q(g_screenWidth * g_screenHeight * 3);
if(!use_shaders) {
pixelbuf = (ubyte *) vm_malloc_q(g_screenWidth * g_screenHeight * 3);
if (pixelbuf == NULL) {
nprintf(("MOVIE", "ERROR: Can't allocate memory for pixelbuf"));
video_inited = 1;
return;
if (pixelbuf == NULL) {
nprintf(("MOVIE", "ERROR: Can't allocate memory for pixelbuf"));
video_inited = 1;
return;
}
memset( pixelbuf, 0, g_screenWidth * g_screenHeight * 3 );
}
memset( pixelbuf, 0, g_screenWidth * g_screenHeight * 3 );
if (scale_video) {
g_screenX = ((fl2i(gr_screen.max_w / scale_by + 0.5f) - g_screenWidth) / 2);
@@ -414,8 +526,19 @@ static void OGG_video_init(theora_info *tinfo)
gl_screenU = i2fl(g_screenWidth) / i2fl(wp2);
gl_screenV = i2fl(g_screenHeight) / i2fl(hp2);
}
if(use_shaders) {
gl_screenU = i2fl(tinfo->frame_width-1) / i2fl(2048) ;
gl_screenV = i2fl(tinfo->frame_height-1) / i2fl(2048);
GL_state.Texture.SetShaderMode(GL_TRUE);
vglUniform1iARB( vglGetUniformLocationARB(shader_id, "ytex"), 0 );
vglUniform1iARB( vglGetUniformLocationARB(shader_id, "utex"), 1 );
vglUniform1iARB( vglGetUniformLocationARB(shader_id, "vtex"), 2 );
}
}
if(!use_shaders && tinfo->frame_height > 450) {
mprintf(("VIDEO: No shader support and hd video is beeing played this can get choppy."));
}
video_inited = 1;
}
@@ -432,12 +555,23 @@ static void OGG_video_close()
}
GL_state.Texture.Disable();
GL_state.Texture.Delete(GLtex);
glDeleteTextures(1, &GLtex);
if(use_shaders) {
GL_state.Texture.Delete(ytex);
GL_state.Texture.Delete(utex);
GL_state.Texture.Delete(vtex);
glDeleteTextures(1, &ytex);
glDeleteTextures(1, &utex);
glDeleteTextures(1, &vtex);
} else {
GL_state.Texture.Delete(GLtex);
glDeleteTextures(1, &GLtex);
}
opengl_set_texture_target();
ytex = utex = vtex = 0;
GLtex = 0;
GL_state.Texture.SetShaderMode(GL_FALSE);
opengl_shader_set_current( 0 );
}
if (pixelbuf != NULL) {
@@ -453,7 +587,6 @@ static void OGG_video_close()
g_screenX = 0;
g_screenY = 0;
GLtex = 0;
gl_screenYH = 0;
gl_screenXW = 0;
gl_screenU = 0;
@@ -528,16 +661,25 @@ static void convert_YUV_to_RGB(yuv_buffer *yuv)
}
}
extern int Mouse_hidden;
static void OGG_video_draw(theora_state *tstate)
{
yuv_buffer yuv;
theora_decode_YUVout(tstate, &yuv);
convert_YUV_to_RGB(&yuv);
if(!use_shaders)
convert_YUV_to_RGB(&yuv);
if (gr_screen.mode == GR_OPENGL) {
glTexSubImage2D(GL_state.Texture.GetTarget(), 0, 0, 0, g_screenWidth, g_screenHeight, GL_BGR, GL_UNSIGNED_BYTE, pixelbuf);
if(use_shaders) {
GL_state.Texture.SetActiveUnit(0);
glTexSubImage2D(GL_state.Texture.GetTarget(), 0, 0, 0, yuv.y_stride, yuv.y_height, GL_LUMINANCE, GL_UNSIGNED_BYTE, yuv.y);
GL_state.Texture.SetActiveUnit(1);
glTexSubImage2D(GL_state.Texture.GetTarget(), 0, 0, 0, yuv.uv_stride, yuv.uv_height, GL_LUMINANCE, GL_UNSIGNED_BYTE, yuv.u);
GL_state.Texture.SetActiveUnit(2);
glTexSubImage2D(GL_state.Texture.GetTarget(), 0, 0, 0, yuv.uv_stride, yuv.uv_height, GL_LUMINANCE, GL_UNSIGNED_BYTE, yuv.v);
} else {
glTexSubImage2D(GL_state.Texture.GetTarget(), 0, 0, 0, g_screenWidth, g_screenHeight, GL_BGR, GL_UNSIGNED_BYTE, pixelbuf);
}
glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex2i(g_screenX, g_screenY);
@@ -552,7 +694,7 @@ static void OGG_video_draw(theora_state *tstate)
glVertex2i(gl_screenXW, g_screenY);
glEnd();
}
Mouse_hidden = 1;
gr_flip();
os_poll();
-3
View File
@@ -495,7 +495,4 @@ const char *dds_error_string(int code)
default:
return "Abort, retry, fail?";
}
//get a warning otherwise
return "Abort, retry, fail?";
}
+96 -134
View File
@@ -9,7 +9,6 @@
#include "debris/debris.h"
#include "render/3d.h"
#include "fireball/fireballs.h"
@@ -28,17 +27,14 @@
#include "network/multi.h"
#include "network/multimsgs.h"
#include "network/multiutil.h"
#include "weapon/weapon.h"
#define MAX_LIFE 10.0f
#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
#define MAX_HULL_PIECES MAX_DEBRIS_PIECES // limit the number of hull debris chunks that can exist.
// limit the number of hull debris chunks that can exist.
//#define MAX_HULL_PIECES 10
#define MAX_HULL_PIECES MAX_DEBRIS_PIECES //-WMCD
int Num_hull_pieces; // number of hull pieces in existance
debris Hull_debris_list; // head of linked list for hull debris chunks, for quick search
@@ -58,13 +54,10 @@ int Debris_num_submodels = 0;
#define MAX_SPEED_SMALL_DEBRIS 200 // maximum velocity of small debris piece
#define MAX_SPEED_BIG_DEBRIS 150 // maximum velocity of big debris piece
#define MAX_SPEED_CAPITAL_DEBRIS 100 // maximum velocity of capital debris piece
//#define DEBRIS_SPEED_DEBUG
// ---------------------------------------------------------------------------------------
// debris_start_death_roll()
//
// Start the sequence of a piece of debris writhing in unholy agony!!!
//
/**
* Start the sequence of a piece of debris writhing in unholy agony!!!
*/
static void debris_start_death_roll(object *debris_obj, debris *debris_p)
{
if (debris_p->is_hull) {
@@ -86,14 +79,11 @@ static void debris_start_death_roll(object *debris_obj, debris *debris_p)
}
debris_obj->flags |= OF_SHOULD_BE_DEAD;
// demo_do_flag_dead(OBJ_INDEX(debris_obj));
}
// ---------------------------------------------------------------------------------------
// debris_init()
//
// This will get called at the start of each level.
//
/**
* This will get called at the start of each level.
*/
void debris_init()
{
int i;
@@ -117,7 +107,9 @@ void debris_init()
list_init(&Hull_debris_list);
}
// Page in debris bitmaps at level load
/**
* Page in debris bitmaps at level load
*/
void debris_page_in()
{
uint i;
@@ -151,10 +143,9 @@ void debris_page_in()
MONITOR(NumSmallDebrisRend)
MONITOR(NumHullDebrisRend)
// ---------------------------------------------------------------------------------------
// debris_render()
//
//
/**
* Render debris
*/
void debris_render(object * obj)
{
int i, num, swapped;
@@ -210,7 +201,9 @@ void debris_render(object * obj)
}
}
// Removed the DEBRIS_EXPIRE flag, and remove item from Hull_debris_list
/**
* Removed the ::DEBRIS_EXPIRE flag, and remove item from ::Hull_debris_list
*/
void debris_clear_expired_flag(debris *db)
{
if ( db->flags & DEBRIS_EXPIRE ) {
@@ -223,12 +216,11 @@ void debris_clear_expired_flag(debris *db)
}
}
// ---------------------------------------------------------------------------------------
// debris_delete()
//
// Delete the debris object. This is only ever called via obj_delete(). Do not call directly.
// Use debris_start_death_roll() if you want to force a debris piece to die.
//
/**
* Delete the debris object.
* This is only ever called via obj_delete(). Do not call directly.
* Use debris_start_death_roll() if you want to force a debris piece to die.
*/
void debris_delete( object * obj )
{
int num;
@@ -248,9 +240,11 @@ void debris_delete( object * obj )
Num_debris_pieces--;
}
// If debris piece *db is far away from all players, make it go away very soon.
// In single player game, delete if MAX_DEBRIS_DIST from player.
// In multiplayer game, delete if MAX_DEBRIS_DIST from all players.
/**
* If debris piece *db is far away from all players, make it go away very soon.
* In single player game, delete if MAX_DEBRIS_DIST from player.
* In multiplayer game, delete if MAX_DEBRIS_DIST from all players.
*/
void maybe_delete_debris(debris *db)
{
object *objp;
@@ -275,24 +269,16 @@ void maybe_delete_debris(debris *db)
}
}
// broke debris_move into debris_process_pre and debris_process_post as was done with all
// *_move functions on 8/13 by MK and MA.
void debris_process_pre( object *objp, float frame_time)
{
}
MONITOR(NumSmallDebris)
MONITOR(NumHullDebris)
// ---------------------------------------------------------------------------------------
// debris_process_post()
//
// Do various updates to debris: check if time to die, start fireballs
//
// parameters: obj => pointer to debris object
// frame_time => time elapsed since last debris_move() called
//
// Maybe delete debris if it's very far away from player.
/**
* Do various updates to debris: check if time to die, start fireballs
* Maybe delete debris if it's very far away from player.
*
* @param obj pointer to debris object
* @param frame_time time elapsed since last debris_move() called
*/
void debris_process_post(object * obj, float frame_time)
{
int i, num;
@@ -328,10 +314,7 @@ void debris_process_post(object * obj, float frame_time)
return; // If arc_frequency <= 0, this piece has no arcs on it
}
if ( !timestamp_elapsed(db->fire_timeout) && timestamp_elapsed(db->next_fireball)) {
// start the next fireball up in the next 50 - 100 ms
//db->next_fireball = timestamp_rand(60,80);
if ( !timestamp_elapsed(db->fire_timeout) && timestamp_elapsed(db->next_fireball)) {
db->next_fireball = timestamp_rand(db->arc_frequency,db->arc_frequency*2 );
db->arc_frequency += 100;
@@ -352,7 +335,7 @@ void debris_process_post(object * obj, float frame_time)
// Create the spark effects
for (i=0; i<MAX_DEBRIS_ARCS; i++ ) {
if ( !timestamp_valid( db->arc_timestamp[i] ) ) {
//db->arc_timestamp[i] = timestamp_rand(400,1000); // live up to a second
db->arc_timestamp[i] = timestamp(lifetime); // live up to a second
switch( n ) {
@@ -404,11 +387,7 @@ void debris_process_post(object * obj, float frame_time)
// 0.10 second effect
snd_play_3d( &Snds[SND_DEBRIS_ARC_01], &snd_pos, &View_position, obj->radius );
}
}
}
for (i=0; i<MAX_DEBRIS_ARCS; i++ ) {
@@ -427,15 +406,12 @@ void debris_process_post(object * obj, float frame_time)
}
}
}
}
// ---------------------------------------------------------------------------------------
// debris_find_oldest()
//
// Locate the oldest hull debris chunk. Search through the Hull_debris_list, which is a list
// of all the hull debris chunks.
//
/**
* Locate the oldest hull debris chunk. Search through the ::Hull_debris_list, which is a list
* of all the hull debris chunks.
*/
int debris_find_oldest()
{
int oldest_index;
@@ -457,13 +433,18 @@ int debris_find_oldest()
#define DEBRIS_ROTVEL_SCALE 5.0f
void calc_debris_physics_properties( physics_info *pi, vec3d *min, vec3d *max );
// ---------------------------------------------------------------------------------------
// debris_create()
//
// Create debris from an object
//
// 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
/**
* Create debris from an object
*
* @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 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)
{
int i, n, objnum, parent_objnum;
@@ -490,7 +471,6 @@ object *debris_create(object *source_obj, int model_num, int submodel_num, vec3d
dist /= 2.0f;
}
if ( dist > 200.0f ) {
//mprintf(( "Not creating debris that is %.1f m away\n", dist ));
return NULL;
}
}
@@ -580,7 +560,6 @@ object *debris_create(object *source_obj, int model_num, int submodel_num, vec3d
for (i=0; i<MAX_DEBRIS_ARCS; i++ ) {
db->arc_timestamp[i] = timestamp(-1);
// vec3d arc_pts[MAX_DEBRIS_ARCS][2]; // The endpoints of each arc
}
if ( db->is_hull ) {
@@ -634,8 +613,6 @@ object *debris_create(object *source_obj, int model_num, int submodel_num, vec3d
obj->net_signature = multi_get_next_network_signature( MULTI_SIG_DEBRIS );
}
// -- No long need shield: bset_shield_strength(obj, 100.0f); // Hey! Set to some meaningful value!
if (source_obj->type == OBJ_SHIP) {
obj->hull_strength = Ships[source_obj->instance].ship_max_hull_strength/8.0f;
} else
@@ -708,14 +685,8 @@ object *debris_create(object *source_obj, int model_num, int submodel_num, vec3d
vm_vec_copy_scale(&radial_vel, &to_center, scale );
}
// MK: This next line causes debris pieces to get between 50% and 100% of the parent ship's
// velocity. What would be very cool is if the rotational velocity of the parent would become
// translational velocity of the debris piece. This would be based on the location of the debris
// piece in the parent object.
// 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_crossprod ( &vel_from_rotvel, &world_rotvel, &to_center );
@@ -724,10 +695,7 @@ object *debris_create(object *source_obj, int model_num, int submodel_num, vec3d
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_scale_add(&obj->phys_info.vel, &radial_vel, &source_obj->phys_info.vel, frand()/2.0f + 0.5f);
// nprintf(("Andsager","object vel from rotvel: %0.2f, %0.2f, %0.2f\n",vel_from_rotvel.x, vel_from_rotvel.y, vel_from_rotvel.z));
// make sure rotational velocity does not get too high
// make sure rotational velocity does not get too high
if (radius < 1.0) {
radius = 1.0f;
}
@@ -755,29 +723,20 @@ object *debris_create(object *source_obj, int model_num, int submodel_num, vec3d
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 ( hull_flag ) {
// vm_vec_zero(&pi->vel);
// vm_vec_zero(&pi->rotvel);
// }
return obj;
}
// ---------------------------------------------------------------------------------------
// debris_hit()
//
// Alas, poor debris_obj got whacked. Fortunately, we know who did it, where and how hard, so we
// can do something about it.
//
/**
* Alas, poor debris_obj got whacked. Fortunately, we know who did it, where and how hard, so we
* can do something about it.
*/
void debris_hit(object *debris_obj, object *other_obj, vec3d *hitpos, float damage)
{
debris *debris_p = &Debris[debris_obj->instance];
// Do a little particle spark shower to show we hit
{
particle_emitter pe;
@@ -826,13 +785,11 @@ void debris_hit(object *debris_obj, object *other_obj, vec3d *hitpos, float dama
}
}
// ---------------------------------------------------------------------------------------
// debris_check_collision()
//
// See if poor debris object *obj got whacked by evil *other_obj at point *hitpos.
// NOTE: debris_hit_info pointer NULL for debris:weapon collision, otherwise debris:ship collision.
// Return true if hit, else return false.
//
/**
* See if poor debris object *obj got whacked by evil *other_obj at point *hitpos.
* NOTE: debris_hit_info pointer NULL for debris:weapon collision, otherwise debris:ship collision.
* @return true if hit, else return false.
*/
int debris_check_collision(object *pdebris, object *other_obj, vec3d *hitpos, collision_info_struct *debris_hit_info)
{
mc_info mc;
@@ -849,6 +806,7 @@ int debris_check_collision(object *pdebris, object *other_obj, vec3d *hitpos, co
if ( debris_hit_info == NULL ) {
// debris weapon collision
Assert( other_obj->type == OBJ_WEAPON );
mc.model_instance_num = -1;
mc.model_num = Debris[num].model_num; // Fill in the model to check
mc.submodel_num = Debris[num].submodel_num;
model_clear_instance( mc.model_num );
@@ -862,6 +820,10 @@ int debris_check_collision(object *pdebris, object *other_obj, vec3d *hitpos, co
*hitpos = mc.hit_point_world;
}
weapon *wp = &Weapons[other_obj->instance];
wp->collisionOccured = true;
wp->collisionInfo = mc_info(mc);
return mc.num_hits;
}
@@ -904,6 +866,7 @@ int debris_check_collision(object *pdebris, object *other_obj, vec3d *hitpos, co
int mc_ret_val = 0;
if ( debris_hit_info->heavy == ship_obj ) { // ship is heavier, so debris is sphere. Check sphere collision against ship poly model
mc.model_instance_num = Ships[ship_obj->instance].model_instance_num;
mc.model_num = Ship_info[Ships[ship_obj->instance].ship_info_index].model_num; // Fill in the model to check
mc.orient = &ship_obj->orient; // The object's orient
mc.radius = pdebris->radius;
@@ -918,9 +881,9 @@ int debris_check_collision(object *pdebris, object *other_obj, vec3d *hitpos, co
// first test against the sphere - if this fails then don't do any submodel tests
mc.flags = MC_ONLY_SPHERE | MC_CHECK_SPHERELINE;
int submodel_list[MAX_ROTATING_SUBMODELS];
int num_rotating_submodels = 0;
SCP_vector<int> submodel_vector;
polymodel *pm;
polymodel_instance *pmi;
ship_model_start(ship_obj);
@@ -931,42 +894,43 @@ int debris_check_collision(object *pdebris, object *other_obj, vec3d *hitpos, co
// Do collision the cool new way
if ( debris_hit_info->collide_rotate ) {
SCP_vector<int>::iterator smv;
// We collide with the sphere, find the list of rotating submodels and test one at a time
model_get_rotating_submodel_list(submodel_list, &num_rotating_submodels, heavy_obj);
model_get_rotating_submodel_list(&submodel_vector, heavy_obj);
// Get polymodel and turn off all rotating submodels, collide against only 1 at a time.
pm = model_get(Ship_info[Ships[heavy_obj->instance].ship_info_index].model_num);
pmi = model_get_instance(Ships[heavy_obj->instance].model_instance_num);
// turn off all rotating submodels and test for collision
int i;
for (i=0; i<num_rotating_submodels; i++) {
pm->submodel[submodel_list[i]].blown_off = 1;
for (smv = submodel_vector.begin(); smv != submodel_vector.end(); ++smv) {
pmi->submodel[*smv].collision_checked = true;
}
// reset flags to check MC_CHECK_MODEL | MC_CHECK_SPHERELINE and maybe MC_CHECK_INVISIBLE_FACES and MC_SUBMODEL_INSTANCE
mc.flags = copy_flags | MC_SUBMODEL_INSTANCE;
// check each submodel in turn
for (i=0; i<num_rotating_submodels; i++) {
for (smv = submodel_vector.begin(); smv != submodel_vector.end(); ++smv) {
// turn on submodel for collision test
pm->submodel[submodel_list[i]].blown_off = 0;
pmi->submodel[*smv].collision_checked = false;
// set angles for last frame (need to set to prev to get p0)
angles copy_angles = pm->submodel[submodel_list[i]].angs;
angles copy_angles = pmi->submodel[*smv].angs;
// find the start and end positions of the sphere in submodel RF
pm->submodel[submodel_list[i]].angs = pm->submodel[submodel_list[i]].sii->prev_angs;
world_find_model_point(&p0, &light_obj->last_pos, pm, submodel_list[i], &heavy_obj->last_orient, &heavy_obj->last_pos);
pmi->submodel[*smv].angs = pmi->submodel[*smv].prev_angs;
world_find_model_instance_point(&p0, &light_obj->last_pos, pm, pmi, *smv, &heavy_obj->last_orient, &heavy_obj->last_pos);
pm->submodel[submodel_list[i]].angs = copy_angles;
world_find_model_point(&p1, &light_obj->pos, pm, submodel_list[i], &heavy_obj->orient, &heavy_obj->pos);
pmi->submodel[*smv].angs = copy_angles;
world_find_model_instance_point(&p1, &light_obj->pos, pm, pmi, *smv, &heavy_obj->orient, &heavy_obj->pos);
mc.p0 = &p0;
mc.p1 = &p1;
// mc.pos = zero // in submodel RF
mc.orient = &vmd_identity_matrix;
mc.submodel_num = submodel_list[i];
mc.submodel_num = *smv;
if ( model_collide(&mc) ) {
if ( mc.hit_dist < debris_hit_info->hit_time ) {
@@ -974,24 +938,23 @@ int debris_check_collision(object *pdebris, object *other_obj, vec3d *hitpos, co
// set up debris_hit_info common
set_hit_struct_info(debris_hit_info, &mc, SUBMODEL_ROT_HIT);
model_find_world_point(&debris_hit_info->hit_pos, &mc.hit_point, mc.model_num, mc.hit_submodel, &heavy_obj->orient, &zero);
model_instance_find_world_point(&debris_hit_info->hit_pos, &mc.hit_point, mc.model_num, mc.model_instance_num, mc.hit_submodel, &heavy_obj->orient, &zero);
// set up debris_hit_info for rotating submodel
if (debris_hit_info->edge_hit == 0) {
model_find_obj_dir(&debris_hit_info->collision_normal, &mc.hit_normal, heavy_obj, mc.hit_submodel);
model_instance_find_obj_dir(&debris_hit_info->collision_normal, &mc.hit_normal, heavy_obj, mc.hit_submodel);
}
// find position in submodel RF of light object at collison
vec3d int_light_pos, diff;
vm_vec_sub(&diff, mc.p1, mc.p0);
vm_vec_scale_add(&int_light_pos, mc.p0, &diff, mc.hit_dist);
model_find_world_point(&debris_hit_info->light_collision_cm_pos, &int_light_pos, mc.model_num, mc.hit_submodel, &heavy_obj->orient, &zero);
model_instance_find_world_point(&debris_hit_info->light_collision_cm_pos, &int_light_pos, mc.model_num, mc.model_instance_num, mc.hit_submodel, &heavy_obj->orient, &zero);
}
}
// Don't look at this submodel again
pm->submodel[submodel_list[i]].blown_off = 1;
pmi->submodel[*smv].collision_checked = true;
}
}
// Recover and do usual ship_ship collision, but without rotating submodels
@@ -1010,7 +973,7 @@ int debris_check_collision(object *pdebris, object *other_obj, vec3d *hitpos, co
// get collision normal if not edge hit
if (debris_hit_info->edge_hit == 0) {
model_find_obj_dir(&debris_hit_info->collision_normal, &mc.hit_normal, heavy_obj, mc.hit_submodel);
model_instance_find_obj_dir(&debris_hit_info->collision_normal, &mc.hit_normal, heavy_obj, mc.hit_submodel);
}
// find position in submodel RF of light object at collison
@@ -1020,12 +983,11 @@ int debris_check_collision(object *pdebris, object *other_obj, vec3d *hitpos, co
}
}
ship_model_stop( ship_obj );
}
} else {
// Debris is heavier obj
mc.model_instance_num = -1;
mc.model_num = Debris[num].model_num; // Fill in the model to check
mc.submodel_num = Debris[num].submodel_num;
model_clear_instance( mc.model_num );
@@ -1081,11 +1043,9 @@ int debris_check_collision(object *pdebris, object *other_obj, vec3d *hitpos, co
}
}
// ---------------------------------------------------------------------------------------
// debris_get_team()
//
// Return the team field for a debris object
//
/**
* Return the team field for a debris object
*/
int debris_get_team(object *objp)
{
Assert( objp->type == OBJ_DEBRIS );
@@ -1093,7 +1053,9 @@ int debris_get_team(object *objp)
return Debris[objp->instance].team;
}
// fills in debris physics properties when created, specifically mass and moment of inertia
/**
* Fills in debris physics properties when created, specifically mass and moment of inertia
*/
void calc_debris_physics_properties( physics_info *pi, vec3d *mins, vec3d *maxs )
{
float dx, dy, dz, mass;
+1 -3
View File
@@ -42,7 +42,7 @@ typedef struct debris {
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
int arc_frequency; // Starts at 0, gets bigger
char parent_alt_name;
int parent_alt_name;
float damage_mult;
} debris;
@@ -52,7 +52,6 @@ typedef struct debris {
#define DEBRIS_USED (1<<0)
#define DEBRIS_EXPIRE (1<<1) // debris can expire (ie hull chunks from small ships)
#define MAX_DEBRIS_PIECES 64
extern debris Debris[MAX_DEBRIS_PIECES];
@@ -64,7 +63,6 @@ struct collision_info_struct;
void debris_init();
void debris_render( object * obj );
void debris_delete( object * obj );
void debris_process_pre( object * obj, float frame_time);
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 );
int debris_check_collision( object * obj, object * other_obj, vec3d * hitpos, collision_info_struct *debris_hit_info=NULL );
+195 -166
View File
@@ -21,7 +21,6 @@
#include "io/key.h"
#include "globalincs/alphacolors.h"
#include "osapi/osapi.h"
#include "debugconsole/dbugfile.h"
#define MAX_COMMANDS 300
@@ -34,35 +33,35 @@ debug_command::debug_command(char *_name, char *_help, void (*_func)() )
{
int i;
if ( Num_debug_commands >= MAX_COMMANDS ) {
if ( Num_debug_commands >= MAX_COMMANDS ) {
Int3(); // Too many debug console commands!! Increase MAX_COMMANDS!!
return;
}
for (i=0; i<Num_debug_commands; i++ ) {
for (i=0; i<Num_debug_commands; i++ ) {
int ret = stricmp( Debug_command[i]->name, _name );
if ( ret == 0) {
if ( ret == 0) {
Int3(); // This debug console command already exists!!!!
return;
} else if ( ret > 0 ) {
} else if ( ret > 0 ) {
break; // Insert it here
} else if ( ret < 0 ) {
} else if ( ret < 0 ) {
// do nothing
}
}
if ( i < Num_debug_commands ) {
if ( i < Num_debug_commands ) {
// Insert it at element i
int j;
for (j=Num_debug_commands; j>i; j-- ) {
for (j=Num_debug_commands; j>i; j-- ) {
Debug_command[j] = Debug_command[j-1];
}
Debug_command[i] = this;
Debug_command[i] = this;
Num_debug_commands++;
} else {
Debug_command[Num_debug_commands] = this;
Debug_command[Num_debug_commands] = this;
Num_debug_commands++;
}
@@ -72,17 +71,18 @@ debug_command::debug_command(char *_name, char *_help, void (*_func)() )
}
// some global variables
int Dc_command; // If this is set, then process the command
int Dc_help; // If this is set, then print out the help text in the form, "usage: ... \nLong description\n" );
int Dc_status; // If this is set, then print out the current status of the command.
char *Dc_arg; // The (lowercased) string value of the argument retrieved from dc_arg
char *Dc_arg_org; // Dc_arg before it got converted to lowercase
uint Dc_arg_type; // The type of dc_arg.
char *Dc_command_line; // The rest of the command line, from the end of the last processed arg on.
int Dc_arg_int; // If Dc_arg_type & ARG_INT is set, then this is the value
float Dc_arg_float; // If Dc_arg_type & ARG_FLOAT is set, then this is the value
int Dc_command; // If this is set, then process the command
int Dc_help; // If this is set, then print out the help text in the form, "usage: ... \nLong description\n" );
int Dc_status; // If this is set, then print out the current status of the command.
char *Dc_arg; // The (lowercased) string value of the argument retrieved from dc_arg
char *Dc_arg_org; // Dc_arg before it got converted to lowercase
uint Dc_arg_type; // The type of dc_arg.
char *Dc_command_line; // The rest of the command line, from the end of the last processed arg on.
int Dc_arg_int; // If Dc_arg_type & ARG_INT is set, then this is the value
ubyte Dc_arg_ubyte; // If Dc_arg_type & ARG_UBYTE is set, then this is the value
float Dc_arg_float; // If Dc_arg_type & ARG_FLOAT is set, then this is the value
int scroll_times = 0; // incremented each time display scrolls
int scroll_times = 0; // incremented each time display scrolls
int debug_inited = 0;
@@ -112,7 +112,7 @@ typedef enum {
#define MAX_TOKEN_STRING_LENGTH 128
char scanner_ch;
char scanner_ch;
TOKEN_CODE scanner_token;
char scanner_token_string[MAX_TOKEN_STRING_LENGTH];
@@ -126,7 +126,7 @@ CHAR_CODE scanner_char_table[256];
void scanner_get_char()
{
if ( *scanner_bufferp == '\0' ) {
if ( *scanner_bufferp == '\0' ) {
scanner_ch = 0;
return;
}
@@ -144,26 +144,23 @@ void scanner_init()
scanner_char_table['.'] = DIGIT;
scanner_char_table['-'] = DIGIT;
scanner_char_table['+'] = DIGIT;
scanner_char_table['_'] = LETTER;
scanner_char_table[34] = QUOTE;
scanner_char_table[0] = EOF_CODE;
scanner_char_table[':'] = LETTER;
scanner_char_table['\\'] = LETTER;
scanner_ch = 0;
}
void scanner_skip_blanks()
{
while( (scanner_ch ==' ') || (scanner_ch =='\t') )
while( (scanner_ch ==' ') || (scanner_ch =='\t') )
scanner_get_char();
}
void scanner_downshift_word()
{
int offset = 'a' - 'A';
@@ -178,10 +175,9 @@ void scanner_downshift_word()
} while (*tp != '\0' );
}
void scanner_get_word()
{
while( (scanner_char_code(scanner_ch)==LETTER) || (scanner_char_code(scanner_ch)==DIGIT) ) {
while( (scanner_char_code(scanner_ch)==LETTER) || (scanner_char_code(scanner_ch)==DIGIT) ) {
*scanner_tokenp++ = scanner_ch;
scanner_get_char();
}
@@ -190,13 +186,12 @@ void scanner_get_word()
scanner_token = IDENTIFIER;
}
void scanner_get_string()
{
*scanner_tokenp++ = 34;
scanner_get_char();
while(scanner_ch != 34 ) {
while(scanner_ch != 34 ) {
*scanner_tokenp++ = scanner_ch;
scanner_get_char();
}
@@ -206,21 +201,18 @@ void scanner_get_string()
scanner_token = STRING;
}
void scanner_get_token()
{
scanner_skip_blanks();
scanner_tokenp = scanner_token_string;
*scanner_tokenp = 0;
switch( scanner_char_code(scanner_ch) ) {
case QUOTE: scanner_get_string(); break;
case EOF_CODE: scanner_token = NO_TOKEN; break;
switch( scanner_char_code(scanner_ch) ) {
case QUOTE: scanner_get_string(); break;
case EOF_CODE: scanner_token = NO_TOKEN; break;
case DIGIT:
case LETTER: scanner_get_word(); break;
default:
case LETTER: scanner_get_word(); break;
default:
*scanner_tokenp++ = scanner_ch;
*scanner_tokenp = '\0';
scanner_get_char();
@@ -237,7 +229,6 @@ void scanner_start_command( char * s )
scanner_get_char();
}
int Dc_debug_on = 0;
jmp_buf dc_bad_arg;
@@ -245,98 +236,126 @@ void dc_get_arg(uint type)
{
scanner_get_token();
Dc_command_line = scanner_bufferp;
Dc_command_line = scanner_bufferp;
Dc_arg_org = scanner_token_string;
Dc_arg = scanner_word_string;
if (Dc_debug_on) {
if (Dc_debug_on) {
dc_printf( "next arg is '%s', was originally '%s'\n", Dc_arg, Dc_arg_org );
dc_printf( "Rest of the command line is '%s'\n", Dc_command_line );
}
if ( scanner_token == NO_TOKEN ) {
if ( scanner_token == NO_TOKEN ) {
Dc_arg_type = ARG_NONE;
} else if ( scanner_token == IDENTIFIER ) {
} else if ( scanner_token == IDENTIFIER ) {
Dc_arg_type = ARG_STRING;
} else if ( scanner_token == STRING ) {
} else if ( scanner_token == STRING ) {
Dc_arg_type = ARG_QUOTE;
} else {
Dc_arg_type = ARG_STRING;
}
if ( Dc_arg_type & ARG_STRING ) {
if ( Dc_arg_type & ARG_STRING ) {
int i, num_digits, len;
len = strlen(Dc_arg);
num_digits = 0;
for (i=0; i<len; i++)
if ( scanner_char_table[Dc_arg[i]] == DIGIT ) num_digits++;
if ( num_digits==len ) {
Dc_arg_type |= ARG_FLOAT;
Dc_arg_float = (float)atof(Dc_arg);
if ( !strchr( Dc_arg, '.' )) {
Dc_arg_type |= ARG_INT;
Dc_arg_int = atoi(Dc_arg);
for (i=0; i<len; i++) {
if ( scanner_char_table[Dc_arg[i]] == DIGIT ) {
num_digits++;
}
} else {
if ( (Dc_arg[0] == '0') && (Dc_arg[1] == 'x') ) {
char *p;
int n;
n = strtol(Dc_arg,&p,0);
if ( *p == 0 ) {
Dc_arg_type |= ARG_INT|ARG_HEX;
Dc_arg_int = n;
if ( num_digits==len ) {
Dc_arg_type |= ARG_FLOAT;
Dc_arg_float = (float)atof(Dc_arg);
if ( !strchr( Dc_arg, '.' )) {
Dc_arg_type |= ARG_INT;
Dc_arg_int = atoi(Dc_arg);
Dc_arg_type |= ARG_UBYTE;
Dc_arg_ubyte = (ubyte)atoi(Dc_arg);
}
}
} else {
if ( (Dc_arg[0] == '0') && (Dc_arg[1] == 'x') ) {
char *p;
int n;
n = strtol(Dc_arg,&p,0);
if ( *p == 0 ) {
Dc_arg_type |= ARG_INT|ARG_HEX;
Dc_arg_int = n;
}
}
}
}
if (Dc_debug_on) {
if ( Dc_arg_type & ARG_FLOAT )
if (Dc_debug_on) {
if ( Dc_arg_type & ARG_FLOAT ) {
dc_printf( "Found float number! %f\n", Dc_arg_float );
}
if ( Dc_arg_type & ARG_INT )
if ( Dc_arg_type & ARG_INT ) {
dc_printf( "Found int number! %d\n", Dc_arg_int );
}
if ( Dc_arg_type & ARG_HEX )
if ( Dc_arg_type & ARG_UBYTE ) {
dc_printf( "Found ubyte number! %d\n", Dc_arg_ubyte );
}
if ( Dc_arg_type & ARG_HEX ) {
dc_printf( "Found hex number! 0x%x\n", Dc_arg_int );
}
}
if ( !stricmp( Dc_arg, "on" ))
if ( !stricmp( Dc_arg, "on" ) ) {
Dc_arg_type |= ARG_TRUE;
if ( !stricmp( Dc_arg, "true" ))
}
if ( !stricmp( Dc_arg, "true" ) ) {
Dc_arg_type |= ARG_TRUE;
if ( !stricmp( Dc_arg, "off" ))
}
if ( !stricmp( Dc_arg, "off" ) ) {
Dc_arg_type |= ARG_FALSE;
if ( !stricmp( Dc_arg, "false" ))
}
if ( !stricmp( Dc_arg, "false" ) ) {
Dc_arg_type |= ARG_FALSE;
}
if ( !stricmp( Dc_arg, "+" ))
if ( !stricmp( Dc_arg, "+" ) ) {
Dc_arg_type |= ARG_PLUS;
}
if ( !stricmp( Dc_arg, "-" ))
if ( !stricmp( Dc_arg, "-" ) ) {
Dc_arg_type |= ARG_MINUS;
}
if ( !stricmp( Dc_arg, "," ))
if ( !stricmp( Dc_arg, "," ) ) {
Dc_arg_type |= ARG_COMMA;
}
}
if ( Dc_arg_type & ARG_INT) {
if ( Dc_arg_int )
if ( Dc_arg_type & ARG_INT) {
if ( Dc_arg_int ) {
Dc_arg_type |= ARG_TRUE;
else
} else {
Dc_arg_type |= ARG_FALSE;
}
}
if ( !(Dc_arg_type&type) ) {
if ( (Dc_arg_type & ARG_NONE) && !(type & ARG_NONE))
if ( Dc_arg_type & ARG_UBYTE) {
if ( Dc_arg_ubyte ) {
Dc_arg_type |= ARG_TRUE;
} else {
Dc_arg_type |= ARG_FALSE;
}
}
if ( !(Dc_arg_type&type) ) {
if ( (Dc_arg_type & ARG_NONE) && !(type & ARG_NONE) ) {
dc_printf( "Error: Not enough parameters.\n" );
else
} else {
dc_printf( "Error: '%s' invalid type\n", Dc_arg );
longjmp(dc_bad_arg,1);
longjmp(dc_bad_arg,1);
}
}
}
void debug_help();
@@ -347,80 +366,85 @@ void debug_do_command(char * command)
int i;
int mode = 0;
if ( strlen(command) < 1 ) return;
if ( strlen(command) < 1 ) {
return;
}
Dc_debug_on = 0;
Dc_command_line = command;
scanner_start_command(command);
if (setjmp(dc_bad_arg) ) {
if (setjmp(dc_bad_arg) ) {
return;
}
dc_get_arg( ARG_ANY );
if ( !strcmp( Dc_arg, "debug" ) ) {
if ( !strcmp( Dc_arg, "debug" ) ) {
Dc_debug_on = 1;
dc_printf( "Command line: '%s'\n", Dc_command_line );
dc_get_arg( ARG_ANY );
}
if ( !stricmp( Dc_arg, "xyzzy" ) ) {
if ( !stricmp( Dc_arg, "xyzzy" ) ) {
dc_printf("Nothing happens.\n");
return;
}
if ( !strcmp( Dc_arg, "?" ) ) {
if ( !strcmp( Dc_arg, "?" ) ) {
mode = 1;
dc_get_arg( ARG_ANY );
if ( Dc_arg_type&ARG_NONE ) {
debug_help();
if ( Dc_arg_type&ARG_NONE ) {
debug_help();
return;
}
}
if ( !strcmp( Dc_arg, "help" ) || !strcmp( Dc_arg, "man" ) ) {
if ( !strcmp( Dc_arg, "help" ) || !strcmp( Dc_arg, "man" ) ) {
mode = 2;
dc_get_arg( ARG_ANY );
if ( Dc_arg_type&ARG_NONE ) {
debug_help();
if ( Dc_arg_type&ARG_NONE ) {
debug_help();
return;
}
}
if ( strstr( Dc_command_line, "?" ) ) {
if ( strstr( Dc_command_line, "?" ) ) {
mode = 2;
}
if ( !(Dc_arg_type&ARG_STRING) ) {
if ( !(Dc_arg_type&ARG_STRING) ) {
dc_printf( "Invalid keyword '%s'\n", Dc_arg );
return;
}
if (Dc_debug_on) {
if (Dc_debug_on) {
dc_printf( "Searching for command '%s'\n", Dc_arg );
}
for (i=0; i<Num_debug_commands; i++ ) {
if ( !stricmp( Debug_command[i]->name, Dc_arg )) {
for (i=0; i<Num_debug_commands; i++ ) {
if ( !stricmp( Debug_command[i]->name, Dc_arg ) ) {
if (mode==0) {
if (Dc_debug_on)
if (mode==0) {
if (Dc_debug_on) {
dc_printf( "Calling function '%s'\n", Dc_arg );
}
Dc_command = 1;
Dc_help = 0;
Dc_status = 1;
} else if (mode==1) {
if (Dc_debug_on)
if (Dc_debug_on) {
dc_printf( "Checking status for '%s'\n", Dc_arg );
}
Dc_command = 0;
Dc_help = 0;
Dc_status = 1;
} else {
if (Dc_debug_on)
if (Dc_debug_on) {
dc_printf( "Doing help for '%s'\n", Dc_arg );
}
Dc_command = 0;
Dc_help = 1;
Dc_status = 0;
@@ -428,9 +452,9 @@ void debug_do_command(char * command)
(*Debug_command[i]->func)();
if (mode==0) {
if (mode==0) {
dc_get_arg(ARG_ANY);
if (!(Dc_arg_type&ARG_NONE)) {
if (!(Dc_arg_type&ARG_NONE)) {
dc_printf( "Ignoring the unused command line tail '%s %s'\n", Dc_arg_org, Dc_command_line );
}
}
@@ -445,7 +469,7 @@ void debug_do_command(char * command)
void debug_draw()
{
int i;
gr_clear();
gr_set_font(FONT1);
gr_set_color_fast( &Color_bright );
@@ -453,12 +477,12 @@ void debug_draw()
gr_set_color_fast( &Color_normal );
for (i=0; i<DROWS; i++ ) {
for (i=0; i<DROWS; i++ ) {
gr_string( 0, i*16+16, debug_text[i] );
}
int t = timer_get_fixed_seconds() / (F1_0/3);
if ( t & 1 ) {
if ( t & 1 ) {
int w,h;
char c;
@@ -466,10 +490,10 @@ void debug_draw()
debug_text[debug_y][command_line_pos+1] = 0;
gr_get_string_size( &w, &h, debug_text[debug_y] );
//gr_string( w, debug_y*16, "_" );
gr_rect(w+1,debug_y*16+1+16,2,14);
debug_text[debug_y][command_line_pos+1] = c;
}
@@ -479,17 +503,18 @@ void debug_draw()
void debug_output( char c )
{
if ( c == '\t' ) {
if ( c == '\t' ) {
int next_tab = ((debug_x/28)+1)*28;
if ( next_tab >= DCOLS-1 ) {
if ( next_tab >= DCOLS-1 ) {
debug_x=0;
debug_y++;
scroll_times++;
if ( debug_y >= DROWS ) {
if ( debug_y >= DROWS ) {
int i;
for (i=1; i<DROWS; i++ )
for (i=1; i<DROWS; i++ ) {
strcpy_s( debug_text[i-1], debug_text[i] );
}
debug_y = DROWS-1;
debug_x = 0;
debug_text[debug_y][debug_x] = 0;
@@ -498,26 +523,30 @@ void debug_output( char c )
return;
}
for ( ; debug_x < next_tab; )
for ( ; debug_x < next_tab; ) {
debug_text[debug_y][debug_x++] = ' ';
}
debug_text[debug_y][debug_x] = 0;
return;
}
if ( (c == '\n') || (debug_x >= DCOLS-1) ) {
if ( (c == '\n') || (debug_x >= DCOLS-1) ) {
debug_x=0;
debug_y++;
scroll_times++;
if ( debug_y >= DROWS ) {
if ( debug_y >= DROWS ) {
int i;
for (i=1; i<DROWS; i++ )
for (i=1; i<DROWS; i++ ) {
strcpy_s( debug_text[i-1], debug_text[i] );
}
debug_y = DROWS-1;
debug_x = 0;
debug_text[debug_y][debug_x] = 0;
}
debug_text[debug_y][debug_x] = 0;
if ( c == '\n' ) return;
if ( c == '\n' ) {
return;
}
}
debug_text[debug_y][debug_x++] = c;
@@ -528,72 +557,72 @@ void dc_printf(char *format, ...)
{
char tmp[DCOLS*DROWS];
va_list args;
va_start(args, format);
vsprintf(tmp, format, args);
va_end(args);
char *p = tmp;
while( *p != '\0' ) {
while( *p != '\0' ) {
debug_output(*p);
p++;
}
}
}
void debug_init()
{
int i;
if ( debug_inited ) return;
if ( debug_inited ) {
return;
}
debug_inited = 1;
debug_x=0;
debug_y=0;
for (i=0; i<DROWS; i++ ) {
for (i=0; i<DROWS; i++ ) {
debug_text[i][0] = 0;
}
dc_printf("Debug console started.\n" );
}
void debug_console( void (*_func)() )
{
int done = 0;
scanner_init();
while( key_inkey() ){
while( key_inkey() ) {
os_poll();
}
if ( !debug_inited ) debug_init();
if ( !debug_inited ) {
debug_init();
}
debug_draw();
while (!done) {
while (!done) {
// poll the os
os_poll();
int k = key_inkey();
switch( k ) {
switch( k ) {
case KEY_SHIFTED+KEY_ENTER:
case KEY_ESC:
done=1; break;
case KEY_ESC:
done=1; break;
case KEY_BACKSP:
if ( command_line_pos > 0 ) {
if ( command_line_pos > 0 ) {
command_line[--command_line_pos] = 0;
}
break;
case KEY_F3:
if ( last_oldcommand > -1 ) {
if ( last_oldcommand > -1 ) {
strcpy_s( command_line, oldcommand_line[last_oldcommand] );
command_line_pos = strlen(command_line);
command_line[command_line_pos] = 0;
@@ -602,10 +631,11 @@ void debug_console( void (*_func)() )
case KEY_UP:
command_scroll--;
if (command_scroll<0)
if (command_scroll<0) {
command_scroll = last_oldcommand;
}
if ( command_scroll > -1 ) {
if ( command_scroll > -1 ) {
strcpy_s( command_line, oldcommand_line[command_scroll] );
command_line_pos = strlen(command_line);
command_line[command_line_pos] = 0;
@@ -614,46 +644,44 @@ void debug_console( void (*_func)() )
case KEY_DOWN:
command_scroll++;
if (command_scroll>last_oldcommand)
if (command_scroll>last_oldcommand) {
command_scroll = 0;
if (command_scroll>last_oldcommand)
}
if (command_scroll>last_oldcommand) {
command_scroll = -1;
if ( command_scroll > -1 ) {
}
if ( command_scroll > -1 ) {
strcpy_s( command_line, oldcommand_line[command_scroll] );
command_line_pos = strlen(command_line);
command_line[command_line_pos] = 0;
}
break;
case KEY_ENTER: {
case KEY_ENTER: {
debug_output( '\n' );
debug_draw();
debug_do_command(command_line);
int i, found = 0;
for (i=0; i<=last_oldcommand; i++ ) {
if (!stricmp( oldcommand_line[i], command_line )) {
for (i=0; i<=last_oldcommand; i++ ) {
if (!stricmp( oldcommand_line[i], command_line )) {
found = 1;
}
}
if ( !found ) {
if ( last_oldcommand < DEBUG_HISTORY-1 ) {
if ( !found ) {
if ( last_oldcommand < DEBUG_HISTORY-1 ) {
last_oldcommand++;
strcpy_s( oldcommand_line[last_oldcommand], command_line);
} else {
int iLoop;
for (iLoop=0; iLoop<last_oldcommand; iLoop++ ) {
for (iLoop=0; iLoop<last_oldcommand; iLoop++ ) {
strcpy_s( oldcommand_line[iLoop], oldcommand_line[iLoop+1] );
}
strcpy_s( oldcommand_line[last_oldcommand], command_line);
}
}
// int i;
// for (i=0; i<=last_oldcommand; i++ ) {
// dc_printf( "OC %d. %s\n", i, oldcommand_line[i] );
// }
debug_output( '\n' );
command_line_pos = 0;
command_line[command_line_pos] = 0;
@@ -662,7 +690,7 @@ void debug_console( void (*_func)() )
}
break;
default: {
default: {
ubyte c = (ubyte)key_to_ascii(k);
if ( c != 255 ) {
command_line[command_line_pos++] = c;
@@ -675,12 +703,12 @@ void debug_console( void (*_func)() )
strcat_s( debug_text[debug_y], command_line );
debug_draw();
if ( _func ){
if ( _func ) {
_func();
}
}
while( key_inkey() ){
while( key_inkey() ) {
os_poll();
}
}
@@ -689,24 +717,25 @@ void debug_help()
{
int s, i;
dc_printf( "Available functions:\n\n" );
dc_printf( "Available functions:\n\n" );
s = scroll_times;
for (i=0; i<Num_debug_commands; i++ ) {
for (i=0; i<Num_debug_commands; i++ ) {
dc_printf( " %s - %s\n", Debug_command[i]->name, Debug_command[i]->help );
//mprintf(( "Scroll times %d\n", scroll_times - s ));
if ( scroll_times - s > DROWS - 3 ) {
if ( scroll_times - s > DROWS - 3 ) {
int k;
dc_printf( " Press a key...B for back\n" );
debug_draw();
k = key_getch();
s = scroll_times;
if ( k == KEY_B ) {
if ( k == KEY_B ) {
i -= ((DROWS-3)*2);
if ( i <= 0 )
if ( i <= 0 ) {
i = -1;
}
}
}
}
debug_draw();
}
dc_printf( "\n" );
-406
View File
@@ -1,406 +0,0 @@
#include "dbugfile.h"
#include "globalincs/pstypes.h"
#ifdef _WIN32
#include <windows.h>
#endif
#include <time.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/timeb.h>
int dbugfile_counters[MAX_COUNTERS];
bool dbugfile_init_var = false;
char dbugfile_filename[512];
void dbugfile_output(char *buffer)
{
if(dbugfile_init_var == false)
{
return;
}
FILE *fp = fopen(dbugfile_filename, "a");
if(fp == NULL)
{
return;
}
fwrite(buffer, sizeof(char) * strlen(buffer), 1, fp);
fclose(fp);
}
void dbugfile_init()
{
// Clear the counters
memset(dbugfile_counters, 0, sizeof(int) * MAX_COUNTERS);
char big_buffer[1000];
char temp_buff[512];
dbugfile_filename[0] = '\0';
#ifdef _WIN32
char path[MAX_PATH];
GetCurrentDirectory(MAX_PATH, path);
int path_len = strlen(path);
if(path[path_len - 1] != '\\')
{
path[path_len] = '\\';
path[path_len + 1] = '\0';
}
strcpy_s(dbugfile_filename, path);
#endif
strcat_s(dbugfile_filename, "DBUG-");
strcpy_s(big_buffer, "DBUGFILE Active: ");
#ifdef _WIN32
{
unsigned long len = 512;
GetUserName(temp_buff, &len);
strcat_s(dbugfile_filename, temp_buff);
strcat_s(big_buffer, temp_buff);
strcat_s(dbugfile_filename, "-");
strcat_s(big_buffer, " ");
}
#endif
_tzset();
// Display operating system-style date and time.
_strdate( temp_buff);
strcat_s(dbugfile_filename, "D(");
strcat_s(dbugfile_filename,temp_buff);
strcat_s(big_buffer,temp_buff);
strcat_s(dbugfile_filename, ") T(");
strcat_s(big_buffer, " ");
_strtime( temp_buff);
strcat_s(dbugfile_filename,temp_buff);
strcat_s(big_buffer,temp_buff);
strcat_s(dbugfile_filename, ").txt");
strcat_s(big_buffer, "\n");
// Remove invalid slash chars
int len = strlen(dbugfile_filename);
while(len >= 2)
{
if(dbugfile_filename[len] == '/' || dbugfile_filename[len] == ':')
{
dbugfile_filename[len] = '-';
}
len--;
}
// open file
// Uncomment this to see where the file is going
//MessageBox(NULL, dbugfile_filename, "das", MB_OK);
FILE *fp = fopen(dbugfile_filename, "w");
if(fp == NULL)
{
return;
}
fwrite(big_buffer, sizeof(char) * strlen(big_buffer), 1, fp);
#ifdef _WIN32
// detect OS type
OSVERSIONINFO version_info;
version_info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if(GetVersionEx(&version_info) != false)
{
char *error = "Error in detecting OS version";
char *version = error;
switch(version_info.dwMajorVersion)
{
case 4:
{
if(version_info.dwMinorVersion == 0)
{
version = "Windows 95";
}
else if(version_info.dwMinorVersion == 10)
{
version = "Windows 98";
}
else if(version_info.dwMinorVersion == 90)
{
version = "Windows Me";
}
break;
}
case 5:
{
if(version_info.dwMinorVersion == 0)
{
version = "Windows 2000";
}
else if(version_info.dwMinorVersion == 1)
{
version = "Windows XP";
}
break;
}
}
char *release_type = NULL;
#ifdef _DEBUG
release_type = "Debug";
#else
release_type = "Release";
#endif
sprintf(big_buffer, "OS: %s %s, ", version, release_type);
}
fwrite(big_buffer, sizeof(char) * strlen(big_buffer), 1, fp);
char exe_name[MAX_PATH];
GetModuleFileName(NULL, exe_name, MAX_PATH);
strcat_s(exe_name, "\n");
fwrite(exe_name, sizeof(char) * strlen(exe_name), 1, fp);
#endif
fclose(fp);
dbugfile_init_var = true;
}
void dbugfile_deinit()
{
dbugfile_output("Normal end");
dbugfile_init_var = false;
}
void dbugfile_sprintf(int line, char *file, const char *format, ...)
{
if(dbugfile_init_var == false)
{
return;
}
// find last slash (for PC) to crop file path
char *ptr = strrchr(file, '\\');
if(ptr == NULL)
{
ptr = file;
}
else
{
ptr++;
}
char buffer[1000];
int i = sprintf(buffer, "[%s,%4d] ", ptr, line);
va_list ap;
char *p, *sval;
long ival;
double dval;
// Add each extra parameter to string
va_start(ap, format);
for(p = (char *) format; *p; p++)
{
if(*p != '%')
{
*(buffer + i) = *p;
i++;
continue;
}
p++;
switch(*p)
{
case 'd':
{
ival = va_arg(ap, int);
i += sprintf(buffer+i,"%d", ival);
break;
}
case 'c':
{
ival = va_arg(ap, char);
buffer[i] = (char) ival;
i++;
break;
}
case 'x':
{
ival = va_arg(ap, int);
i += sprintf(buffer+i,"%x", ival);
break;
}
case 'f':
{
dval = va_arg(ap, double);
i += sprintf(buffer+i,"%f", dval);
break;
}
case 's':
{
for(sval = va_arg(ap, char *); *sval; sval++)
{
*(buffer + i++) = *sval;
}
break;
}
default:
{
i += sprintf(buffer+i,"N/A: %%%c", *p);
break;
}
}
}
va_end(ap);
i += sprintf(buffer + i, "\n");
dbugfile_output(buffer);
}
void dbugfile_print_matrix_4x4(int line, char *file, float *matrix, char *text)
{
if(dbugfile_init_var == false)
{
return;
}
if(matrix == NULL)
{
return;
}
// find last slash (for PC) to crop file path
char *ptr = strrchr(file, '\\');
if(ptr == NULL)
{
ptr = file;
}
else
{
ptr++;
}
if(text == NULL)
{
text = "";
}
char buffer[1000];
sprintf(buffer,"[%s,%4d] Matrix %s:\n"
"%f %f %f %f\n"
"%f %f %f %f\n"
"%f %f %f %f\n"
"%f %f %f %f\n",
ptr,line, text,
matrix[0],
matrix[1],
matrix[2],
matrix[3],
matrix[4],
matrix[5],
matrix[6],
matrix[7],
matrix[8],
matrix[9],
matrix[10],
matrix[11],
matrix[12],
matrix[13],
matrix[14],
matrix[15]);
dbugfile_output(buffer);
}
void dbugfile_print_matrix_3x3(int line, char *file, float *matrix, char *text)
{
if(dbugfile_init_var == false)
{
return;
}
if(matrix == NULL)
{
return;
}
// find last slash (for PC) to crop file path
char *ptr = strrchr(file, '\\');
if(ptr == NULL)
{
ptr = file;
}
else
{
ptr++;
}
if(text == NULL)
{
text = "";
}
char buffer[1000];
sprintf(buffer,"[%s,%4d] Matrix %s:\n"
"%f %f %f\n"
"%f %f %f\n"
"%f %f %f\n",
ptr,line, text,
matrix[0],
matrix[1],
matrix[2],
matrix[3],
matrix[4],
matrix[5],
matrix[6],
matrix[7],
matrix[8]);
dbugfile_output(buffer);
}
void dbugfile_print_counter(int line, char *file, int counter_num, char *string)
{
char buffer[1000];
strcpy_s(buffer, string);
strcat_s(buffer, " %d");
dbugfile_sprintf(line, file, buffer, dbugfile_counters[counter_num]);
}
-66
View File
@@ -1,66 +0,0 @@
#ifndef _DBUGFILE_HEADER_
#define _DBUGFILE_HEADER_
#define MAX_COUNTERS 10
void dbugfile_init();
void dbugfile_deinit();
void dbugfile_sprintf(int line, char *file, const char *format, ...);
void dbugfile_print_matrix_3x3(int line, char *file, float *matrix, char *text);
void dbugfile_print_matrix_4x4(int line, char *file, float *matrix, char *text);
void dbugfile_print_counter(int line, char *file, int counter_num, char *string);
#ifdef DBUGFILE_ACTIVE
#define DBUGFILE_INIT() dbugfile_init();
#define DBUGFILE_DEINIT() dbugfile_deinit();
#define DBUGFILE_OUTPUT_0(t) dbugfile_sprintf(__LINE__, __FILE__, t);
#define DBUGFILE_OUTPUT_1(t,a) dbugfile_sprintf(__LINE__, __FILE__, t,a);
#define DBUGFILE_OUTPUT_2(t,a,b) dbugfile_sprintf(__LINE__, __FILE__, t,a,b);
#define DBUGFILE_OUTPUT_3(t,a,b,c) dbugfile_sprintf(__LINE__, __FILE__, t,a,b,c);
#define DBUGFILE_OUTPUT_4(t,a,b,c,d) dbugfile_sprintf(__LINE__, __FILE__, t,a,b,c,d);
#define DBUGFILE_OUTPUT_5(t,a,b,c,d,e) dbugfile_sprintf(__LINE__, __FILE__, t,a,b,c,d,e);
#define DBUGFILE_OUTPUT_6(t,a,b,c,d,e,f) dbugfile_sprintf(__LINE__, __FILE__, t,a,b,c,d,e,f);
#define DBUGFILE_OUTPUT_7(t,a,b,c,d,e,f,g) dbugfile_sprintf(__LINE__, __FILE__, t,a,b,c,d,e,f,g);
#define DBUGFILE_OUTPUT_8(t,a,b,c,d,e,f,g,h) dbugfile_sprintf(__LINE__, __FILE__, t,a,b,c,d,e,f,g,h);
#define DBUGFILE_OUTPUT_9(t,a,b,c,d,e,f,g,h,i) dbugfile_sprintf(__LINE__, __FILE__, t,a,b,c,d,e,f,g,h,i);
#define DBUGFILE_OUTPUT_MATRIX_3X3(m,t) dbugfile_print_matrix_3x3(__LINE__, __FILE__, m,t);
#define DBUGFILE_OUTPUT_MATRIX_4X4(m,t) dbugfile_print_matrix_4x4(__LINE__, __FILE__, m,t);
extern int dbugfile_counters[MAX_COUNTERS];
#define DBUGFILE_INC_COUNTER(n) if(n < MAX_COUNTERS) dbugfile_counters[n]++;
#define DBUGFILE_DEC_COUNTER(n) if(n < MAX_COUNTERS) dbugfile_counters[n]--;
#define DBUGFILE_OUTPUT_COUNTER(n,s) dbugfile_print_counter(__LINE__, __FILE__, n, s);
#else
#define DBUGFILE_INIT() ;
#define DBUGFILE_DEINIT() ;
#define DBUGFILE_OUTPUT_0(t) ;
#define DBUGFILE_OUTPUT_1(t,a) ;
#define DBUGFILE_OUTPUT_2(t,a,b) ;
#define DBUGFILE_OUTPUT_3(t,a,b,c) ;
#define DBUGFILE_OUTPUT_4(t,a,b,c,d) ;
#define DBUGFILE_OUTPUT_5(t,a,b,c,d,e) ;
#define DBUGFILE_OUTPUT_6(t,a,b,c,d,e,f) ;
#define DBUGFILE_OUTPUT_7(t,a,b,c,d,e,f,g) ;
#define DBUGFILE_OUTPUT_8(t,a,b,c,d,e,f,g,h) ;
#define DBUGFILE_OUTPUT_9(t,a,b,c,d,e,f,g,h,i) ;
#define DBUGFILE_OUTPUT_MATRIX_3X3(m,t) ;
#define DBUGFILE_OUTPUT_MATRIX_4X4(m,t) ;
#define DBUGFILE_INC_COUNTER(n) ;
#define DBUGFILE_DEC_COUNTER(n) ;
#define DBUGFILE_OUTPUT_COUNTER(n,s) ;
#endif
#endif
+5 -5
View File
@@ -109,10 +109,10 @@ const float WIDTHF = ((float) WIDTH) * 1.01f;
/**
* Internal conversion function to convert draw data into bars for the screen
*
* @param int colour - colour index (>=0)
* @param int xpos - x position to start bar on
* @param int xwidth - width of bar
* @param int yrow - Index of row bar belongs to
* @param colour Colour index (>=0)
* @param xpos X position to start bar on
* @param xwidth Width of bar
* @param yrow Index of row bar belongs to
*/
void timerbar_conv_and_draw(int colour, int xpos, int xwidth, int yrow)
{
@@ -212,7 +212,7 @@ void timerbar_switch_type(int num)
}
/**
* @param void (*new_draw_func_ptr)(int colour, float x, float y, float w, float h) - pointer to draw function
* @param (*new_draw_func_ptr)(int colour, float x, float y, float w, float h) Pointer to draw function
*
* Sets the draw function used to output the timer data, designed to be generic allowing any API
* to take advantage of this module. Set to NULL to disable drawing.
-8
View File
@@ -26,13 +26,5 @@ void timerbar_pop();
// This function shouldnt not be used any more or it will break push and pop calls
void timerbar_switch_type(int num);
#define TIMERBAR_SET_DRAW_FUNC(f) if (Cmdline_timerbar) timerbar_set_draw_func(f);
#define TIMERBAR_START_FRAME() if (Cmdline_timerbar) timerbar_start_frame();
#define TIMERBAR_END_FRAME() if (Cmdline_timerbar) timerbar_end_frame();
#define TIMERBAR_SWITCH_TYPE(n) if (Cmdline_timerbar) timerbar_switch_type(n);
#define TIMERBAR_PUSH(v) if (Cmdline_timerbar) timerbar_push(v);
#define TIMERBAR_POP() if (Cmdline_timerbar) timerbar_pop();
#endif
File diff suppressed because it is too large. Load diff
-129
View File
@@ -1,129 +0,0 @@
//header file for making decals-Bobboau
#ifndef _DECAL_H
#define _DECAL_H
#include "object/object.h"
#include "globalincs/pstypes.h"
//#include "ship/ship.h"
#ifdef ENABLE_DECALS
#define MAX_DECAL_POLY 40
#define MAX_DECAL_POLY_POINT 10
#define MAX_DECAL_DEFPOINTS 10000
#define MAX_DECAL_POINT 10
#define MAX_SHIP_DECALS 25
#define MAX_GLOBAL_DECAL_POLYS 11000
#define QUICKFIND_SUBDIVISION 100
#define QUICKFIND_SEGMENT_LENGTH (MAX_GLOBAL_DECAL_POLYS/QUICKFIND_SUBDIVISION)
#define MAX_GLOBAL_DECALS 5000
#define DP_EOF 0
#define DP_DEFPOINTS 1
#define DP_FLATPOLY 2
#define DP_TMAPPOLY 3
#define DP_SORTNORM 4
#define DP_BOUNDBOX 5
#endif // ENABLE_DECALS
struct decal;
struct decal_list;
struct decal_list_controle;
struct decal_poly{
vec3d norm[3];
vertex point[3];
decal_poly *next;
decal* parent;
int idx;
};
struct decal{
int n_poly;
int timestamp; //when this decal was created
int burn_time; //how long it takes for the glow texture to fade
int vertex_buffer_start; //were is the start of this decal's polys in the vertex buffer
decal_poly* poly;
decal_poly* add_poly();
decal_poly* get_last_poly();
void remove_last_poly();
decal_list_controle *parent;
};
struct decal_list{
decal dec;
decal_list *next;
};
struct decal_item{
decal_list dec;
bool used;
};
struct decal_list_controle{
int n_decals;
int buffer;
int texture;
int n_poly;
int burn_texture;
int glow_texture;
bool modifyed;
decal_list *d_list;
decal_list *end;
decal_list *add_new();
void trim();
void clear();
~decal_list_controle();
decal_list_controle();
};
struct decal_system{
decal_list_controle *decals;
int n_decal_textures;
bool decals_modified;
int max_decals;
decal_system():decals(NULL),n_decal_textures(0),decals_modified(false){};
};
//this is used to give all the data to the generation data to the functions that make them
struct decal_point{
vec3d pnt;
matrix orient;
float radius;
};
#ifdef ENABLE_DECALS
int decal_create(object * obj, decal_point *point, int subobject, int texture, int backfaced_texture = -1, int glow_texture = -1, int burn_texture = -1, int burn_time = 1000);//makes the decal
int decal_create_simple(object * obj, decal_point *point, int texture);//makes a simple non-clipped decal
void decal_render_all(object * obj); //renders all decals
int decal_create_sub(void *model_ptr);
void clear_decals(decal_system *system);
void init_decals();
#else // ENABLE_DECALS
inline int decal_create(object * obj, decal_point *point, int subobject, int texture, int backfaced_texture = -1, int glow_texture = -1, int burn_texture = -1, int burn_time = 1000)
{
return 0;
}
#define decal_create_simple(a, b, c) (0)
#define decal_render_all(a)
#define decal_create_sub(a) (0);
#define clear_decals(a)
#define init_decals()
#endif // ENABLE_DECALS
#endif // _DECAL_H
-974
View File
@@ -1,974 +0,0 @@
/*
* Copyright (C) Volition, Inc. 1999. All rights reserved.
*
* All source code herein is the property of Volition, Inc. You may not sell
* or otherwise commercially exploit the source or things you created based on the
* source.
*
*/
#include "demo/demo.h"
#include "ship/ship.h"
#include "weapon/weapon.h"
#include "globalincs/linklist.h"
#include "freespace2/freespace.h"
#include "object/object.h"
#include "io/timer.h"
#include "gamesequence/gamesequence.h"
#include "mission/missionmessage.h"
#include "mission/missionparse.h"
#include "ship/shipfx.h"
#include "ship/shiphit.h"
#include "cfile/cfile.h"
// -----------------------------------------------------------------------------------------------------------------------------
// DEMO DEFINES/VARS
//
CFILE *Demo_file = NULL;
// how often we dump
#define DEMO_DEFAULT_FPS 15
int Demo_fps = 1000 / DEMO_DEFAULT_FPS;
// timestamp for frame dumping
int Demo_stamp = -1;
// missiontime
float Demo_missiontime = 0.0f;
// buffer for reading and writing demo stuff
#define DEMO_BUF_SIZE 32768
char *Demo_buf = NULL;
int Demo_buf_pos = 0;
// # of events posted for this frame
int Demo_frame_events = 0;
// current offset into the demo file - only used for playback
int Demo_cur_offset = -1;
// demo version #
#define DEMO_VERSION 2
// an error reading or writing the demo file
int Demo_error = DEMO_ERROR_NONE;
// all strings read out of the demo file must be no longer than this
#define DEMO_STRING_LEN 255
// macros
#define DEMO_DATA_FRAME() do { \
if(Demo_file == NULL){\
Int3();\
DEMO_ERROR(DEMO_ERROR_GENERAL);\
break;\
}\
if(Game_mode & GM_DEMO_RECORD){\
if(Demo_buf_pos == 0) {\
Int3();\
break;\
}\
if(Demo_frame_events <= 0){\
break;\
}\
if(!cfwrite_ushort((ushort)Demo_buf_pos, Demo_file)){\
DEMO_ERROR(DEMO_ERROR_DISK_SPACE);\
break;\
}\
if(!cfwrite(Demo_buf, Demo_buf_pos, 1, Demo_file)){\
DEMO_ERROR(DEMO_ERROR_DISK_SPACE);\
break;\
}\
} else if(Game_mode & GM_DEMO_PLAYBACK){\
Demo_buf_pos = (int)cfread_ushort(Demo_file);\
if(!cfread(Demo_buf, Demo_buf_pos, 1, Demo_file)){\
DEMO_ERROR(DEMO_ERROR_DISK_ACCESS);\
break;\
}\
}\
} while(0)
#define DEMO_DATA(vl, vl_size) do { if(Demo_buf == NULL){ DEMO_ERROR(DEMO_ERROR_GENERAL); break; } if((Demo_buf_pos + vl_size) >= DEMO_BUF_SIZE){ Int3(); DEMO_ERROR(DEMO_ERROR_FRAMESIZE); break; } if(Game_mode & GM_DEMO_RECORD){ memcpy(Demo_buf + Demo_buf_pos, &vl, vl_size); } else if(Game_mode & GM_DEMO_PLAYBACK){ memcpy(&vl, Demo_buf + Demo_buf_pos, vl_size); } Demo_buf_pos += vl_size; } while(0)
#define DEMO_INT(vl) do { DEMO_DATA(vl, sizeof(int)); } while(0)
#define DEMO_UINT(vl) do { DEMO_DATA(vl, sizeof(uint)); } while(0)
#define DEMO_SHORT(vl) do { DEMO_DATA(vl, sizeof(short)); } while(0)
#define DEMO_USHORT(vl) do { DEMO_DATA(vl, sizeof(ushort)); } while(0)
#define DEMO_BYTE(vl) do { DEMO_DATA(vl, sizeof(char)); } while(0)
#define DEMO_UBYTE(vl) do { DEMO_DATA(vl, sizeof(ubyte)); } while(0)
#define DEMO_FLOAT(vl) do { DEMO_DATA(vl, sizeof(float)); } while(0)
#define DEMO_VECTOR(vl) do { DEMO_DATA(vl, sizeof(vec3d)); } while(0)
#define DEMO_MATRIX(vl) do { DEMO_DATA(vl, sizeof(matrix)); } while(0)
#define DEMO_STRING(vl) do { int stlen; if(Game_mode & GM_DEMO_RECORD){ stlen = strlen(vl); if(stlen <= 0){ break; } DEMO_DATA(stlen, sizeof(ushort)); DEMO_DATA(*vl, strlen(vl)); } else { ushort len = 0; DEMO_USHORT(len); DEMO_DATA(*vl, len); vl[len] = '\0'; } } while(0)
// demo events types
#define DE_DUMP 1 // standard object dump
#define DE_TRAILER 2 // end of demo trailer
#define DE_PRIMARY 3 // primary weapon fired
#define DE_UNIQUE_MESSAGE 4 // unique hud message
#define DE_BUILTIN_MESSAGE 5 // builtin hud message
#define DE_OBJ_CREATE 6 // object create message
#define DE_OBJ_WARPIN 7 // ship warpin
#define DE_OBJ_WARPOUT 8 // ship warpout
#define DE_OBJ_DEPARTED 9 // ship departed
#define DE_SHIP_KILL 10 // ship kill
// call this when posting an error
#define DEMO_ERROR(er) do { Demo_error = er; Int3(); } while(0)
int Demo_make = 0;
DCF(demo, "")
{
Demo_make = !Demo_make;
if(Demo_make){
dc_printf("Demo will be recorded\n");
} else {
dc_printf("Demo will NOT be recorded\n");
}
}
// -----------------------------------------------------------------------------------------------------------------------------
// DEMO FORWARD DECLARATIONS
//
// write demo header
int demo_write_header();
// read the demo header
int demo_read_header();
// write the demo trailer
void demo_write_trailer();
// do a recording frame
void demo_do_recording_frame_start();
// do a recording frame
void demo_do_recording_frame_end();
// do a playback frame
void demo_do_playback_frame();
// seek through the demo file to the proper location
// return 0 on error, 1 on success/continue, 2 if the demo is done
int demo_playback_seek();
// scan through a read in frame of data and apply everything necessary. returns true if the trailer (end of demo) was found
int demo_playback_seek_sub(int frame_size);
// -----------------------------------------------------------------------------------------------------------------------------
// DEMO FUNCTIONS
//
// do frame for the demo - playback and recording, returns 0 if errors were encountered during frame processing
int demo_do_frame_start()
{
#ifndef DEMO_SYSTEM
return 1;
#else
// if we're not doing any demo stuff
if(!(Game_mode & GM_DEMO)){
return 1;
}
// bad
if(Demo_file == NULL){
DEMO_ERROR(DEMO_ERROR_DISK_ACCESS);
return 0;
}
// make sure we're not trying to record and playback at the same time
Assert( ((Game_mode & GM_DEMO_RECORD) && !(Game_mode & GM_DEMO_PLAYBACK)) || (!(Game_mode & GM_DEMO_RECORD) && (Game_mode & GM_DEMO_PLAYBACK)) );
// recording
if(Game_mode & GM_DEMO_RECORD){
demo_do_recording_frame_start();
} else {
demo_do_playback_frame();
}
// bad bad bad, get mwa
if(Demo_error){
return 0;
}
// continue
return 1;
#endif
}
// do frame for the demo - playback and recording, returns 0 if errors were encountered during frame processing
int demo_do_frame_end()
{
#ifndef DEMO_SYSTEM
return 1;
#else
// if we're not doing any demo stuff
if(!(Game_mode & GM_DEMO)){
return 1;
}
// bad
if(Demo_file == NULL){
DEMO_ERROR(DEMO_ERROR_DISK_ACCESS);
return 0;
}
// make sure we're not trying to record and playback at the same time
Assert( ((Game_mode & GM_DEMO_RECORD) && !(Game_mode & GM_DEMO_PLAYBACK)) || (!(Game_mode & GM_DEMO_RECORD) && (Game_mode & GM_DEMO_PLAYBACK)) );
// recording. there's nothing to do here for playback
if(Game_mode & GM_DEMO_RECORD){
demo_do_recording_frame_end();
}
// bad bad bad, get mwa
if(Demo_error){
return 0;
}
// continue
return 1;
#endif
}
// initialize a demo for recording
// NOTE : call this after loading the mission and going through the briefing, but _before_ physically moving into the mission
int demo_start_record(char *file)
{
#ifndef DEMO_SYSTEM
return 0;
#else
char full_name[MAX_FILENAME_LEN] = "";
// try and allocate the buffer
Demo_buf = (char*)vm_malloc(DEMO_BUF_SIZE);
if(Demo_buf == NULL){
DEMO_ERROR(DEMO_ERROR_DISK_ACCESS);
return 0;
}
// open the outfile
strcpy_s(full_name, file);
cf_add_ext(full_name, ".fsd");
Demo_file = cfopen(full_name, "wb", CFILE_NORMAL, CF_TYPE_DEMOS);
if(Demo_file == NULL){
Int3();
Demo_error = DEMO_ERROR_DISK_ACCESS;
return 0;
}
// no errors
Demo_error = DEMO_ERROR_NONE;
// write the header
if(!demo_write_header()){
return 0;
}
// flag demo mode
Game_mode |= GM_DEMO_RECORD;
// no events yet
Demo_frame_events = 0;
// success
return 1;
#endif
}
// initialize a demo for playback - calling this will load up the demo file and move the player into the playback state
int demo_start_playback(char *file)
{
#ifndef DEMO_SYSTEM
return 0;
#else
char full_name[MAX_FILENAME_LEN] = "";
// try and allocate the buffer
Demo_buf = (char*)vm_malloc(DEMO_BUF_SIZE);
if(Demo_buf == NULL){
DEMO_ERROR(DEMO_ERROR_DISK_ACCESS);
return 0;
}
// open the outfile
strcpy_s(full_name, file);
cf_add_ext(full_name, ".fsd");
Demo_file = cfopen(full_name, "rb", CFILE_NORMAL, CF_TYPE_DEMOS);
if(Demo_file == NULL){
DEMO_ERROR(DEMO_ERROR_DISK_ACCESS);
return 0;
}
// no errors
Demo_error = DEMO_ERROR_NONE;
// read the header
Demo_cur_offset = -1;
if(!demo_read_header()){
return 0;
}
// flag demo mode
Game_mode |= GM_DEMO_PLAYBACK;
// everything is cool, so jump into the mission
gameseq_post_event(GS_EVENT_ENTER_GAME);
return 1;
#endif
}
// finish the demo
void demo_close()
{
#ifdef DEMO_SYSTEM
// if we're recording, write the trailer
if(Game_mode & GM_DEMO_RECORD){
demo_write_trailer();
}
// close the demo file
if(Demo_file != NULL){
cfclose(Demo_file);
Demo_file = NULL;
}
// free the buffer
if(Demo_buf != NULL){
vm_free(Demo_buf);
Demo_buf = NULL;
}
// if we're playing back, go back to the main hall
if(Game_mode & GM_DEMO_PLAYBACK){
gameseq_post_event(GS_EVENT_MAIN_MENU);
}
// unflag demo mode
Game_mode &= ~(GM_DEMO_RECORD | GM_DEMO_PLAYBACK);
#endif
}
// if we should run the simulation for this object, or let the demo system handle it
int demo_should_sim(object *objp)
{
#ifndef DEMO_SYSTEM
return 1;
#else
// always sim stuff in non-demo mode
if(!(Game_mode & GM_DEMO)){
return 1;
}
// don't sim ships or missiles
if((objp->type == OBJ_SHIP) || ((objp->type == OBJ_WEAPON) && (objp->instance >= 0) && (Weapon_info[Weapons[objp->instance].weapon_info_index].subtype == WP_MISSILE))){
return 0;
}
// sim everything else
return 1;
#endif
}
// -----------------------------------------------------------------------------------------------------------------------------
// DEMO RECORDING FUNCTIONS
//
// write demo header
int demo_write_header()
{
uint chksum;
char *full_name;
// write demo version #
if(!cfwrite_int(DEMO_VERSION, Demo_file)){
DEMO_ERROR(DEMO_ERROR_DISK_ACCESS);
return 0;
}
// write mission filename
if(!cfwrite_string_len(Game_current_mission_filename, Demo_file)){
DEMO_ERROR(DEMO_ERROR_DISK_ACCESS);
return 0;
}
// write mission checksum
full_name = cf_add_ext(Game_current_mission_filename, FS_MISSION_FILE_EXT);
cf_chksum_long(full_name, &chksum);
if(!cfwrite_int(chksum, Demo_file)){
DEMO_ERROR(DEMO_ERROR_DISK_ACCESS);
return 0;
}
// success
return 1;
}
// write the demo trailer
void demo_write_trailer()
{
// start a new chunk
demo_do_recording_frame_start();
// trailer event
ubyte frame_type = DE_TRAILER;
DEMO_UBYTE(frame_type);
// 1 event
Demo_frame_events++;
// write frame data to disk
DEMO_DATA_FRAME();
}
// start recording frame
void demo_do_recording_frame_start()
{
// if we're not physically doing the mission
if(gameseq_get_state() != GS_STATE_GAME_PLAY){
return;
}
// add in frametime
Demo_missiontime += flFrametime;
// clear the buffer, set no events, and write the header
Demo_buf_pos = 0;
Demo_frame_events = 0;
// missiontime
float fl_time = f2fl(Missiontime);
DEMO_FLOAT(fl_time);
}
// end recording frame
void demo_do_recording_frame_end()
{
// if we're not physically doing the mission
if(gameseq_get_state() != GS_STATE_GAME_PLAY){
return;
}
// if its time to dump objects (the last thing we might dump per frame)
if((Demo_stamp == -1) || timestamp_elapsed(Demo_stamp)){
// post an object dump event
demo_POST_object_dump();
// reset the stamp
Demo_stamp = timestamp(Demo_fps);
}
// write all accumulated frame data to disk if necessary
DEMO_DATA_FRAME();
}
// post an object dump event
void demo_POST_object_dump()
{
ship_obj *sobjp;
object *objp;
ushort obj_count;
ubyte team;
// object dump event
ubyte event_type = DE_DUMP;
DEMO_UBYTE(event_type);
// go through the ship list and count
obj_count = 0;
for ( sobjp = GET_FIRST(&Ship_obj_list); sobjp !=END_OF_LIST(&Ship_obj_list); sobjp = GET_NEXT(sobjp) ){
// object pointer
if(sobjp->objnum < 0){
continue;
}
obj_count++;
}
// write out the object count
DEMO_USHORT(obj_count);
// go through the ship list and dump necessary stuff
for ( sobjp = GET_FIRST(&Ship_obj_list); sobjp !=END_OF_LIST(&Ship_obj_list); sobjp = GET_NEXT(sobjp) ){
// object pointer
if(sobjp->objnum < 0){
continue;
}
objp = &Objects[sobjp->objnum];
// just ships for now
DEMO_INT(objp->signature);
DEMO_VECTOR(objp->pos);
DEMO_MATRIX(objp->orient);
DEMO_FLOAT(objp->phys_info.forward_thrust);
team = (ubyte)Ships[objp->instance].team;
DEMO_UBYTE(team);
DEMO_INT(Ships[objp->instance].flags);
}
// up the event count
Demo_frame_events++;
}
// post a primary fired event
void demo_POST_primary_fired(object *objp, int banks, int linked)
{
ubyte fire_info = 0;
// object dump event
ubyte event_type = DE_PRIMARY;
DEMO_UBYTE(event_type);
// object signature
DEMO_INT(objp->signature);
// get fire info
fire_info = (ubyte)banks;
fire_info &= ~(1<<7);
if(linked){
fire_info |= (1<<7);
}
DEMO_UBYTE(fire_info);
// up the event count
Demo_frame_events++;
}
// post a unique message
void demo_POST_unique_message(char *id, char *who_from, int m_source, int priority)
{
// sanity
if((id == NULL) || (who_from == NULL) || (strlen(id) <= 0) || (strlen(who_from) <= 0)){
return;
}
// write it
ubyte event = DE_UNIQUE_MESSAGE;
DEMO_UBYTE(event);
DEMO_STRING(id);
DEMO_STRING(who_from);
DEMO_INT(m_source);
DEMO_INT(priority);
// up the event count
Demo_frame_events++;
}
// post a builtin message
void demo_POST_builtin_message(int type, ship *shipp, int priority, int timing)
{
int sig = 0;
// write it
ubyte event = DE_BUILTIN_MESSAGE;
DEMO_UBYTE(event);
DEMO_INT(type);
if(shipp == NULL){
sig = -1;
} else if(shipp->objnum >= 0){
sig = Objects[shipp->objnum].signature;
}
DEMO_INT(sig);
DEMO_INT(priority);
DEMO_INT(timing);
// up the event count
Demo_frame_events++;
}
// post an object create message
void demo_POST_obj_create(char *pobj_name, int signature)
{
// write it
ubyte event = DE_OBJ_CREATE;
DEMO_UBYTE(event);
DEMO_STRING(pobj_name);
DEMO_INT(signature);
// up the event count
Demo_frame_events++;
}
// post a warpin event
void demo_POST_warpin(int signature, int ship_flags)
{
// write it
ubyte event = DE_OBJ_WARPIN;
DEMO_UBYTE(event);
DEMO_INT(signature);
DEMO_INT(ship_flags);
// up the event count
Demo_frame_events++;
}
// post a warpout event
void demo_POST_warpout(int signature, int ship_flags)
{
// write it
ubyte event = DE_OBJ_WARPOUT;
DEMO_UBYTE(event);
DEMO_INT(signature);
DEMO_INT(ship_flags);
// up the event count
Demo_frame_events++;
}
// post a departed event
void demo_POST_departed(int signature, int ship_flags)
{
// write it
ubyte event = DE_OBJ_DEPARTED;
DEMO_UBYTE(event);
DEMO_INT(signature);
DEMO_INT(ship_flags);
// up the event count
Demo_frame_events++;
}
// post a ship kill event
void demo_POST_ship_kill(object *objp)
{
// write it
ubyte event = DE_SHIP_KILL;
DEMO_UBYTE(event);
DEMO_INT(objp->signature);
// up the event count
Demo_frame_events++;
}
// -----------------------------------------------------------------------------------------------------------------------------
// DEMO PLAYBACK FUNCTIONS
//
// read the demo header
int demo_read_header()
{
int version;
uint file_checksum, my_checksum;
char *full_name;
// read the version #
version = cfread_int(Demo_file);
if(version != DEMO_VERSION){
DEMO_ERROR(DEMO_ERROR_VERSION);
return 0;
}
// read mission filename
cfread_string_len(Game_current_mission_filename, MAX_FILENAME_LEN, Demo_file);
// get mission checksum
file_checksum = cfread_int(Demo_file);
full_name = cf_add_ext(Game_current_mission_filename, FS_MISSION_FILE_EXT);
if(!cf_chksum_long(full_name, &my_checksum)){
DEMO_ERROR(DEMO_ERROR_DISK_ACCESS);
return 0;
}
if(file_checksum != my_checksum){
DEMO_ERROR(DEMO_ERROR_MISSION);
return 0;
}
// get the file offset of this first frame
Demo_cur_offset = cftell(Demo_file);
// success
return 1;
}
// do a playback frame
void demo_do_playback_frame()
{
// seek to the best location in the demo file
switch(demo_playback_seek()){
// error
case 0:
return;
// continue
case 1:
break;
// found the trailer - this demo is done
case 2:
demo_close();
break;
}
}
// seek through the demo file to the proper location
// return 0 on error, 1 on success/continue, 2 if the demo is done
int demo_playback_seek()
{
float this_time = 0.0f;
int frame_size;
int this_offset;
int ret = 0;
// scan until we find something useful
while(1){
// record the beginning of this chunk
this_offset = cftell(Demo_file);
// read in the data for the next frame
DEMO_DATA_FRAME();
frame_size = Demo_buf_pos;
Demo_buf_pos = 0;
// check the time
DEMO_FLOAT(this_time);
// ahead of us
if(this_time > f2fl(Missiontime)){
// success
ret = 1;
// seek back to the beginning of this chunk
Demo_cur_offset = this_offset;
// bust out
break;
}
// we should scan through this chunk
else {
// returns true if it finds the demo trailer
if(demo_playback_seek_sub(frame_size)){
return 2;
}
}
}
// seek back to the new frame
cfseek(Demo_file, Demo_cur_offset, CF_SEEK_SET);
// return
return ret;
}
// scan through a read in frame of data and apply everything necessary. returns true if the trailer (end of demo) was found
int demo_playback_seek_sub(int frame_size)
{
ubyte event = 0;
int idx;
// apply everything
while(Demo_buf_pos < frame_size){
// next event
DEMO_UBYTE(event);
// process it
switch(event){
// oops, trailer. we're done
case DE_TRAILER:
return 1;
// object dump
case DE_DUMP: {
ushort obj_count = 0;
int obj_sig = 0;
ubyte team = 0;
vec3d obj_pos = vmd_zero_vector;
matrix obj_orient = vmd_identity_matrix;
float obj_fthrust = 0;
int ship_index = 0;
int ship_flags = 0;
// get the object count
DEMO_USHORT(obj_count);
// read in all the objects
for(idx=0; idx<obj_count; idx++){
DEMO_INT(obj_sig);
DEMO_VECTOR(obj_pos);
DEMO_MATRIX(obj_orient);
DEMO_FLOAT(obj_fthrust);
DEMO_UBYTE(team);
DEMO_INT(ship_flags);
// find our ship object
ship_index = ship_get_by_signature(obj_sig);
// Assert(ship_index >= 0);
if(ship_index >= 0){
Objects[Ships[ship_index].objnum].pos = obj_pos;
Objects[Ships[ship_index].objnum].orient = obj_orient;
Objects[Ships[ship_index].objnum].phys_info.forward_thrust = obj_fthrust;
Ships[ship_index].team = team;
Ships[ship_index].flags = ship_flags;
}
}
}
break;
// primary fired
case DE_PRIMARY: {
int obj_sig = 0 ;
ubyte fire_info = 0;
int ship_index = -1;
// get the data and ship
DEMO_INT(obj_sig);
DEMO_UBYTE(fire_info);
ship_index = ship_get_by_signature(obj_sig);
if(ship_index >= 0){
Ships[ship_index].weapons.current_primary_bank = (int)(fire_info & ~(1<<7));
if(fire_info & (1<<7)){
Ships[ship_index].flags |= SF_PRIMARY_LINKED;
} else {
Ships[ship_index].flags &= ~(SF_PRIMARY_LINKED);
}
// fire
ship_fire_primary(&Objects[Ships[ship_index].objnum], 0, 1);
}
}
break;
// unique message
case DE_UNIQUE_MESSAGE: {
char id[255] = "";
char who_from[255] = "";
int m_source = 0;
int priority = 0;
// read the stuff in
DEMO_STRING(id);
DEMO_STRING(who_from);
DEMO_INT(m_source);
DEMO_INT(priority);
// send the message
message_send_unique_to_player(id, who_from, m_source, priority, 0, 0);
}
break;
// builtin message
case DE_BUILTIN_MESSAGE:{
int type = 0;
int sig = 0;
int ship_index = 0;
int priority = 0;
int timing = 0;
// get data and ship
DEMO_INT(type);
DEMO_INT(sig);
DEMO_INT(priority);
DEMO_INT(timing);
if(sig == -1){
// message_send_builtin_to_player(type, NULL, priority, timing, 0, 0);
} else {
ship_index = ship_get_by_signature(sig);
if(ship_index >= 0){
// message_send_builtin_to_player(type, &Ships[ship_index], priority, timing, 0, 0);
}
}
}
break;
// obj create
case DE_OBJ_CREATE:{
char pobj_name[255] = "";
int obj_sig = 0;
int objnum = 0;
p_object *objp = NULL;
// try and create the ship
DEMO_STRING(pobj_name);
DEMO_INT(obj_sig);
objp = mission_parse_get_arrival_ship( pobj_name );
if(objp != NULL){
objnum = parse_create_object(objp);
if(objnum >= 0){
Objects[objnum].signature = obj_sig;
}
}
}
break;
// warpin effect
case DE_OBJ_WARPIN:{
int obj_sig = 0;
int ship_flags = 0;
int ship_index = 0;
// get the data and ship
DEMO_INT(obj_sig);
DEMO_INT(ship_flags);
ship_index = ship_get_by_signature(obj_sig);
if(ship_index >= 0){
Ships[ship_index].flags = ship_flags;
shipfx_warpin_start(&Objects[Ships[ship_index].objnum]);
}
}
break;
// warpout effect
case DE_OBJ_WARPOUT:{
int obj_sig = 0;
int ship_flags = 0;
int ship_index = 0;
// get the data and ship
DEMO_INT(obj_sig);
DEMO_INT(ship_flags);
ship_index = ship_get_by_signature(obj_sig);
if(ship_index >= 0){
Ships[ship_index].flags = ship_flags;
shipfx_warpout_start(&Objects[Ships[ship_index].objnum]);
}
}
break;
// departed
case DE_OBJ_DEPARTED:{
int obj_sig = 0;
int ship_flags = 0;
int ship_index = 0;
// get the data and ship
DEMO_INT(obj_sig);
DEMO_INT(ship_flags);
ship_index = ship_get_by_signature(obj_sig);
if(ship_index >= 0){
Ships[ship_index].flags = ship_flags;
ship_actually_depart(ship_index);
}
}
break;
// ship kill
case DE_SHIP_KILL:{
int obj_sig = 0;
int ship_index = 0;
// get the data and ship
DEMO_INT(obj_sig);
ship_index = ship_get_by_signature(obj_sig);
if(ship_index >= 0){
Objects[Ships[ship_index].objnum].hull_strength = 0.0f;
ship_generic_kill_stuff(&Objects[Ships[ship_index].objnum], 1.0f);
}
}
break;
default:
Int3();
return 0;
}
}
return 0;
}
-91
View File
@@ -1,91 +0,0 @@
/*
* Copyright (C) Volition, Inc. 1999. All rights reserved.
*
* All source code herein is the property of Volition, Inc. You may not sell
* or otherwise commercially exploit the source or things you created based on the
* source.
*
*/
#ifndef _FS2_DEMO_SYSTEM_HEADER_FILE
#define _FS2_DEMO_SYSTEM_HEADER_FILE
// -----------------------------------------------------------------------------------------------------------------------------
// DEMO DEFINES/VARS
//
// compile in the demo system
#define DEMO_SYSTEM
struct object;
struct ship;
// an error reading or writing the demo file
#define DEMO_ERROR_NONE 0 // no error
#define DEMO_ERROR_GENERAL 1 // general problem
#define DEMO_ERROR_FRAMESIZE 2 // frame size was too big (> 32k)
#define DEMO_ERROR_DISK_SPACE 3 // out of disk space
#define DEMO_ERROR_DISK_ACCESS 4 // problem accessing disk
#define DEMO_ERROR_VERSION 5 // bad version #
#define DEMO_ERROR_MISSION 6 // different mission file checksums
extern int Demo_error;
extern int Demo_make;
// -----------------------------------------------------------------------------------------------------------------------------
// DEMO FUNCTIONS
//
// do frame for the demo - start for the frame
int demo_do_frame_start();
// do frame for the demo - end for the frame
int demo_do_frame_end();
// initialize a demo for recording
// NOTE : call this after loading the mission and going through the briefing, but _before_ physically moving into the mission
int demo_start_record(char *file);
// initialize a demo for playback - calling this will load up the demo file and move the player into the playback state
int demo_start_playback(char *file);
// finish the demo, whether recording or playing back
void demo_close();
// if we should run the simulation for this object, or let the demo system handle it
int demo_should_sim(object *objp);
// functions for posting critical events to the demo system ------------------------------------------------------------
// post an object dump event (only used internally)
void demo_POST_object_dump();
// post a primary fired event
void demo_POST_primary_fired(object *objp, int banks, int linked);
// post a unique message
void demo_POST_unique_message(char *id, char *who_from, int m_source, int priority);
// post a builtin message
void demo_POST_builtin_message(int type, ship *shipp, int priority, int timing);
// post an object create message
void demo_POST_obj_create(char *pobj_name, int signature);
// post a warpin event
void demo_POST_warpin(int signature, int ship_flags);
// post a warpout event
void demo_POST_warpout(int signature, int ship_flags);
// post a departed event
void demo_POST_departed(int signature, int ship_flags);
// post a ship kill event
void demo_POST_ship_kill(object *objp);
#endif
-864
View File
@@ -1,864 +0,0 @@
/*==========================================================================;
*
* Copyright (C) 1995,1996 Microsoft Corporation. All Rights Reserved.
*
* File: dsound.h
* Content: DirectSound include file
*
**************************************************************************/
#ifndef __DSOUND_INCLUDED__
#define __DSOUND_INCLUDED__
#include "directx/vd3dtypes.h"
#define COM_NO_WINDOWS_H
#include <objbase.h>
#define _FACDS 0x878
#define MAKE_DSHRESULT(code) MAKE_HRESULT(1, _FACDS, code)
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
// Direct Sound Component GUID {47D4D946-62E8-11cf-93BC-444553540000}
DEFINE_GUID(CLSID_DirectSound, 0x47d4d946, 0x62e8, 0x11cf, 0x93, 0xbc, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0);
// DirectSound Capture Component GUID {B0210780-89CD-11d0-AF08-00A0C925CD16}
DEFINE_GUID(CLSID_DirectSoundCapture, 0xb0210780, 0x89cd, 0x11d0, 0xaf, 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16);
//
// Structures
//
#ifdef __cplusplus
// 'struct' not 'class' per the way DECLARE_INTERFACE_ is defined
struct IDirectSound;
struct IDirectSoundBuffer;
struct IDirectSound3DListener;
struct IDirectSound3DBuffer;
struct IDirectSoundCapture;
struct IDirectSoundCaptureBuffer;
struct IDirectSoundNotify;
#endif // __cplusplus
typedef struct IDirectSound *LPDIRECTSOUND;
typedef struct IDirectSoundBuffer *LPDIRECTSOUNDBUFFER;
typedef struct IDirectSound3DListener *LPDIRECTSOUND3DLISTENER;
typedef struct IDirectSound3DBuffer *LPDIRECTSOUND3DBUFFER;
typedef struct IDirectSoundCapture *LPDIRECTSOUNDCAPTURE;
typedef struct IDirectSoundCaptureBuffer *LPDIRECTSOUNDCAPTUREBUFFER;
typedef struct IDirectSoundNotify *LPDIRECTSOUNDNOTIFY;
typedef struct _DSCAPS
{
DWORD dwSize;
DWORD dwFlags;
DWORD dwMinSecondarySampleRate;
DWORD dwMaxSecondarySampleRate;
DWORD dwPrimaryBuffers;
DWORD dwMaxHwMixingAllBuffers;
DWORD dwMaxHwMixingStaticBuffers;
DWORD dwMaxHwMixingStreamingBuffers;
DWORD dwFreeHwMixingAllBuffers;
DWORD dwFreeHwMixingStaticBuffers;
DWORD dwFreeHwMixingStreamingBuffers;
DWORD dwMaxHw3DAllBuffers;
DWORD dwMaxHw3DStaticBuffers;
DWORD dwMaxHw3DStreamingBuffers;
DWORD dwFreeHw3DAllBuffers;
DWORD dwFreeHw3DStaticBuffers;
DWORD dwFreeHw3DStreamingBuffers;
DWORD dwTotalHwMemBytes;
DWORD dwFreeHwMemBytes;
DWORD dwMaxContigFreeHwMemBytes;
DWORD dwUnlockTransferRateHwBuffers;
DWORD dwPlayCpuOverheadSwBuffers;
DWORD dwReserved1;
DWORD dwReserved2;
} DSCAPS, *LPDSCAPS;
typedef const DSCAPS *LPCDSCAPS;
typedef struct _DSBCAPS
{
DWORD dwSize;
DWORD dwFlags;
DWORD dwBufferBytes;
DWORD dwUnlockTransferRate;
DWORD dwPlayCpuOverhead;
} DSBCAPS, *LPDSBCAPS;
typedef const DSBCAPS *LPCDSBCAPS;
typedef struct _DSBUFFERDESC
{
DWORD dwSize;
DWORD dwFlags;
DWORD dwBufferBytes;
DWORD dwReserved;
LPWAVEFORMATEX lpwfxFormat;
} DSBUFFERDESC, *LPDSBUFFERDESC;
typedef const DSBUFFERDESC *LPCDSBUFFERDESC;
typedef struct _DS3DBUFFER
{
DWORD dwSize;
D3DVECTOR vPosition;
D3DVECTOR vVelocity;
DWORD dwInsideConeAngle;
DWORD dwOutsideConeAngle;
D3DVECTOR vConeOrientation;
LONG lConeOutsideVolume;
D3DVALUE flMinDistance;
D3DVALUE flMaxDistance;
DWORD dwMode;
} DS3DBUFFER, *LPDS3DBUFFER;
typedef const DS3DBUFFER *LPCDS3DBUFFER;
typedef struct _DS3DLISTENER
{
DWORD dwSize;
D3DVECTOR vPosition;
D3DVECTOR vVelocity;
D3DVECTOR vOrientFront;
D3DVECTOR vOrientTop;
D3DVALUE flDistanceFactor;
D3DVALUE flRolloffFactor;
D3DVALUE flDopplerFactor;
} DS3DLISTENER, *LPDS3DLISTENER;
typedef const DS3DLISTENER *LPCDS3DLISTENER;
typedef struct _DSCCAPS
{
DWORD dwSize;
DWORD dwFlags;
DWORD dwFormats;
DWORD dwChannels;
} DSCCAPS, *LPDSCCAPS;
typedef const DSCCAPS *LPCDSCCAPS;
typedef struct _DSCBUFFERDESC
{
DWORD dwSize;
DWORD dwFlags;
DWORD dwBufferBytes;
DWORD dwReserved;
LPWAVEFORMATEX lpwfxFormat;
} DSCBUFFERDESC, *LPDSCBUFFERDESC;
typedef const DSCBUFFERDESC *LPCDSCBUFFERDESC;
typedef struct _DSCBCAPS
{
DWORD dwSize;
DWORD dwFlags;
DWORD dwBufferBytes;
DWORD dwReserved;
} DSCBCAPS, *LPDSCBCAPS;
typedef const DSCBCAPS *LPCDSCBCAPS;
typedef struct _DSBPOSITIONNOTIFY
{
DWORD dwOffset;
HANDLE hEventNotify;
} DSBPOSITIONNOTIFY, *LPDSBPOSITIONNOTIFY;
typedef const DSBPOSITIONNOTIFY *LPCDSBPOSITIONNOTIFY;
//
// Compatibility typedefs
//
typedef LPDIRECTSOUND *LPLPDIRECTSOUND;
typedef LPDIRECTSOUNDBUFFER *LPLPDIRECTSOUNDBUFFER;
typedef LPDIRECTSOUND3DLISTENER *LPLPDIRECTSOUND3DLISTENER;
typedef LPDIRECTSOUND3DBUFFER *LPLPDIRECTSOUND3DBUFFER;
typedef LPDIRECTSOUNDCAPTURE *LPLPDIRECTSOUNDCAPTURE;
typedef LPDIRECTSOUNDCAPTUREBUFFER *LPLPDIRECTSOUNDCAPTUREBUFFER;
typedef LPDIRECTSOUNDNOTIFY *LPLPDIRECTSOUNDNOTIFY;
typedef LPVOID *LPLPVOID;
typedef const WAVEFORMATEX *LPCWAVEFORMATEX;
//
// DirectSound API
//
typedef BOOL (CALLBACK *LPDSENUMCALLBACKW)(LPGUID, LPCWSTR, LPCWSTR, LPVOID);
typedef BOOL (CALLBACK *LPDSENUMCALLBACKA)(LPGUID, LPCSTR, LPCSTR, LPVOID);
extern HRESULT WINAPI DirectSoundCreate(LPGUID, LPDIRECTSOUND *, LPUNKNOWN);
extern HRESULT WINAPI DirectSoundEnumerateW(LPDSENUMCALLBACKW, LPVOID);
extern HRESULT WINAPI DirectSoundEnumerateA(LPDSENUMCALLBACKA, LPVOID);
extern HRESULT WINAPI DirectSoundCaptureCreate(LPGUID, LPDIRECTSOUNDCAPTURE *, LPUNKNOWN);
extern HRESULT WINAPI DirectSoundCaptureEnumerateW(LPDSENUMCALLBACKW, LPVOID);
extern HRESULT WINAPI DirectSoundCaptureEnumerateA(LPDSENUMCALLBACKA, LPVOID);
#ifdef UNICODE
#define LPDSENUMCALLBACK LPDSENUMCALLBACKW
#define DirectSoundEnumerate DirectSoundEnumerateW
#define DirectSoundCaptureEnumerate DirectSoundCaptureEnumerateW
#else // UNICODE
#define LPDSENUMCALLBACK LPDSENUMCALLBACKA
#define DirectSoundEnumerate DirectSoundEnumerateA
#define DirectSoundCaptureEnumerate DirectSoundCaptureEnumerateA
#endif // UNICODE
//
// IDirectSound
//
DEFINE_GUID(IID_IDirectSound, 0x279AFA83, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60);
#undef INTERFACE
#define INTERFACE IDirectSound
DECLARE_INTERFACE_(IDirectSound, IUnknown)
{
// IUnknown methods
STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE;
STDMETHOD_(ULONG,AddRef) (THIS) PURE;
STDMETHOD_(ULONG,Release) (THIS) PURE;
// IDirectSound methods
STDMETHOD(CreateSoundBuffer) (THIS_ LPCDSBUFFERDESC, LPDIRECTSOUNDBUFFER *, LPUNKNOWN) PURE;
STDMETHOD(GetCaps) (THIS_ LPDSCAPS) PURE;
STDMETHOD(DuplicateSoundBuffer) (THIS_ LPDIRECTSOUNDBUFFER, LPDIRECTSOUNDBUFFER *) PURE;
STDMETHOD(SetCooperativeLevel) (THIS_ HWND, DWORD) PURE;
STDMETHOD(Compact) (THIS) PURE;
STDMETHOD(GetSpeakerConfig) (THIS_ LPDWORD) PURE;
STDMETHOD(SetSpeakerConfig) (THIS_ DWORD) PURE;
STDMETHOD(Initialize) (THIS_ LPGUID) PURE;
};
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirectSound_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDirectSound_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDirectSound_Release(p) (p)->lpVtbl->Release(p)
#define IDirectSound_CreateSoundBuffer(p,a,b,c) (p)->lpVtbl->CreateSoundBuffer(p,a,b,c)
#define IDirectSound_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a)
#define IDirectSound_DuplicateSoundBuffer(p,a,b) (p)->lpVtbl->DuplicateSoundBuffer(p,a,b)
#define IDirectSound_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b)
#define IDirectSound_Compact(p) (p)->lpVtbl->Compact(p)
#define IDirectSound_GetSpeakerConfig(p,a) (p)->lpVtbl->GetSpeakerConfig(p,a)
#define IDirectSound_SetSpeakerConfig(p,b) (p)->lpVtbl->SetSpeakerConfig(p,b)
#define IDirectSound_Initialize(p,a) (p)->lpVtbl->Initialize(p,a)
#else // !defined(__cplusplus) || defined(CINTERFACE)
#define IDirectSound_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
#define IDirectSound_AddRef(p) (p)->AddRef()
#define IDirectSound_Release(p) (p)->Release()
#define IDirectSound_CreateSoundBuffer(p,a,b,c) (p)->CreateSoundBuffer(a,b,c)
#define IDirectSound_GetCaps(p,a) (p)->GetCaps(a)
#define IDirectSound_DuplicateSoundBuffer(p,a,b) (p)->DuplicateSoundBuffer(a,b)
#define IDirectSound_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b)
#define IDirectSound_Compact(p) (p)->Compact()
#define IDirectSound_GetSpeakerConfig(p,a) (p)->GetSpeakerConfig(a)
#define IDirectSound_SetSpeakerConfig(p,b) (p)->SetSpeakerConfig(b)
#define IDirectSound_Initialize(p,a) (p)->Initialize(a)
#endif // !defined(__cplusplus) || defined(CINTERFACE)
//
// IDirectSoundBuffer
//
DEFINE_GUID(IID_IDirectSoundBuffer, 0x279AFA85, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60);
#undef INTERFACE
#define INTERFACE IDirectSoundBuffer
DECLARE_INTERFACE_(IDirectSoundBuffer, IUnknown)
{
// IUnknown methods
STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE;
STDMETHOD_(ULONG,AddRef) (THIS) PURE;
STDMETHOD_(ULONG,Release) (THIS) PURE;
// IDirectSoundBuffer methods
STDMETHOD(GetCaps) (THIS_ LPDSBCAPS) PURE;
STDMETHOD(GetCurrentPosition) (THIS_ LPDWORD, LPDWORD) PURE;
STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX, DWORD, LPDWORD) PURE;
STDMETHOD(GetVolume) (THIS_ LPLONG) PURE;
STDMETHOD(GetPan) (THIS_ LPLONG) PURE;
STDMETHOD(GetFrequency) (THIS_ LPDWORD) PURE;
STDMETHOD(GetStatus) (THIS_ LPDWORD) PURE;
STDMETHOD(Initialize) (THIS_ LPDIRECTSOUND, LPCDSBUFFERDESC) PURE;
STDMETHOD(Lock) (THIS_ DWORD, DWORD, LPVOID *, LPDWORD, LPVOID *, LPDWORD, DWORD) PURE;
STDMETHOD(Play) (THIS_ DWORD, DWORD, DWORD) PURE;
STDMETHOD(SetCurrentPosition) (THIS_ DWORD) PURE;
STDMETHOD(SetFormat) (THIS_ LPCWAVEFORMATEX) PURE;
STDMETHOD(SetVolume) (THIS_ LONG) PURE;
STDMETHOD(SetPan) (THIS_ LONG) PURE;
STDMETHOD(SetFrequency) (THIS_ DWORD) PURE;
STDMETHOD(Stop) (THIS) PURE;
STDMETHOD(Unlock) (THIS_ LPVOID, DWORD, LPVOID, DWORD) PURE;
STDMETHOD(Restore) (THIS) PURE;
};
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirectSoundBuffer_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDirectSoundBuffer_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDirectSoundBuffer_Release(p) (p)->lpVtbl->Release(p)
#define IDirectSoundBuffer_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a)
#define IDirectSoundBuffer_GetCurrentPosition(p,a,b) (p)->lpVtbl->GetCurrentPosition(p,a,b)
#define IDirectSoundBuffer_GetFormat(p,a,b,c) (p)->lpVtbl->GetFormat(p,a,b,c)
#define IDirectSoundBuffer_GetVolume(p,a) (p)->lpVtbl->GetVolume(p,a)
#define IDirectSoundBuffer_GetPan(p,a) (p)->lpVtbl->GetPan(p,a)
#define IDirectSoundBuffer_GetFrequency(p,a) (p)->lpVtbl->GetFrequency(p,a)
#define IDirectSoundBuffer_GetStatus(p,a) (p)->lpVtbl->GetStatus(p,a)
#define IDirectSoundBuffer_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b)
#define IDirectSoundBuffer_Lock(p,a,b,c,d,e,f,g) (p)->lpVtbl->Lock(p,a,b,c,d,e,f,g)
#define IDirectSoundBuffer_Play(p,a,b,c) (p)->lpVtbl->Play(p,a,b,c)
#define IDirectSoundBuffer_SetCurrentPosition(p,a) (p)->lpVtbl->SetCurrentPosition(p,a)
#define IDirectSoundBuffer_SetFormat(p,a) (p)->lpVtbl->SetFormat(p,a)
#define IDirectSoundBuffer_SetVolume(p,a) (p)->lpVtbl->SetVolume(p,a)
#define IDirectSoundBuffer_SetPan(p,a) (p)->lpVtbl->SetPan(p,a)
#define IDirectSoundBuffer_SetFrequency(p,a) (p)->lpVtbl->SetFrequency(p,a)
#define IDirectSoundBuffer_Stop(p) (p)->lpVtbl->Stop(p)
#define IDirectSoundBuffer_Unlock(p,a,b,c,d) (p)->lpVtbl->Unlock(p,a,b,c,d)
#define IDirectSoundBuffer_Restore(p) (p)->lpVtbl->Restore(p)
#else // !defined(__cplusplus) || defined(CINTERFACE)
#define IDirectSoundBuffer_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
#define IDirectSoundBuffer_AddRef(p) (p)->AddRef()
#define IDirectSoundBuffer_Release(p) (p)->Release()
#define IDirectSoundBuffer_GetCaps(p,a) (p)->GetCaps(a)
#define IDirectSoundBuffer_GetCurrentPosition(p,a,b) (p)->GetCurrentPosition(a,b)
#define IDirectSoundBuffer_GetFormat(p,a,b,c) (p)->GetFormat(a,b,c)
#define IDirectSoundBuffer_GetVolume(p,a) (p)->GetVolume(a)
#define IDirectSoundBuffer_GetPan(p,a) (p)->GetPan(a)
#define IDirectSoundBuffer_GetFrequency(p,a) (p)->GetFrequency(a)
#define IDirectSoundBuffer_GetStatus(p,a) (p)->GetStatus(a)
#define IDirectSoundBuffer_Initialize(p,a,b) (p)->Initialize(a,b)
#define IDirectSoundBuffer_Lock(p,a,b,c,d,e,f,g) (p)->Lock(a,b,c,d,e,f,g)
#define IDirectSoundBuffer_Play(p,a,b,c) (p)->Play(a,b,c)
#define IDirectSoundBuffer_SetCurrentPosition(p,a) (p)->SetCurrentPosition(a)
#define IDirectSoundBuffer_SetFormat(p,a) (p)->SetFormat(a)
#define IDirectSoundBuffer_SetVolume(p,a) (p)->SetVolume(a)
#define IDirectSoundBuffer_SetPan(p,a) (p)->SetPan(a)
#define IDirectSoundBuffer_SetFrequency(p,a) (p)->SetFrequency(a)
#define IDirectSoundBuffer_Stop(p) (p)->Stop()
#define IDirectSoundBuffer_Unlock(p,a,b,c,d) (p)->Unlock(a,b,c,d)
#define IDirectSoundBuffer_Restore(p) (p)->Restore()
#endif // !defined(__cplusplus) || defined(CINTERFACE)
//
// IDirectSound3DListener
//
DEFINE_GUID(IID_IDirectSound3DListener, 0x279AFA84, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60);
#undef INTERFACE
#define INTERFACE IDirectSound3DListener
DECLARE_INTERFACE_(IDirectSound3DListener, IUnknown)
{
// IUnknown methods
STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE;
STDMETHOD_(ULONG,AddRef) (THIS) PURE;
STDMETHOD_(ULONG,Release) (THIS) PURE;
// IDirectSound3D methods
STDMETHOD(GetAllParameters) (THIS_ LPDS3DLISTENER) PURE;
STDMETHOD(GetDistanceFactor) (THIS_ LPD3DVALUE) PURE;
STDMETHOD(GetDopplerFactor) (THIS_ LPD3DVALUE) PURE;
STDMETHOD(GetOrientation) (THIS_ LPD3DVECTOR, LPD3DVECTOR) PURE;
STDMETHOD(GetPosition) (THIS_ LPD3DVECTOR) PURE;
STDMETHOD(GetRolloffFactor) (THIS_ LPD3DVALUE) PURE;
STDMETHOD(GetVelocity) (THIS_ LPD3DVECTOR) PURE;
STDMETHOD(SetAllParameters) (THIS_ LPCDS3DLISTENER, DWORD) PURE;
STDMETHOD(SetDistanceFactor) (THIS_ D3DVALUE, DWORD) PURE;
STDMETHOD(SetDopplerFactor) (THIS_ D3DVALUE, DWORD) PURE;
STDMETHOD(SetOrientation) (THIS_ D3DVALUE, D3DVALUE, D3DVALUE, D3DVALUE, D3DVALUE, D3DVALUE, DWORD) PURE;
STDMETHOD(SetPosition) (THIS_ D3DVALUE, D3DVALUE, D3DVALUE, DWORD) PURE;
STDMETHOD(SetRolloffFactor) (THIS_ D3DVALUE, DWORD) PURE;
STDMETHOD(SetVelocity) (THIS_ D3DVALUE, D3DVALUE, D3DVALUE, DWORD) PURE;
STDMETHOD(CommitDeferredSettings) (THIS) PURE;
};
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirectSound3DListener_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDirectSound3DListener_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDirectSound3DListener_Release(p) (p)->lpVtbl->Release(p)
#define IDirectSound3DListener_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a)
#define IDirectSound3DListener_GetDistanceFactor(p,a) (p)->lpVtbl->GetDistanceFactor(p,a)
#define IDirectSound3DListener_GetDopplerFactor(p,a) (p)->lpVtbl->GetDopplerFactor(p,a)
#define IDirectSound3DListener_GetOrientation(p,a,b) (p)->lpVtbl->GetOrientation(p,a,b)
#define IDirectSound3DListener_GetPosition(p,a) (p)->lpVtbl->GetPosition(p,a)
#define IDirectSound3DListener_GetRolloffFactor(p,a) (p)->lpVtbl->GetRolloffFactor(p,a)
#define IDirectSound3DListener_GetVelocity(p,a) (p)->lpVtbl->GetVelocity(p,a)
#define IDirectSound3DListener_SetAllParameters(p,a,b) (p)->lpVtbl->SetAllParameters(p,a,b)
#define IDirectSound3DListener_SetDistanceFactor(p,a,b) (p)->lpVtbl->SetDistanceFactor(p,a,b)
#define IDirectSound3DListener_SetDopplerFactor(p,a,b) (p)->lpVtbl->SetDopplerFactor(p,a,b)
#define IDirectSound3DListener_SetOrientation(p,a,b,c,d,e,f,g) (p)->lpVtbl->SetOrientation(p,a,b,c,d,e,f,g)
#define IDirectSound3DListener_SetPosition(p,a,b,c,d) (p)->lpVtbl->SetPosition(p,a,b,c,d)
#define IDirectSound3DListener_SetRolloffFactor(p,a,b) (p)->lpVtbl->SetRolloffFactor(p,a,b)
#define IDirectSound3DListener_SetVelocity(p,a,b,c,d) (p)->lpVtbl->SetVelocity(p,a,b,c,d)
#define IDirectSound3DListener_CommitDeferredSettings(p) (p)->lpVtbl->CommitDeferredSettings(p)
#else // !defined(__cplusplus) || defined(CINTERFACE)
#define IDirectSound3DListener_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
#define IDirectSound3DListener_AddRef(p) (p)->AddRef()
#define IDirectSound3DListener_Release(p) (p)->Release()
#define IDirectSound3DListener_GetAllParameters(p,a) (p)->GetAllParameters(a)
#define IDirectSound3DListener_GetDistanceFactor(p,a) (p)->GetDistanceFactor(a)
#define IDirectSound3DListener_GetDopplerFactor(p,a) (p)->GetDopplerFactor(a)
#define IDirectSound3DListener_GetOrientation(p,a,b) (p)->GetOrientation(a,b)
#define IDirectSound3DListener_GetPosition(p,a) (p)->GetPosition(a)
#define IDirectSound3DListener_GetRolloffFactor(p,a) (p)->GetRolloffFactor(a)
#define IDirectSound3DListener_GetVelocity(p,a) (p)->GetVelocity(a)
#define IDirectSound3DListener_SetAllParameters(p,a,b) (p)->SetAllParameters(a,b)
#define IDirectSound3DListener_SetDistanceFactor(p,a,b) (p)->SetDistanceFactor(a,b)
#define IDirectSound3DListener_SetDopplerFactor(p,a,b) (p)->SetDopplerFactor(a,b)
#define IDirectSound3DListener_SetOrientation(p,a,b,c,d,e,f,g) (p)->SetOrientation(a,b,c,d,e,f,g)
#define IDirectSound3DListener_SetPosition(p,a,b,c,d) (p)->SetPosition(a,b,c,d)
#define IDirectSound3DListener_SetRolloffFactor(p,a,b) (p)->SetRolloffFactor(a,b)
#define IDirectSound3DListener_SetVelocity(p,a,b,c,d) (p)->SetVelocity(a,b,c,d)
#define IDirectSound3DListener_CommitDeferredSettings(p) (p)->CommitDeferredSettings()
#endif // !defined(__cplusplus) || defined(CINTERFACE)
//
// IDirectSound3DBuffer
//
DEFINE_GUID(IID_IDirectSound3DBuffer, 0x279AFA86, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60);
#undef INTERFACE
#define INTERFACE IDirectSound3DBuffer
DECLARE_INTERFACE_(IDirectSound3DBuffer, IUnknown)
{
// IUnknown methods
STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE;
STDMETHOD_(ULONG,AddRef) (THIS) PURE;
STDMETHOD_(ULONG,Release) (THIS) PURE;
// IDirectSoundBuffer3D methods
STDMETHOD(GetAllParameters) (THIS_ LPDS3DBUFFER) PURE;
STDMETHOD(GetConeAngles) (THIS_ LPDWORD, LPDWORD) PURE;
STDMETHOD(GetConeOrientation) (THIS_ LPD3DVECTOR) PURE;
STDMETHOD(GetConeOutsideVolume) (THIS_ LPLONG) PURE;
STDMETHOD(GetMaxDistance) (THIS_ LPD3DVALUE) PURE;
STDMETHOD(GetMinDistance) (THIS_ LPD3DVALUE) PURE;
STDMETHOD(GetMode) (THIS_ LPDWORD) PURE;
STDMETHOD(GetPosition) (THIS_ LPD3DVECTOR) PURE;
STDMETHOD(GetVelocity) (THIS_ LPD3DVECTOR) PURE;
STDMETHOD(SetAllParameters) (THIS_ LPCDS3DBUFFER, DWORD) PURE;
STDMETHOD(SetConeAngles) (THIS_ DWORD, DWORD, DWORD) PURE;
STDMETHOD(SetConeOrientation) (THIS_ D3DVALUE, D3DVALUE, D3DVALUE, DWORD) PURE;
STDMETHOD(SetConeOutsideVolume) (THIS_ LONG, DWORD) PURE;
STDMETHOD(SetMaxDistance) (THIS_ D3DVALUE, DWORD) PURE;
STDMETHOD(SetMinDistance) (THIS_ D3DVALUE, DWORD) PURE;
STDMETHOD(SetMode) (THIS_ DWORD, DWORD) PURE;
STDMETHOD(SetPosition) (THIS_ D3DVALUE, D3DVALUE, D3DVALUE, DWORD) PURE;
STDMETHOD(SetVelocity) (THIS_ D3DVALUE, D3DVALUE, D3DVALUE, DWORD) PURE;
};
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirectSound3DBuffer_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDirectSound3DBuffer_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDirectSound3DBuffer_Release(p) (p)->lpVtbl->Release(p)
#define IDirectSound3DBuffer_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a)
#define IDirectSound3DBuffer_GetConeAngles(p,a,b) (p)->lpVtbl->GetConeAngles(p,a,b)
#define IDirectSound3DBuffer_GetConeOrientation(p,a) (p)->lpVtbl->GetConeOrientation(p,a)
#define IDirectSound3DBuffer_GetConeOutsideVolume(p,a) (p)->lpVtbl->GetConeOutsideVolume(p,a)
#define IDirectSound3DBuffer_GetPosition(p,a) (p)->lpVtbl->GetPosition(p,a)
#define IDirectSound3DBuffer_GetMinDistance(p,a) (p)->lpVtbl->GetMinDistance(p,a)
#define IDirectSound3DBuffer_GetMaxDistance(p,a) (p)->lpVtbl->GetMaxDistance(p,a)
#define IDirectSound3DBuffer_GetMode(p,a) (p)->lpVtbl->GetMode(p,a)
#define IDirectSound3DBuffer_GetVelocity(p,a) (p)->lpVtbl->GetVelocity(p,a)
#define IDirectSound3DBuffer_SetAllParameters(p,a,b) (p)->lpVtbl->SetAllParameters(p,a,b)
#define IDirectSound3DBuffer_SetConeAngles(p,a,b,c) (p)->lpVtbl->SetConeAngles(p,a,b,c)
#define IDirectSound3DBuffer_SetConeOrientation(p,a,b,c,d) (p)->lpVtbl->SetConeOrientation(p,a,b,c,d)
#define IDirectSound3DBuffer_SetConeOutsideVolume(p,a,b)(p)->lpVtbl->SetConeOutsideVolume(p,a,b)
#define IDirectSound3DBuffer_SetPosition(p,a,b,c,d) (p)->lpVtbl->SetPosition(p,a,b,c,d)
#define IDirectSound3DBuffer_SetMinDistance(p,a,b) (p)->lpVtbl->SetMinDistance(p,a,b)
#define IDirectSound3DBuffer_SetMaxDistance(p,a,b) (p)->lpVtbl->SetMaxDistance(p,a,b)
#define IDirectSound3DBuffer_SetMode(p,a,b) (p)->lpVtbl->SetMode(p,a,b)
#define IDirectSound3DBuffer_SetVelocity(p,a,b,c,d) (p)->lpVtbl->SetVelocity(p,a,b,c,d)
#else // !defined(__cplusplus) || defined(CINTERFACE)
#define IDirectSound3DBuffer_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
#define IDirectSound3DBuffer_AddRef(p) (p)->AddRef()
#define IDirectSound3DBuffer_Release(p) (p)->Release()
#define IDirectSound3DBuffer_GetAllParameters(p,a) (p)->GetAllParameters(a)
#define IDirectSound3DBuffer_GetConeAngles(p,a,b) (p)->GetConeAngles(a,b)
#define IDirectSound3DBuffer_GetConeOrientation(p,a) (p)->GetConeOrientation(a)
#define IDirectSound3DBuffer_GetConeOutsideVolume(p,a) (p)->GetConeOutsideVolume(a)
#define IDirectSound3DBuffer_GetPosition(p,a) (p)->GetPosition(a)
#define IDirectSound3DBuffer_GetMinDistance(p,a) (p)->GetMinDistance(a)
#define IDirectSound3DBuffer_GetMaxDistance(p,a) (p)->GetMaxDistance(a)
#define IDirectSound3DBuffer_GetMode(p,a) (p)->GetMode(a)
#define IDirectSound3DBuffer_GetVelocity(p,a) (p)->GetVelocity(a)
#define IDirectSound3DBuffer_SetAllParameters(p,a,b) (p)->SetAllParameters(a,b)
#define IDirectSound3DBuffer_SetConeAngles(p,a,b,c) (p)->SetConeAngles(a,b,c)
#define IDirectSound3DBuffer_SetConeOrientation(p,a,b,c,d) (p)->SetConeOrientation(a,b,c,d)
#define IDirectSound3DBuffer_SetConeOutsideVolume(p,a,b)(p)->SetConeOutsideVolume(a,b)
#define IDirectSound3DBuffer_SetPosition(p,a,b,c,d) (p)->SetPosition(a,b,c,d)
#define IDirectSound3DBuffer_SetMinDistance(p,a,b) (p)->SetMinDistance(a,b)
#define IDirectSound3DBuffer_SetMaxDistance(p,a,b) (p)->SetMaxDistance(a,b)
#define IDirectSound3DBuffer_SetMode(p,a,b) (p)->SetMode(a,b)
#define IDirectSound3DBuffer_SetVelocity(p,a,b,c,d) (p)->SetVelocity(a,b,c,d)
#endif // !defined(__cplusplus) || defined(CINTERFACE)
//
// IDirectSoundCapture
//
DEFINE_GUID(IID_IDirectSoundCapture, 0xb0210781, 0x89cd, 0x11d0, 0xaf, 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16);
#undef INTERFACE
#define INTERFACE IDirectSoundCapture
DECLARE_INTERFACE_(IDirectSoundCapture, IUnknown)
{
// IUnknown methods
STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE;
STDMETHOD_(ULONG,AddRef) (THIS) PURE;
STDMETHOD_(ULONG,Release) (THIS) PURE;
// IDirectSoundCapture methods
STDMETHOD(CreateCaptureBuffer) (THIS_ LPCDSCBUFFERDESC, LPDIRECTSOUNDCAPTUREBUFFER *, LPUNKNOWN) PURE;
STDMETHOD(GetCaps) (THIS_ LPDSCCAPS ) PURE;
STDMETHOD(Initialize) (THIS_ LPGUID) PURE;
};
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirectSoundCapture_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDirectSoundCapture_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDirectSoundCapture_Release(p) (p)->lpVtbl->Release(p)
#define IDirectSoundCapture_CreateCaptureBuffer(p,a,b,c) (p)->lpVtbl->CreateCaptureBuffer(p,a,b,c)
#define IDirectSoundCapture_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a)
#define IDirectSoundCapture_Initialize(p,a) (p)->lpVtbl->Initialize(p,a)
#else // !defined(__cplusplus) || defined(CINTERFACE)
#define IDirectSoundCapture_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
#define IDirectSoundCapture_AddRef(p) (p)->AddRef()
#define IDirectSoundCapture_Release(p) (p)->Release()
#define IDirectSoundCapture_CreateCaptureBuffer(p,a,b,c) (p)->CreateCaptureBuffer(a,b,c)
#define IDirectSoundCapture_GetCaps(p,a) (p)->GetCaps(a)
#define IDirectSoundCapture_Initialize(p,a) (p)->Initialize(a)
#endif // !defined(__cplusplus) || defined(CINTERFACE)
//
// IDirectSoundCaptureBuffer
//
DEFINE_GUID(IID_IDirectSoundCaptureBuffer, 0xb0210782, 0x89cd, 0x11d0, 0xaf, 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16);
#undef INTERFACE
#define INTERFACE IDirectSoundCaptureBuffer
DECLARE_INTERFACE_(IDirectSoundCaptureBuffer, IUnknown)
{
// IUnknown methods
STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE;
STDMETHOD_(ULONG,AddRef) (THIS) PURE;
STDMETHOD_(ULONG,Release) (THIS) PURE;
// IDirectSoundCaptureBuffer methods
STDMETHOD(GetCaps) (THIS_ LPDSCBCAPS ) PURE;
STDMETHOD(GetCurrentPosition) (THIS_ LPDWORD, LPDWORD ) PURE;
STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX, DWORD, LPDWORD ) PURE;
STDMETHOD(GetStatus) (THIS_ LPDWORD ) PURE;
STDMETHOD(Initialize) (THIS_ LPDIRECTSOUNDCAPTURE, LPCDSCBUFFERDESC) PURE;
STDMETHOD(Lock) (THIS_ DWORD, DWORD, LPVOID *, LPDWORD, LPVOID *, LPDWORD, DWORD) PURE;
STDMETHOD(Start) (THIS_ DWORD) PURE;
STDMETHOD(Stop) (THIS) PURE;
STDMETHOD(Unlock) (THIS_ LPVOID, DWORD, LPVOID, DWORD) PURE;
};
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirectSoundCaptureBuffer_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDirectSoundCaptureBuffer_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDirectSoundCaptureBuffer_Release(p) (p)->lpVtbl->Release(p)
#define IDirectSoundCaptureBuffer_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a)
#define IDirectSoundCaptureBuffer_GetCurrentPosition(p,a,b) (p)->lpVtbl->GetCurrentPosition(p,a,b)
#define IDirectSoundCaptureBuffer_GetFormat(p,a,b,c) (p)->lpVtbl->GetFormat(p,a,b,c)
#define IDirectSoundCaptureBuffer_GetStatus(p,a) (p)->lpVtbl->GetStatus(p,a)
#define IDirectSoundCaptureBuffer_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b)
#define IDirectSoundCaptureBuffer_Lock(p,a,b,c,d,e,f,g) (p)->lpVtbl->Lock(p,a,b,c,d,e,f,g)
#define IDirectSoundCaptureBuffer_Start(p,a) (p)->lpVtbl->Start(p,a)
#define IDirectSoundCaptureBuffer_Stop(p) (p)->lpVtbl->Stop(p)
#define IDirectSoundCaptureBuffer_Unlock(p,a,b,c,d) (p)->lpVtbl->Unlock(p,a,b,c,d)
#else // !defined(__cplusplus) || defined(CINTERFACE)
#define IDirectSoundCaptureBuffer_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
#define IDirectSoundCaptureBuffer_AddRef(p) (p)->AddRef()
#define IDirectSoundCaptureBuffer_Release(p) (p)->Release()
#define IDirectSoundCaptureBuffer_GetCaps(p,a) (p)->GetCaps(a)
#define IDirectSoundCaptureBuffer_GetCurrentPosition(p,a,b) (p)->GetCurrentPosition(a,b)
#define IDirectSoundCaptureBuffer_GetFormat(p,a,b,c) (p)->GetFormat(a,b,c)
#define IDirectSoundCaptureBuffer_GetStatus(p,a) (p)->GetStatus(a)
#define IDirectSoundCaptureBuffer_Initialize(p,a,b) (p)->Initialize(a,b)
#define IDirectSoundCaptureBuffer_Lock(p,a,b,c,d,e,f,g) (p)->Lock(a,b,c,d,e,f,g)
#define IDirectSoundCaptureBuffer_Start(p,a) (p)->Start(a)
#define IDirectSoundCaptureBuffer_Stop(p) (p)->Stop()
#define IDirectSoundCaptureBuffer_Unlock(p,a,b,c,d) (p)->Unlock(a,b,c,d)
#endif // !defined(__cplusplus) || defined(CINTERFACE)
//
// IDirectSoundNotify
//
DEFINE_GUID(IID_IDirectSoundNotify, 0xb0210783, 0x89cd, 0x11d0, 0xaf, 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16);
#undef INTERFACE
#define INTERFACE IDirectSoundNotify
DECLARE_INTERFACE_(IDirectSoundNotify, IUnknown)
{
// IUnknown methods
STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE;
STDMETHOD_(ULONG,AddRef) (THIS) PURE;
STDMETHOD_(ULONG,Release) (THIS) PURE;
// IDirectSoundNotify methods
STDMETHOD(SetNotificationPositions) (THIS_ DWORD, LPCDSBPOSITIONNOTIFY) PURE;
};
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirectSoundNotify_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDirectSoundNotify_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDirectSoundNotify_Release(p) (p)->lpVtbl->Release(p)
#define IDirectSoundNotify_SetNotificationPositions(p,a,b) (p)->lpVtbl->SetNotificationPositions(p,a,b)
#else // !defined(__cplusplus) || defined(CINTERFACE)
#define IDirectSoundNotify_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
#define IDirectSoundNotify_AddRef(p) (p)->AddRef()
#define IDirectSoundNotify_Release(p) (p)->Release()
#define IDirectSoundNotify_SetNotificationPositions(p,a,b) (p)->SetNotificationPositions(a,b)
#endif // !defined(__cplusplus) || defined(CINTERFACE)
//
// IKsPropertySet
//
#ifndef _IKsPropertySet_
#define _IKsPropertySet_
#ifdef __cplusplus
// 'struct' not 'class' per the way DECLARE_INTERFACE_ is defined
struct IKsPropertySet;
#endif // __cplusplus
typedef struct IKsPropertySet *LPKSPROPERTYSET;
#define KSPROPERTY_SUPPORT_GET 0x00000001
#define KSPROPERTY_SUPPORT_SET 0x00000002
DEFINE_GUID(IID_IKsPropertySet, 0x31efac30, 0x515c, 0x11d0, 0xa9, 0xaa, 0x00, 0xaa, 0x00, 0x61, 0xbe, 0x93);
#undef INTERFACE
#define INTERFACE IKsPropertySet
DECLARE_INTERFACE_(IKsPropertySet, IUnknown)
{
// IUnknown methods
STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE;
STDMETHOD_(ULONG,AddRef) (THIS) PURE;
STDMETHOD_(ULONG,Release) (THIS) PURE;
// IKsPropertySet methods
STDMETHOD(Get) (THIS_ REFGUID, ULONG, LPVOID, ULONG, LPVOID, ULONG, PULONG) PURE;
STDMETHOD(Set) (THIS_ REFGUID, ULONG, LPVOID, ULONG, LPVOID, ULONG) PURE;
STDMETHOD(QuerySupport) (THIS_ REFGUID, ULONG, PULONG) PURE;
};
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IKsPropertySet_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IKsPropertySet_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IKsPropertySet_Release(p) (p)->lpVtbl->Release(p)
#define IKsPropertySet_Get(p,a,b,c,d,e,f,g) (p)->lpVtbl->Get(p,a,b,c,d,e,f,g)
#define IKsPropertySet_Set(p,a,b,c,d,e,f) (p)->lpVtbl->Set(p,a,b,c,d,e,f)
#define IKsPropertySet_QuerySupport(p,a,b,c) (p)->lpVtbl->QuerySupport(p,a,b,c)
#else // !defined(__cplusplus) || defined(CINTERFACE)
#define IKsPropertySet_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
#define IKsPropertySet_AddRef(p) (p)->AddRef()
#define IKsPropertySet_Release(p) (p)->Release()
#define IKsPropertySet_Get(p,a,b,c,d,e,f,g) (p)->Get(a,b,c,d,e,f,g)
#define IKsPropertySet_Set(p,a,b,c,d,e,f) (p)->Set(a,b,c,d,e,f)
#define IKsPropertySet_QuerySupport(p,a,b,c) (p)->QuerySupport(a,b,c)
#endif // !defined(__cplusplus) || defined(CINTERFACE)
#endif // _IKsPropertySet_
//
// Return Codes
//
#define DS_OK 0
// The call failed because resources (such as a priority level)
// were already being used by another caller.
#define DSERR_ALLOCATED MAKE_DSHRESULT(10)
// The control (vol,pan,etc.) requested by the caller is not available.
#define DSERR_CONTROLUNAVAIL MAKE_DSHRESULT(30)
// An invalid parameter was passed to the returning function
#define DSERR_INVALIDPARAM E_INVALIDARG
// This call is not valid for the current state of this object
#define DSERR_INVALIDCALL MAKE_DSHRESULT(50)
// An undetermined error occured inside the DirectSound subsystem
#define DSERR_GENERIC E_FAIL
// The caller does not have the priority level required for the function to
// succeed.
#define DSERR_PRIOLEVELNEEDED MAKE_DSHRESULT(70)
// Not enough free memory is available to complete the operation
#define DSERR_OUTOFMEMORY E_OUTOFMEMORY
// The specified WAVE format is not supported
#define DSERR_BADFORMAT MAKE_DSHRESULT(100)
// The function called is not supported at this time
#define DSERR_UNSUPPORTED E_NOTIMPL
// No sound driver is available for use
#define DSERR_NODRIVER MAKE_DSHRESULT(120)
// This object is already initialized
#define DSERR_ALREADYINITIALIZED MAKE_DSHRESULT(130)
// This object does not support aggregation
#define DSERR_NOAGGREGATION CLASS_E_NOAGGREGATION
// The buffer memory has been lost, and must be restored.
#define DSERR_BUFFERLOST MAKE_DSHRESULT(150)
// Another app has a higher priority level, preventing this call from
// succeeding.
#define DSERR_OTHERAPPHASPRIO MAKE_DSHRESULT(160)
// This object has not been initialized
#define DSERR_UNINITIALIZED MAKE_DSHRESULT(170)
// The requested COM interface is not available
#define DSERR_NOINTERFACE E_NOINTERFACE
//
// Flags
//
#define DSCAPS_PRIMARYMONO 0x00000001
#define DSCAPS_PRIMARYSTEREO 0x00000002
#define DSCAPS_PRIMARY8BIT 0x00000004
#define DSCAPS_PRIMARY16BIT 0x00000008
#define DSCAPS_CONTINUOUSRATE 0x00000010
#define DSCAPS_EMULDRIVER 0x00000020
#define DSCAPS_CERTIFIED 0x00000040
#define DSCAPS_SECONDARYMONO 0x00000100
#define DSCAPS_SECONDARYSTEREO 0x00000200
#define DSCAPS_SECONDARY8BIT 0x00000400
#define DSCAPS_SECONDARY16BIT 0x00000800
#define DSBPLAY_LOOPING 0x00000001
#define DSBSTATUS_PLAYING 0x00000001
#define DSBSTATUS_BUFFERLOST 0x00000002
#define DSBSTATUS_LOOPING 0x00000004
#define DSBLOCK_FROMWRITECURSOR 0x00000001
#define DSBLOCK_ENTIREBUFFER 0x00000002
#define DSSCL_NORMAL 0x00000001
#define DSSCL_PRIORITY 0x00000002
#define DSSCL_EXCLUSIVE 0x00000003
#define DSSCL_WRITEPRIMARY 0x00000004
#define DS3DMODE_NORMAL 0x00000000
#define DS3DMODE_HEADRELATIVE 0x00000001
#define DS3DMODE_DISABLE 0x00000002
#define DS3D_IMMEDIATE 0x00000000
#define DS3D_DEFERRED 0x00000001
#define DS3D_MINDISTANCEFACTOR 0.0f
#define DS3D_MAXDISTANCEFACTOR 10.0f
#define DS3D_DEFAULTDISTANCEFACTOR 1.0f
#define DS3D_MINROLLOFFFACTOR 0.0f
#define DS3D_MAXROLLOFFFACTOR 10.0f
#define DS3D_DEFAULTROLLOFFFACTOR 1.0f
#define DS3D_MINDOPPLERFACTOR 0.0f
#define DS3D_MAXDOPPLERFACTOR 10.0f
#define DS3D_DEFAULTDOPPLERFACTOR 1.0f
#define DS3D_DEFAULTMINDISTANCE 1.0f
#define DS3D_DEFAULTMAXDISTANCE 1000000000.0f
#define DS3D_MINCONEANGLE 0
#define DS3D_MAXCONEANGLE 360
#define DS3D_DEFAULTCONEANGLE 360
#define DS3D_DEFAULTCONEOUTSIDEVOLUME 0
#define DSBCAPS_PRIMARYBUFFER 0x00000001
#define DSBCAPS_STATIC 0x00000002
#define DSBCAPS_LOCHARDWARE 0x00000004
#define DSBCAPS_LOCSOFTWARE 0x00000008
#define DSBCAPS_CTRL3D 0x00000010
#define DSBCAPS_CTRLFREQUENCY 0x00000020
#define DSBCAPS_CTRLPAN 0x00000040
#define DSBCAPS_CTRLVOLUME 0x00000080
#define DSBCAPS_CTRLPOSITIONNOTIFY 0x00000100
#define DSBCAPS_CTRLDEFAULT 0x000000E0
#define DSBCAPS_CTRLALL 0x000001F0
#define DSBCAPS_STICKYFOCUS 0x00004000
#define DSBCAPS_GLOBALFOCUS 0x00008000
#define DSBCAPS_GETCURRENTPOSITION2 0x00010000
#define DSBCAPS_MUTE3DATMAXDISTANCE 0x00020000
#define DSCBCAPS_WAVEMAPPED 0x80000000
#define DSSPEAKER_HEADPHONE 0x00000001
#define DSSPEAKER_MONO 0x00000002
#define DSSPEAKER_QUAD 0x00000003
#define DSSPEAKER_STEREO 0x00000004
#define DSSPEAKER_SURROUND 0x00000005
#define DSSPEAKER_GEOMETRY_MIN 0x00000005 // 5 degrees
#define DSSPEAKER_GEOMETRY_NARROW 0x0000000A // 10 degrees
#define DSSPEAKER_GEOMETRY_WIDE 0x00000014 // 20 degrees
#define DSSPEAKER_GEOMETRY_MAX 0x000000B4 // 180 degrees
#define DSSPEAKER_COMBINED(c, g) ((DWORD)(((BYTE)(c)) | ((DWORD)((BYTE)(g))) << 16))
#define DSSPEAKER_CONFIG(a) ((BYTE)(a))
#define DSSPEAKER_GEOMETRY(a) ((BYTE)(((DWORD)(a) >> 16) & 0x00FF))
#define DSCCAPS_EMULDRIVER 0x00000020
#define DSCBLOCK_ENTIREBUFFER 0x00000001
#define DSCBSTATUS_CAPTURING 0x00000001
#define DSCBSTATUS_LOOPING 0x00000002
#define DSCBSTART_LOOPING 0x00000001
#define DSBFREQUENCY_MIN 100
#define DSBFREQUENCY_MAX 100000
#define DSBFREQUENCY_ORIGINAL 0
#define DSBPAN_LEFT -10000
#define DSBPAN_CENTER 0
#define DSBPAN_RIGHT 10000
#define DSBVOLUME_MIN -10000
#define DSBVOLUME_MAX 0
#define DSBSIZE_MIN 4
#define DSBSIZE_MAX 0x0FFFFFFF
#define DSBPN_OFFSETSTOP 0xFFFFFFFF
#ifdef __cplusplus
};
#endif // __cplusplus
#endif // __DSOUND_INCLUDED__
+100 -110
View File
@@ -47,7 +47,6 @@ fireball_info Fireball_info[MAX_FIREBALL_TYPES];
int fireball_used[MAX_FIREBALL_TYPES];
int Num_fireballs = 0;
int Num_fireball_types = 0;
int fireballs_inited = 0;
@@ -57,7 +56,9 @@ int Warp_ball_bitmap = -1;
#define FB_INDEX(fb) (fb-Fireballs)
// play warp in sound for warp effect
/**
* Play warp in sound for warp effect
*/
void fireball_play_warphole_open_sound(int ship_class, fireball *fb)
{
int sound_index;
@@ -87,7 +88,9 @@ void fireball_play_warphole_open_sound(int ship_class, fireball *fb)
snd_play_3d(&Snds[sound_index], &fireball_objp->pos, &Eye_position, fireball_objp->radius, NULL, 0, 1.0f, SND_PRIORITY_DOUBLE_INSTANCE, NULL, range_multiplier); // play warp sound effect
}
// play warp out sound for warp effect
/**
* Play warp out sound for warp effect
*/
void fireball_play_warphole_close_sound(fireball *fb)
{
int sound_index;
@@ -103,14 +106,15 @@ void fireball_play_warphole_close_sound(fireball *fb)
} else if ( fb->flags & FBF_WARP_CAPITAL_SIZE ) {
sound_index = SND_CAPITAL_WARP_OUT;
} else {
// AL 27-3-98: Decided that warphole closing is only required for capital ship sized warp effects.
return;
}
snd_play_3d(&Snds[sound_index], &fireball_objp->pos, &Eye_position, fireball_objp->radius); // play warp sound effect
}
// set default colors for each explosion type (original values from object.cpp)
/**
* Set default colors for each explosion type (original values from object.cpp)
*/
static void fireball_set_default_color(int idx)
{
Assert( (idx >= 0) && (idx < MAX_FIREBALL_TYPES) );
@@ -147,7 +151,11 @@ static void fireball_set_default_color(int idx)
}
}
// NOTE: we can't be too trusting here so a tbm will only modify the LOD count, not add an entry
/**
* Parse fireball tbl
*
* NOTE: we can't be too trusting here so a tbm will only modify the LOD count, not add an entry
*/
void parse_fireball_tbl(char *filename)
{
int rval;
@@ -239,7 +247,8 @@ void parse_fireball_tbl(char *filename)
void fireball_parse_tbl()
{
int i, j;
int i = 0, j;
SCP_vector<lod_checker>::iterator lod;
memset( &Fireball_info, 0, sizeof(fireball_info) * MAX_FIREBALL_TYPES );
@@ -251,10 +260,10 @@ void fireball_parse_tbl()
// we've got our list so pass it off for final checking and loading.
// we assume that entries in fireball.tbl are in the correct order
for (i = 0; i < (int)LOD_checker.size(); i++) {
if ( (i < MAX_FIREBALL_TYPES) && (LOD_checker[i].override < 0) ) {
strcpy_s( Fireball_info[i].lod[0].filename, LOD_checker[i].filename );
Fireball_info[i].lod_count = LOD_checker[i].num_lods;
for (lod = LOD_checker.begin(); lod != LOD_checker.end(); ++lod) {
if ( (i < MAX_FIREBALL_TYPES) && (lod->override < 0) ) {
strcpy_s( Fireball_info[i].lod[0].filename, lod->filename );
Fireball_info[i].lod_count = lod->num_lods;
Num_fireball_types++;
if (LOD_color[i].alpha == 255) {
@@ -265,22 +274,24 @@ void fireball_parse_tbl()
fireball_set_default_color(i);
}
}
i++;
}
// having to do this twice is less than optimal, but less error prone too.
// this handles (and should only have to handle) TBM related entries
for (i = 0; i < (int)LOD_checker.size(); i++) {
i = 0;
for (lod = LOD_checker.begin(); lod != LOD_checker.end(); ++lod) {
// try entry replacement
if ( (LOD_checker[i].override >= 0) && (LOD_checker[i].override < Num_fireball_types) ) {
strcpy_s( Fireball_info[LOD_checker[i].override].lod[0].filename, LOD_checker[i].filename );
Fireball_info[LOD_checker[i].override].lod_count = LOD_checker[i].num_lods;
if ( (lod->override >= 0) && (lod->override < Num_fireball_types) ) {
strcpy_s( Fireball_info[lod->override].lod[0].filename, lod->filename );
Fireball_info[lod->override].lod_count = lod->num_lods;
if (LOD_color[i].alpha == 255) {
Fireball_info[LOD_checker[i].override].exp_color[0] = (LOD_color[i].red / 255.0f);
Fireball_info[LOD_checker[i].override].exp_color[1] = (LOD_color[i].green / 255.0f);
Fireball_info[LOD_checker[i].override].exp_color[2] = (LOD_color[i].blue / 255.0f);
Fireball_info[lod->override].exp_color[0] = (LOD_color[i].red / 255.0f);
Fireball_info[lod->override].exp_color[1] = (LOD_color[i].green / 255.0f);
Fireball_info[lod->override].exp_color[2] = (LOD_color[i].blue / 255.0f);
} else {
fireball_set_default_color(LOD_checker[i].override);
fireball_set_default_color(lod->override);
}
}
}
@@ -323,15 +334,6 @@ void fireball_load_data()
if ( Warp_ball_bitmap == -1 ) {
Warp_ball_bitmap = bm_load( NOX("warpball01") );
}
// polymodel Warp_pm;
}
void fireball_preload()
{
// Do nothing. Called before level init, this used to page in warp effect.
// Not needed with new BmpMan system.
}
// This will get called at the start of each level.
@@ -372,8 +374,6 @@ MONITOR( NumFireballsRend )
void fireball_render(object * obj)
{
// if(!Cmdline_nohtl)gr_set_lighting(false,false);
int num;
vertex p;
fireball *fb;
@@ -388,10 +388,6 @@ void fireball_render(object * obj)
if ( Fireballs[num].current_bitmap < 0 )
return;
// gr_set_color( 0, 100, 0 );
// g3_draw_sphere_ez( &obj->pos, obj->radius );
// return;
// turn off fogging
if(The_mission.flags & MISSION_FLAG_FULLNEB){
gr_fog_set(GR_FOGMODE_NONE, 0, 0, 0);
@@ -406,14 +402,24 @@ void fireball_render(object * obj)
switch( fb->fireball_render_type ) {
case FIREBALL_MEDIUM_EXPLOSION:
gr_set_bitmap(Fireballs[num].current_bitmap, GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, 1.3f );
g3_draw_bitmap(&p, fb->orient, obj->radius, TMAP_FLAG_TEXTURED | TMAP_HTL_3D_UNLIT );
batch_add_bitmap (
Fireballs[num].current_bitmap,
TMAP_FLAG_TEXTURED | TMAP_HTL_3D_UNLIT | TMAP_FLAG_SOFT_QUAD,
&p,
fb->orient,
obj->radius
);
break;
case FIREBALL_LARGE_EXPLOSION:
// Make the big explosions rotate with the viewer.
gr_set_bitmap(Fireballs[num].current_bitmap, GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, 1.3f );
g3_draw_rotated_bitmap(&p, (i2fl(fb->orient)*PI)/180.0f, obj->radius, TMAP_FLAG_TEXTURED | TMAP_HTL_3D_UNLIT);
batch_add_bitmap_rotated (
Fireballs[num].current_bitmap,
TMAP_FLAG_TEXTURED | TMAP_HTL_3D_UNLIT | TMAP_FLAG_SOFT_QUAD,
&p,
(i2fl(fb->orient)*PI)/180.0f,
obj->radius
);
break;
case FIREBALL_WARP_EFFECT: {
@@ -427,17 +433,11 @@ void fireball_render(object * obj)
if ( t < WARPHOLE_GROW_TIME ) {
rad = (float)pow(t/WARPHOLE_GROW_TIME,0.4f)*obj->radius;
//rad = t*obj->radius/WARPHOLE_GROW_TIME;
//mprintf(( "T=%.2f, Rad = %.2f\n", t, rad ));
} else if ( t < fb->total_time - WARPHOLE_GROW_TIME ) {
rad = obj->radius;
} else {
rad = (float)pow((fb->total_time - t)/WARPHOLE_GROW_TIME,0.4f)*obj->radius;
//rad = (fb->total_time - t )*obj->radius/WARPHOLE_GROW_TIME;
}
//rad = obj->radius;
// obj->alt_rad = rad;
warpin_render(obj, &obj->orient, &obj->pos, Fireballs[num].current_bitmap, rad, percent_life, obj->radius, (Fireballs[num].flags & FBF_WARP_3D) );
}
@@ -449,12 +449,10 @@ void fireball_render(object * obj)
}
}
// -----------------------------------------------------------------
// fireball_delete()
//
// Delete a fireball. Called by object_delete() code... do not call
// directly.
//
/**
* Delete a fireball.
* Called by object_delete() code... do not call directly.
*/
void fireball_delete( object * obj )
{
int num;
@@ -470,11 +468,9 @@ void fireball_delete( object * obj )
Assert( Num_fireballs >= 0 );
}
// -----------------------------------------------------------------
// fireball_delete_all()
//
// Delete all active fireballs, by calling obj_delete directly.
//
/**
* Delete all active fireballs, by calling obj_delete directly.
*/
void fireball_delete_all()
{
fireball *fb;
@@ -564,12 +560,12 @@ int fireball_is_perishable(object * obj)
}
// -----------------------------------------------------------------
// fireball_free_one()
//
// There are too many fireballs, so delete the oldest small one
// to free up a slot. Returns the fireball slot freed.
//
/**
* There are too many fireballs, so delete the oldest small one
* to free up a slot.
*
* @return The fireball slot freed.
*/
int fireball_free_one()
{
fireball *fb;
@@ -600,12 +596,6 @@ int fireball_free_one()
return oldest_slotnum;
}
// broke fireball_move into fireball_process_pre and fireball_process_post as was done
// with all *_move functions on 8/13 by Mike K. and Mark A.
void fireball_process_pre( object *objp, float frame_time)
{
}
int fireball_is_warp(object * obj)
{
int num, objnum;
@@ -671,7 +661,9 @@ void fireball_process_post(object * obj, float frame_time)
fireball_set_framenum(num);
}
// Returns life left of a fireball in seconds
/**
* Returns life left of a fireball in seconds
*/
float fireball_lifeleft( object *obj )
{
int num, objnum;
@@ -686,7 +678,9 @@ float fireball_lifeleft( object *obj )
return fb->total_time - fb->time_elapsed;
}
// Returns life left of a fireball in percent
/**
* Returns life left of a fireball in percent
*/
float fireball_lifeleft_percent( object *obj )
{
int num, objnum;
@@ -698,14 +692,14 @@ float fireball_lifeleft_percent( object *obj )
fb = &Fireballs[num];
// Assert((fb->total_time - fb->time_elapsed) / fb->total_time >=0);
float p = (fb->total_time - fb->time_elapsed) / fb->total_time;
if (p < 0)p=0.0f;
return p;
}
// determine LOD to use
/**
* Determine LOD to use
*/
int fireball_get_lod(vec3d *pos, fireball_info *fd, float size)
{
vertex v;
@@ -786,7 +780,9 @@ int fireball_get_lod(vec3d *pos, fireball_info *fd, float size)
return MIN(ret_lod, fd->lod_count - 1);
}
// Create a fireball, return object index.
/**
* Create a fireball, return object index.
*/
int fireball_create( vec3d * pos, int fireball_type, int render_type, int parent_obj, float size, int reverse, vec3d *velocity, float warp_lifetime, int ship_class, matrix *orient_override, int low_res, int extra_flags, int warp_open_sound, int warp_close_sound)
{
int n, objnum, fb_lod;
@@ -811,22 +807,11 @@ int fireball_create( vec3d * pos, int fireball_type, int render_type, int parent
}
if ( (Num_fireballs >= MAX_FIREBALLS) || (Num_objects >= MAX_OBJECTS) ) {
// who cares if we don't create a spark.
// JAS - Should this code be in? Is it better to remove an old spark
// and start a new one, or just not start the new one?
//if ( fd->type == FIREBALL_TYPE_SMALL ) {
// return -1;
//}
//mprintf(( "Out of fireball slots, trying to free one up!\n" ));
// out of slots, so free one up.
n = fireball_free_one();
if ( n < 0 ) {
// If there's still no free slots, then exit
//mprintf(( "ERROR: Couldn't free one up!!\n" ));
if ( n < 0 ) {
return -1;
} else {
//mprintf(( "Freed one up just fine!!\n" ));
}
} else {
for ( n = 0; n < MAX_FIREBALLS; n++ ) {
@@ -850,11 +835,6 @@ int fireball_create( vec3d * pos, int fireball_type, int render_type, int parent
// if this is a warpout fireball, never go higher than LOD 1
if(fireball_type == FIREBALL_WARP){
/*
if(fb_lod > 1){
fb_lod = 1;
}
*/
fb_lod = MAX_WARP_LOD;
}
fl = &fd->lod[fb_lod];
@@ -922,7 +902,9 @@ int fireball_create( vec3d * pos, int fireball_type, int render_type, int parent
}
if ( fb->fireball_render_type == FIREBALL_WARP_EFFECT ) {
Assert( warp_lifetime > 4.0f ); // Warp lifetime must be at least 4 seconds!
Assert( warp_lifetime >= 4.0f ); // Warp lifetime must be at least 4 seconds!
if ( warp_lifetime < 4.0f )
warp_lifetime = 4.0f;
fb->total_time = warp_lifetime; // in seconds
} else {
fb->total_time = i2fl(fl->num_frames) / fl->fps; // in seconds
@@ -947,11 +929,9 @@ int fireball_create( vec3d * pos, int fireball_type, int render_type, int parent
return objnum;
}
// -----------------------------------------------------------------
// fireball_close()
//
// Called at game shutdown to clean up the fireball system
//
/**
* Called at game shutdown to clean up the fireball system
*/
void fireball_close()
{
if ( !fireballs_inited )
@@ -960,20 +940,6 @@ void fireball_close()
fireball_delete_all();
}
// -----------------------------------------------------------------
// fireball_level_close()
//
// Called when a mission ends... frees up any animations that might
// be partially played
//
void fireball_level_close()
{
if ( !fireballs_inited )
return;
fireball_delete_all();
}
void fireballs_page_in()
{
int i, idx;
@@ -1042,3 +1008,27 @@ int fireball_ship_explosion_type(ship_info *sip)
return index;
}
float fireball_wormhole_intensity( object *obj )
{
int num, objnum;
fireball *fb;
num = obj->instance;
objnum = OBJ_INDEX(obj);
Assertion( Fireballs[num].objnum == objnum, "Basic sanity check. Fireballs[num].objnum (%d) should == objnum (%d)", Fireballs[num].objnum, objnum );
fb = &Fireballs[num];
float t = fb->time_elapsed;
float rad;
if ( t < WARPHOLE_GROW_TIME ) {
rad = (float)pow(t/WARPHOLE_GROW_TIME,0.4f);
} else if ( t < fb->total_time - WARPHOLE_GROW_TIME ) {
rad = 1;
} else {
rad = (float)pow((fb->total_time - t)/WARPHOLE_GROW_TIME,0.4f);
}
return rad;
}
+4 -3
View File
@@ -36,6 +36,7 @@ struct ship_info;
#define FIREBALL_NUM_LARGE_EXPLOSIONS 2
extern int fireball_used[MAX_FIREBALL_TYPES];
extern int Num_fireball_types;
// all this moved here by Goober5000 because it makes more sense in the H file
typedef struct fireball_lod {
@@ -76,7 +77,6 @@ typedef struct fireball {
void fireball_init();
void fireball_render(object * obj);
void fireball_delete( object * obj );
void fireball_process_pre(object * obj, float frame_time);
void fireball_process_post(object * obj, float frame_time);
// reversed is for warp_in/out effects
@@ -85,8 +85,6 @@ void fireball_process_post(object * obj, float frame_time);
int fireball_create(vec3d *pos, int fireball_type, int render_type, int parent_obj, float size, int reversed=0, vec3d *velocity=NULL, float warp_lifetime=0.0f, int ship_class=-1, matrix *orient=NULL, int low_res=0, int extra_flags=0, int warp_open_sound=-1, int warp_close_sound=-1);
void fireball_render_plane(int plane);
void fireball_close();
void fireball_level_close();
void fireball_preload(); // page in warpout effect data
// Returns 1 if you can remove this fireball
int fireball_is_perishable(object * obj);
@@ -106,6 +104,9 @@ void fireball_get_color(int idx, float *red, float *green, float *blue);
// returns the index of the fireball bitmap for this ship. -1 if there is none.
int fireball_ship_explosion_type(ship_info *sip);
// returns the intensity of a wormhole
float fireball_wormhole_intensity( object *obj );
// internal function to draw warp grid.
extern void warpin_render(object *obj, matrix *orient, vec3d *pos, int texture_bitmap_num, float radius, float life_percent, float max_radius, int warp_3d = 0 );
+17 -8
View File
@@ -32,8 +32,8 @@ void draw_face( vertex *v1, vertex *v2, vertex *v3 )
vec3d norm;
vertex *vertlist[3];
vm_vec_perp(&norm,(vec3d *)&v1->x, (vec3d *)&v2->x, (vec3d *)&v3->x);
if ( vm_vec_dot(&norm, (vec3d *)&v1->x ) >= 0.0 ) {
vm_vec_perp(&norm,&v1->world, &v2->world, &v3->world);
if ( vm_vec_dot(&norm, &v1->world ) >= 0.0 ) {
vertlist[0] = v3;
vertlist[1] = v2;
vertlist[2] = v1;
@@ -92,7 +92,7 @@ void warpin_render(object *obj, matrix *orient, vec3d *pos, int texture_bitmap_n
}
vecs[4] = center;
verts[4].u = 0.5f; verts[4].v = 0.5f;
verts[4].texture_position.u = 0.5f; verts[4].texture_position.v = 0.5f;
if (Cmdline_nohtl) {
g3_rotate_vertex( &verts[4], &vecs[4] );
@@ -141,11 +141,20 @@ void warpin_render(object *obj, matrix *orient, vec3d *pos, int texture_bitmap_n
// vm_vec_scale_add( &vecs[4], ¢er, &orient->vec.fvec, -Grid_depth );
vecs[4] = center;
verts[0].u = 0.01f; verts[0].v = 0.01f;
verts[1].u = 0.99f; verts[1].v = 0.01f;
verts[2].u = 0.99f; verts[2].v = 0.99f;
verts[3].u = 0.01f; verts[3].v = 0.99f;
verts[4].u = 0.5f; verts[4].v = 0.5f;
verts[0].texture_position.u = 0.01f;
verts[0].texture_position.v = 0.01f;
verts[1].texture_position.u = 0.99f;
verts[1].texture_position.v = 0.01f;
verts[2].texture_position.u = 0.99f;
verts[2].texture_position.v = 0.99f;
verts[3].texture_position.u = 0.01f;
verts[3].texture_position.v = 0.99f;
verts[4].texture_position.u = 0.5f;
verts[4].texture_position.v = 0.5f;
if (Cmdline_nohtl) {
g3_rotate_vertex( &verts[0], &vecs[0] );
+406 -406
View File
@@ -1,406 +1,406 @@
/*
* Created by Hassan "Karajorma" Kazmi for the FreeSpace2 Source Code Project.
* You may not sell or otherwise commercially exploit the source or things you
* create based on the source.
*/
// AltShipClassDlg.cpp : implementation file
//
#include "stdafx.h"
#include "fred.h"
#include "AltShipClassDlg.h"
#include "globalincs/linklist.h"
#include "ship/ship.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// AltShipClassDlg dialog
AltShipClassDlg::AltShipClassDlg(CWnd* pParent /*=NULL*/)
: CDialog(AltShipClassDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(AltShipClassDlg)
m_selected_variable = -1;
m_selected_class = -1;
//}}AFX_DATA_INIT
multi_edit = false;
player_ships_only = true;
num_string_variables = 0;
memset(string_variable_indices, -1, sizeof (int)*MAX_SEXP_VARIABLES);
memset(ship_class_indices, -1, sizeof (int)*MAX_SHIP_CLASSES);
}
void AltShipClassDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(AltShipClassDlg)
DDX_Control(pDX, IDC_DEFAULT_TO_CLASS, m_default_to_class);
DDX_Control(pDX, IDC_ALT_CLASS_LIST, m_alt_class_list);
DDX_Control(pDX, IDC_SET_FROM_SHIP_CLASS, m_set_from_ship_class);
DDX_Control(pDX, IDC_SET_FROM_VARIABLES, m_set_from_variables);
DDX_CBIndex(pDX, IDC_SET_FROM_VARIABLES, m_selected_variable);
DDX_CBIndex(pDX, IDC_SET_FROM_SHIP_CLASS, m_selected_class);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(AltShipClassDlg, CDialog)
//{{AFX_MSG_MAP(AltShipClassDlg)
ON_BN_CLICKED(IDC_ALT_CLASS_ADD, OnAltClassAdd)
ON_BN_CLICKED(IDC_ALT_CLASS_INSERT, OnAltClassInsert)
ON_BN_CLICKED(IDC_ALT_CLASS_DELETE, OnAltClassDelete)
ON_BN_CLICKED(IDC_ALT_CLASS_UP, OnMoveUp)
ON_BN_CLICKED(IDC_ALT_CLASS_DOWN, OnMoveDown)
ON_CBN_SELENDOK(IDC_SET_FROM_SHIP_CLASS, OnSelendokSetFromShipClass)
ON_CBN_SELENDOK(IDC_SET_FROM_VARIABLES, OnSelendokSetFromVariables)
ON_LBN_SELCHANGE(IDC_ALT_CLASS_LIST, OnSelchangeAltClassList)
ON_BN_CLICKED(IDC_DEFAULT_TO_CLASS, OnDefaultToClass)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// AltShipClassDlg message handlers
BOOL AltShipClassDlg::OnInitDialog()
{
int i, count;
char buff[TOKEN_LENGTH + TOKEN_LENGTH + 2]; // VariableName[VariableValue]
CDialog::OnInitDialog();
// have we got multiple selected ships?
num_selected_ships = 0;
object *objp;
objp = GET_FIRST(&obj_used_list);
while (objp != END_OF_LIST(&obj_used_list)) {
if ((objp->type == OBJ_START) || (objp->type == OBJ_SHIP)) {
if (objp->flags & OF_MARKED) {
m_selected_ships[num_selected_ships++] = objp->instance;
}
}
objp = GET_NEXT(objp);
}
Assert (num_selected_ships > 0);
Assert (Objects[cur_object_index].flags & OF_MARKED);
if (num_selected_ships > 1)
{
multi_edit = true;
}
// Fill the variable combo box
m_set_from_variables.ResetContent();
m_set_from_variables.AddString("Set From Ship Class");
for (i=0; i < MAX_SEXP_VARIABLES; i++)
{
if (Sexp_variables[i].type & SEXP_VARIABLE_STRING)
{
sprintf(buff, "%s[%s]", Sexp_variables[i].variable_name, Sexp_variables[i].text);
m_set_from_variables.AddString(buff);
string_variable_indices[num_string_variables++] = i;
}
}
m_set_from_variables.SetCurSel(0);
if (!num_string_variables) {
m_set_from_variables.EnableWindow(FALSE);
}
// Fill the ship classes combo box
m_set_from_ship_class.ResetContent();
// Add the default entry if we need one followed by all the ship classes
if (num_string_variables) {
m_set_from_ship_class.AddString("Set From Variable");
}
count = 0;
for (i=0; i<Num_ship_classes; i++)
{
if (player_ships_only && !(Ship_info[i].flags & SIF_PLAYER_SHIP)) {
continue;
}
ship_class_indices[count++] = i;
m_set_from_ship_class.AddString(Ship_info[i].name);
}
m_set_from_ship_class.SetCurSel(num_string_variables?1:0); // Set to the first ship class
// Set up the actual list of alt classes
alt_class_pool.clear();
alt_class_pool = Ships[Objects[cur_object_index].instance].s_alt_classes;
alt_class_list_rebuild();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void AltShipClassDlg::alt_class_list_rebuild()
{
int i, j;
char buff[TOKEN_LENGTH + TOKEN_LENGTH + 2]; // VariableName[VariableValue]
j = m_alt_class_list.GetCount();
for ( i=0; i < j ; i++) {
m_alt_class_list.DeleteString(0);
}
for (i = 0; i < (int)alt_class_pool.size() ; i++) {
// Default classes should be at the end of the list
if(alt_class_pool[i].default_to_this_class && (i < (int)alt_class_pool.size() - 1) ) {
// Int3();
// TO DO : we should fix this.
}
if (alt_class_pool[i].variable_index != -1) {
Assert (alt_class_pool[i].variable_index > -1 && alt_class_pool[i].variable_index < MAX_SEXP_VARIABLES);
Assert (Sexp_variables[alt_class_pool[i].variable_index].type & SEXP_VARIABLE_STRING);
sprintf(buff, "%s[%s]", Sexp_variables[alt_class_pool[i].variable_index].variable_name, Sexp_variables[alt_class_pool[i].variable_index].text);
// add it to the list
m_alt_class_list.AddString(buff);
}
else {
if (alt_class_pool[i].ship_class >= 0 && alt_class_pool[i].ship_class < MAX_SHIP_CLASSES) {
m_alt_class_list.AddString(Ship_info[alt_class_pool[i].ship_class].name);
}
else {
m_alt_class_list.AddString("Invalid Ship Class");
Int3();
}
}
}
}
void AltShipClassDlg::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
void AltShipClassDlg::OnOK()
{
// TODO: Add extra validation here
for (int i=0; i < num_selected_ships; i++) {
Ships[m_selected_ships[i]].s_alt_classes = alt_class_pool;
}
CDialog::OnOK();
}
void AltShipClassDlg::OnAltClassAdd()
{
alt_class new_list_item;
alt_class_update_entry(new_list_item);
alt_class_pool.push_back(new_list_item);
alt_class_list_rebuild();
}
void AltShipClassDlg::OnAltClassInsert()
{
int index;
alt_class new_list_item;
alt_class_update_entry(new_list_item);
index = m_alt_class_list.GetCurSel();
// If nothing is selected just add it
if ( index == -1) {
alt_class_pool.push_back(new_list_item);
}
// Stick it in front of the current selection
else {
alt_class_pool.insert(alt_class_pool.begin() + index, new_list_item );
}
alt_class_list_rebuild();
// If we inserted the user will probably want to edit the selection
if (index > -1) {
m_alt_class_list.SetCurSel(index);
}
}
// Updates the currently selected list entry
void AltShipClassDlg::alt_class_update_entry(alt_class &list_item)
{
int index;
// Add a string variable to the list
if (num_string_variables && m_set_from_variables.GetCurSel() > 0) {
index = string_variable_indices[m_set_from_variables.GetCurSel() -1];
Assert (index >= 0);
list_item.variable_index = index;
list_item.ship_class = ship_info_lookup(Sexp_variables[index].text);
}
// Add a ship class to the list
else {
index = m_set_from_ship_class.GetCurSel();
// Correct the index if the first entry isn't actually a ship class
if (num_string_variables) {
Assert (index > 0);
index--;
}
list_item.variable_index = -1;
list_item.ship_class = ship_class_indices[index];
}
// check the default tickbox
list_item.default_to_this_class = m_default_to_class.GetCheck() ? true:false;
}
void AltShipClassDlg::OnAltClassDelete()
{
int index = m_alt_class_list.GetCurSel();
// Nothing selected
if (index == -1) {
return;
}
Assert (index < (int) alt_class_pool.size());
alt_class_pool.erase(alt_class_pool.begin()+index);
alt_class_list_rebuild();
}
void AltShipClassDlg::OnMoveUp()
{
int index = m_alt_class_list.GetCurSel();
// Nothing selected or already at the top
if (index < 1) {
return;
}
std::swap(alt_class_pool[index], alt_class_pool[index-1]);
alt_class_list_rebuild();
m_alt_class_list.SetCurSel(index-1);
}
void AltShipClassDlg::OnMoveDown()
{
int index = m_alt_class_list.GetCurSel();
// Nothing selected or already at the bottom
if (index == -1 || (index >= m_alt_class_list.GetCount() - 1) ) {
return;
}
std::swap(alt_class_pool[index], alt_class_pool[index++]);
alt_class_list_rebuild();
m_alt_class_list.SetCurSel(index);
}
void AltShipClassDlg::OnSelendokSetFromShipClass()
{
int current_selection;
if (m_set_from_ship_class.GetCurSel() == 0 && num_string_variables) {
m_set_from_variables.SetCurSel(1);
}
else {
m_set_from_variables.SetCurSel(0);
}
// if a list entry is selected we should update it
current_selection = m_alt_class_list.GetCurSel();
if (current_selection >= 0) {
alt_class_update_entry(alt_class_pool[m_alt_class_list.GetCurSel()]);
alt_class_list_rebuild();
}
}
void AltShipClassDlg::OnSelendokSetFromVariables()
{
int current_selection;
if (m_set_from_variables.GetCurSel() == 0) {
m_set_from_ship_class.SetCurSel(num_string_variables ? 1 : 0);
}
else {
m_set_from_ship_class.SetCurSel(0);
}
// if a list entry is selected we should update it
current_selection = m_alt_class_list.GetCurSel();
if (current_selection >= 0) {
alt_class_update_entry(alt_class_pool[m_alt_class_list.GetCurSel()]);
alt_class_list_rebuild();
}
}
void AltShipClassDlg::OnSelchangeAltClassList()
{
int i;
int variable_selection = 0;
int ship_selection = 0;
int index = m_alt_class_list.GetCurSel();
// Selected nothing
if (index == -1) {
return;
}
// If we have a variable selected
if (alt_class_pool[index].variable_index != -1) {
for (i=0; i < MAX_SEXP_VARIABLES; i++)
{
if (string_variable_indices[i] == alt_class_pool[index].variable_index) {
variable_selection = i+1;
break;
}
}
}
// Ship selected
else {
for (i=0; i < MAX_SHIP_CLASSES; i++) {
if (ship_class_indices[i] == alt_class_pool[index].ship_class) {
ship_selection = i;
break;
}
}
// if we have string variables in the mission the first entry on the list won't be a ship
if (num_string_variables) {
ship_selection++;
}
}
m_set_from_variables.SetCurSel(variable_selection);
m_set_from_ship_class.SetCurSel(ship_selection);
m_default_to_class.SetCheck(alt_class_pool[index].default_to_this_class ? 1:0);
}
void AltShipClassDlg::OnDefaultToClass()
{
int index = m_alt_class_list.GetCurSel();
// Nothing selected
if (index == -1) {
return;
}
alt_class_pool[index].default_to_this_class = m_default_to_class.GetCheck() ? true:false;
}
/*
* Created by Hassan "Karajorma" Kazmi for the FreeSpace2 Source Code Project.
* You may not sell or otherwise commercially exploit the source or things you
* create based on the source.
*/
// AltShipClassDlg.cpp : implementation file
//
#include "stdafx.h"
#include "fred.h"
#include "AltShipClassDlg.h"
#include "globalincs/linklist.h"
#include "ship/ship.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// AltShipClassDlg dialog
AltShipClassDlg::AltShipClassDlg(CWnd* pParent /*=NULL*/)
: CDialog(AltShipClassDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(AltShipClassDlg)
m_selected_variable = -1;
m_selected_class = -1;
//}}AFX_DATA_INIT
multi_edit = false;
player_ships_only = true;
num_string_variables = 0;
memset(string_variable_indices, -1, sizeof (int)*MAX_SEXP_VARIABLES);
memset(ship_class_indices, -1, sizeof (int)*MAX_SHIP_CLASSES);
}
void AltShipClassDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(AltShipClassDlg)
DDX_Control(pDX, IDC_DEFAULT_TO_CLASS, m_default_to_class);
DDX_Control(pDX, IDC_ALT_CLASS_LIST, m_alt_class_list);
DDX_Control(pDX, IDC_SET_FROM_SHIP_CLASS, m_set_from_ship_class);
DDX_Control(pDX, IDC_SET_FROM_VARIABLES, m_set_from_variables);
DDX_CBIndex(pDX, IDC_SET_FROM_VARIABLES, m_selected_variable);
DDX_CBIndex(pDX, IDC_SET_FROM_SHIP_CLASS, m_selected_class);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(AltShipClassDlg, CDialog)
//{{AFX_MSG_MAP(AltShipClassDlg)
ON_BN_CLICKED(IDC_ALT_CLASS_ADD, OnAltClassAdd)
ON_BN_CLICKED(IDC_ALT_CLASS_INSERT, OnAltClassInsert)
ON_BN_CLICKED(IDC_ALT_CLASS_DELETE, OnAltClassDelete)
ON_BN_CLICKED(IDC_ALT_CLASS_UP, OnMoveUp)
ON_BN_CLICKED(IDC_ALT_CLASS_DOWN, OnMoveDown)
ON_CBN_SELENDOK(IDC_SET_FROM_SHIP_CLASS, OnSelendokSetFromShipClass)
ON_CBN_SELENDOK(IDC_SET_FROM_VARIABLES, OnSelendokSetFromVariables)
ON_LBN_SELCHANGE(IDC_ALT_CLASS_LIST, OnSelchangeAltClassList)
ON_BN_CLICKED(IDC_DEFAULT_TO_CLASS, OnDefaultToClass)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// AltShipClassDlg message handlers
BOOL AltShipClassDlg::OnInitDialog()
{
int i, count;
char buff[TOKEN_LENGTH + TOKEN_LENGTH + 2]; // VariableName[VariableValue]
CDialog::OnInitDialog();
// have we got multiple selected ships?
num_selected_ships = 0;
object *objp;
objp = GET_FIRST(&obj_used_list);
while (objp != END_OF_LIST(&obj_used_list)) {
if ((objp->type == OBJ_START) || (objp->type == OBJ_SHIP)) {
if (objp->flags & OF_MARKED) {
m_selected_ships[num_selected_ships++] = objp->instance;
}
}
objp = GET_NEXT(objp);
}
Assert (num_selected_ships > 0);
Assert (Objects[cur_object_index].flags & OF_MARKED);
if (num_selected_ships > 1)
{
multi_edit = true;
}
// Fill the variable combo box
m_set_from_variables.ResetContent();
m_set_from_variables.AddString("Set From Ship Class");
for (i=0; i < MAX_SEXP_VARIABLES; i++)
{
if (Sexp_variables[i].type & SEXP_VARIABLE_STRING)
{
sprintf(buff, "%s[%s]", Sexp_variables[i].variable_name, Sexp_variables[i].text);
m_set_from_variables.AddString(buff);
string_variable_indices[num_string_variables++] = i;
}
}
m_set_from_variables.SetCurSel(0);
if (!num_string_variables) {
m_set_from_variables.EnableWindow(FALSE);
}
// Fill the ship classes combo box
m_set_from_ship_class.ResetContent();
// Add the default entry if we need one followed by all the ship classes
if (num_string_variables) {
m_set_from_ship_class.AddString("Set From Variable");
}
count = 0;
for (i=0; i<Num_ship_classes; i++)
{
if (player_ships_only && !(Ship_info[i].flags & SIF_PLAYER_SHIP)) {
continue;
}
ship_class_indices[count++] = i;
m_set_from_ship_class.AddString(Ship_info[i].name);
}
m_set_from_ship_class.SetCurSel(num_string_variables?1:0); // Set to the first ship class
// Set up the actual list of alt classes
alt_class_pool.clear();
alt_class_pool = Ships[Objects[cur_object_index].instance].s_alt_classes;
alt_class_list_rebuild();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void AltShipClassDlg::alt_class_list_rebuild()
{
int i, j;
char buff[TOKEN_LENGTH + TOKEN_LENGTH + 2]; // VariableName[VariableValue]
j = m_alt_class_list.GetCount();
for ( i=0; i < j ; i++) {
m_alt_class_list.DeleteString(0);
}
for (i = 0; i < (int)alt_class_pool.size() ; i++) {
// Default classes should be at the end of the list
if(alt_class_pool[i].default_to_this_class && (i < (int)alt_class_pool.size() - 1) ) {
// Int3();
// TO DO : we should fix this.
}
if (alt_class_pool[i].variable_index != -1) {
Assert (alt_class_pool[i].variable_index > -1 && alt_class_pool[i].variable_index < MAX_SEXP_VARIABLES);
Assert (Sexp_variables[alt_class_pool[i].variable_index].type & SEXP_VARIABLE_STRING);
sprintf(buff, "%s[%s]", Sexp_variables[alt_class_pool[i].variable_index].variable_name, Sexp_variables[alt_class_pool[i].variable_index].text);
// add it to the list
m_alt_class_list.AddString(buff);
}
else {
if (alt_class_pool[i].ship_class >= 0 && alt_class_pool[i].ship_class < MAX_SHIP_CLASSES) {
m_alt_class_list.AddString(Ship_info[alt_class_pool[i].ship_class].name);
}
else {
m_alt_class_list.AddString("Invalid Ship Class");
Int3();
}
}
}
}
void AltShipClassDlg::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
void AltShipClassDlg::OnOK()
{
// TODO: Add extra validation here
for (int i=0; i < num_selected_ships; i++) {
Ships[m_selected_ships[i]].s_alt_classes = alt_class_pool;
}
CDialog::OnOK();
}
void AltShipClassDlg::OnAltClassAdd()
{
alt_class new_list_item;
alt_class_update_entry(new_list_item);
alt_class_pool.push_back(new_list_item);
alt_class_list_rebuild();
}
void AltShipClassDlg::OnAltClassInsert()
{
int index;
alt_class new_list_item;
alt_class_update_entry(new_list_item);
index = m_alt_class_list.GetCurSel();
// If nothing is selected just add it
if ( index == -1) {
alt_class_pool.push_back(new_list_item);
}
// Stick it in front of the current selection
else {
alt_class_pool.insert(alt_class_pool.begin() + index, new_list_item );
}
alt_class_list_rebuild();
// If we inserted the user will probably want to edit the selection
if (index > -1) {
m_alt_class_list.SetCurSel(index);
}
}
// Updates the currently selected list entry
void AltShipClassDlg::alt_class_update_entry(alt_class &list_item)
{
int index;
// Add a string variable to the list
if (num_string_variables && m_set_from_variables.GetCurSel() > 0) {
index = string_variable_indices[m_set_from_variables.GetCurSel() -1];
Assert (index >= 0);
list_item.variable_index = index;
list_item.ship_class = ship_info_lookup(Sexp_variables[index].text);
}
// Add a ship class to the list
else {
index = m_set_from_ship_class.GetCurSel();
// Correct the index if the first entry isn't actually a ship class
if (num_string_variables) {
Assert (index > 0);
index--;
}
list_item.variable_index = -1;
list_item.ship_class = ship_class_indices[index];
}
// check the default tickbox
list_item.default_to_this_class = m_default_to_class.GetCheck() ? true:false;
}
void AltShipClassDlg::OnAltClassDelete()
{
int index = m_alt_class_list.GetCurSel();
// Nothing selected
if (index == -1) {
return;
}
Assert (index < (int) alt_class_pool.size());
alt_class_pool.erase(alt_class_pool.begin()+index);
alt_class_list_rebuild();
}
void AltShipClassDlg::OnMoveUp()
{
int index = m_alt_class_list.GetCurSel();
// Nothing selected or already at the top
if (index < 1) {
return;
}
std::swap(alt_class_pool[index], alt_class_pool[index-1]);
alt_class_list_rebuild();
m_alt_class_list.SetCurSel(index-1);
}
void AltShipClassDlg::OnMoveDown()
{
int index = m_alt_class_list.GetCurSel();
int inext = index + 1;
// Nothing selected or already at the bottom
if (index == -1 || (index >= m_alt_class_list.GetCount() - 1) ) {
return;
}
std::swap(alt_class_pool[index], alt_class_pool[inext]);
alt_class_list_rebuild();
m_alt_class_list.SetCurSel(index);
}
void AltShipClassDlg::OnSelendokSetFromShipClass()
{
int current_selection;
if (m_set_from_ship_class.GetCurSel() == 0 && num_string_variables) {
m_set_from_variables.SetCurSel(1);
}
else {
m_set_from_variables.SetCurSel(0);
}
// if a list entry is selected we should update it
current_selection = m_alt_class_list.GetCurSel();
if (current_selection >= 0) {
alt_class_update_entry(alt_class_pool[m_alt_class_list.GetCurSel()]);
alt_class_list_rebuild();
}
}
void AltShipClassDlg::OnSelendokSetFromVariables()
{
int current_selection;
if (m_set_from_variables.GetCurSel() == 0) {
m_set_from_ship_class.SetCurSel(num_string_variables ? 1 : 0);
}
else {
m_set_from_ship_class.SetCurSel(0);
}
// if a list entry is selected we should update it
current_selection = m_alt_class_list.GetCurSel();
if (current_selection >= 0) {
alt_class_update_entry(alt_class_pool[m_alt_class_list.GetCurSel()]);
alt_class_list_rebuild();
}
}
void AltShipClassDlg::OnSelchangeAltClassList()
{
int i;
int variable_selection = 0;
int ship_selection = 0;
int index = m_alt_class_list.GetCurSel();
// Selected nothing
if (index == -1) {
return;
}
// If we have a variable selected
if (alt_class_pool[index].variable_index != -1) {
for (i=0; i < MAX_SEXP_VARIABLES; i++)
{
if (string_variable_indices[i] == alt_class_pool[index].variable_index) {
variable_selection = i+1;
break;
}
}
}
// Ship selected
else {
for (i=0; i < MAX_SHIP_CLASSES; i++) {
if (ship_class_indices[i] == alt_class_pool[index].ship_class) {
ship_selection = i;
break;
}
}
// if we have string variables in the mission the first entry on the list won't be a ship
if (num_string_variables) {
ship_selection++;
}
}
m_set_from_variables.SetCurSel(variable_selection);
m_set_from_ship_class.SetCurSel(ship_selection);
m_default_to_class.SetCheck(alt_class_pool[index].default_to_this_class ? 1:0);
}
void AltShipClassDlg::OnDefaultToClass()
{
int index = m_alt_class_list.GetCurSel();
// Nothing selected
if (index == -1) {
return;
}
alt_class_pool[index].default_to_this_class = m_default_to_class.GetCheck() ? true:false;
}
+86 -86
View File
@@ -1,86 +1,86 @@
/*
* Created by Hassan "Karajorma" Kazmi for the FreeSpace2 Source Code Project.
* You may not sell or otherwise commercially exploit the source or things you
* create based on the source.
*/
#if !defined(AFX_AltShipClassDlg_H__2FE2C917_C7DA_4C05_A11F_DCC46BFB26BB__INCLUDED_)
#define AFX_AltShipClassDlg_H__2FE2C917_C7DA_4C05_A11F_DCC46BFB26BB__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// AltShipClassDlg.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// AltShipClassDlg dialog
class AltShipClassDlg : public CDialog
{
// Construction
public:
AltShipClassDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(AltShipClassDlg)
enum { IDD = IDD_ALT_SHIP_CLASS };
CButton m_default_to_class;
CListBox m_alt_class_list;
CComboBox m_set_from_ship_class;
CComboBox m_set_from_variables;
int m_selected_variable;
int m_selected_class;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(AltShipClassDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(AltShipClassDlg)
virtual BOOL OnInitDialog();
virtual void OnCancel();
virtual void OnOK();
afx_msg void OnAltClassAdd();
afx_msg void OnAltClassInsert();
afx_msg void OnAltClassDelete();
afx_msg void OnMoveUp();
afx_msg void OnMoveDown();
afx_msg void OnSelendokSetFromShipClass();
afx_msg void OnSelendokSetFromVariables();
afx_msg void OnSelchangeAltClassList();
afx_msg void OnDefaultToClass();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
bool player_ships_only; // Whether we only add player ships to the alt classes or if we can add any ship
SCP_vector<alt_class> alt_class_pool;
int num_string_variables; // Number of string variables in the mission
int string_variable_indices[MAX_SEXP_VARIABLES]; // maps string variables to their index in Sexp_variables
int ship_class_indices[MAX_SHIP_CLASSES]; // maps ships in the ships combobox to their index in Ship_info
// variables to handle selection of multiple ships
bool multi_edit;
int m_selected_ships[MAX_SHIPS];
int num_selected_ships;
void AltShipClassDlg::alt_class_list_rebuild();
void AltShipClassDlg::alt_class_update_entry(alt_class &list_item);
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_AltShipClassDlg_H__2FE2C917_C7DA_4C05_A11F_DCC46BFB26BB__INCLUDED_)
/*
* Created by Hassan "Karajorma" Kazmi for the FreeSpace2 Source Code Project.
* You may not sell or otherwise commercially exploit the source or things you
* create based on the source.
*/
#if !defined(AFX_AltShipClassDlg_H__2FE2C917_C7DA_4C05_A11F_DCC46BFB26BB__INCLUDED_)
#define AFX_AltShipClassDlg_H__2FE2C917_C7DA_4C05_A11F_DCC46BFB26BB__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// AltShipClassDlg.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// AltShipClassDlg dialog
class AltShipClassDlg : public CDialog
{
// Construction
public:
AltShipClassDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(AltShipClassDlg)
enum { IDD = IDD_ALT_SHIP_CLASS };
CButton m_default_to_class;
CListBox m_alt_class_list;
CComboBox m_set_from_ship_class;
CComboBox m_set_from_variables;
int m_selected_variable;
int m_selected_class;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(AltShipClassDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(AltShipClassDlg)
virtual BOOL OnInitDialog();
virtual void OnCancel();
virtual void OnOK();
afx_msg void OnAltClassAdd();
afx_msg void OnAltClassInsert();
afx_msg void OnAltClassDelete();
afx_msg void OnMoveUp();
afx_msg void OnMoveDown();
afx_msg void OnSelendokSetFromShipClass();
afx_msg void OnSelendokSetFromVariables();
afx_msg void OnSelchangeAltClassList();
afx_msg void OnDefaultToClass();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
bool player_ships_only; // Whether we only add player ships to the alt classes or if we can add any ship
SCP_vector<alt_class> alt_class_pool;
int num_string_variables; // Number of string variables in the mission
int string_variable_indices[MAX_SEXP_VARIABLES]; // maps string variables to their index in Sexp_variables
int ship_class_indices[MAX_SHIP_CLASSES]; // maps ships in the ships combobox to their index in Ship_info
// variables to handle selection of multiple ships
bool multi_edit;
int m_selected_ships[MAX_SHIPS];
int num_selected_ships;
void AltShipClassDlg::alt_class_list_rebuild();
void AltShipClassDlg::alt_class_update_entry(alt_class &list_item);
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_AltShipClassDlg_H__2FE2C917_C7DA_4C05_A11F_DCC46BFB26BB__INCLUDED_)
+115 -116
View File
@@ -1,116 +1,115 @@
// FictionViewerDlg.cpp : implementation file
//
#include "stdafx.h"
#include "fred.h"
#include "FictionViewerDlg.h"
#include "missionui/fictionviewer.h"
#include "gamesnd/eventmusic.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// FictionViewerDlg dialog
FictionViewerDlg::FictionViewerDlg(CWnd* pParent /*=NULL*/)
: CDialog(FictionViewerDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(FictionViewerDlg)
m_story_file = _T("");
m_font_file = _T("");
m_fiction_music = 0;
//}}AFX_DATA_INIT
}
void FictionViewerDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(FictionViewerDlg)
DDX_Text(pDX, IDC_STORY_FILE, m_story_file);
DDX_Text(pDX, IDC_FONT_FILE, m_font_file);
DDX_CBIndex(pDX, IDC_FICTION_MUSIC, m_fiction_music);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(FictionViewerDlg, CDialog)
//{{AFX_MSG_MAP(FictionViewerDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// FictionViewerDlg message handlers
BOOL FictionViewerDlg::OnInitDialog()
{
int i;
CComboBox *box;
box = (CComboBox *) GetDlgItem(IDC_FICTION_MUSIC);
box->AddString("None");
for (i=0; i<Num_music_files; i++){
box->AddString(Spooled_music[i].name);
}
// init variables
m_story_file = _T(fiction_file());
m_font_file = _T(fiction_font());
m_fiction_music = Mission_music[SCORE_FICTION_VIEWER] + 1;
CDialog::OnInitDialog();
UpdateData(FALSE);
return TRUE;
}
void FictionViewerDlg::OnOK()
{
UpdateData(TRUE);
// load it up
fiction_viewer_reset();
fiction_viewer_load((char *)(LPCSTR) m_story_file, (char *)(LPCSTR) m_font_file);
// set music
Mission_music[SCORE_FICTION_VIEWER] = m_fiction_music - 1;
CDialog::OnOK();
}
void FictionViewerDlg::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
void FictionViewerDlg::OnClose()
{
int z;
UpdateData(TRUE);
if (query_modified()) {
z = MessageBox("Do you want to keep your changes?", "Close", MB_ICONQUESTION | MB_YESNOCANCEL);
if (z == IDCANCEL){
return;
}
if (z == IDYES) {
OnOK();
return;
}
}
CDialog::OnClose();
}
int FictionViewerDlg::query_modified()
{
return strcmp(m_story_file, fiction_file()) || strcmp(m_font_file, fiction_font()) || m_fiction_music != (Mission_music[SCORE_FICTION_VIEWER] + 1);
}
// FictionViewerDlg.cpp : implementation file
//
#include "stdafx.h"
#include "fred.h"
#include "FictionViewerDlg.h"
#include "missionui/fictionviewer.h"
#include "gamesnd/eventmusic.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// FictionViewerDlg dialog
FictionViewerDlg::FictionViewerDlg(CWnd* pParent /*=NULL*/)
: CDialog(FictionViewerDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(FictionViewerDlg)
m_story_file = _T("");
m_font_file = _T("");
m_fiction_music = 0;
//}}AFX_DATA_INIT
}
void FictionViewerDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(FictionViewerDlg)
DDX_Text(pDX, IDC_STORY_FILE, m_story_file);
DDX_Text(pDX, IDC_FONT_FILE, m_font_file);
DDX_CBIndex(pDX, IDC_FICTION_MUSIC, m_fiction_music);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(FictionViewerDlg, CDialog)
//{{AFX_MSG_MAP(FictionViewerDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// FictionViewerDlg message handlers
BOOL FictionViewerDlg::OnInitDialog()
{
int i;
CComboBox *box;
box = (CComboBox *) GetDlgItem(IDC_FICTION_MUSIC);
box->AddString("None");
for (i=0; i<Num_music_files; i++){
box->AddString(Spooled_music[i].name);
}
// init variables
m_story_file = _T(fiction_file());
m_font_file = _T(fiction_font());
m_fiction_music = Mission_music[SCORE_FICTION_VIEWER] + 1;
CDialog::OnInitDialog();
UpdateData(FALSE);
return TRUE;
}
void FictionViewerDlg::OnOK()
{
UpdateData(TRUE);
// load it up
fiction_viewer_reset();
fiction_viewer_load((char *)(LPCSTR) m_story_file, (char *)(LPCSTR) m_font_file);
// set music
Mission_music[SCORE_FICTION_VIEWER] = m_fiction_music - 1;
CDialog::OnOK();
}
void FictionViewerDlg::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
void FictionViewerDlg::OnClose()
{
int z;
UpdateData(TRUE);
if (query_modified()) {
z = MessageBox("Do you want to keep your changes?", "Close", MB_ICONQUESTION | MB_YESNOCANCEL);
if (z == IDCANCEL){
return;
}
if (z == IDYES) {
OnOK();
return;
}
}
CDialog::OnClose();
}
int FictionViewerDlg::query_modified()
{
return strcmp(m_story_file, fiction_file()) || strcmp(m_font_file, fiction_font()) || m_fiction_music != (Mission_music[SCORE_FICTION_VIEWER] + 1);
}
+52 -52
View File
@@ -1,52 +1,52 @@
#if !defined(AFX_FICTIONVIEWERDLG_H__46BAD1B6_F9DC_4414_9C33_18EC17FD491F__INCLUDED_)
#define AFX_FICTIONVIEWERDLG_H__46BAD1B6_F9DC_4414_9C33_18EC17FD491F__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// FictionViewerDlg.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// FictionViewerDlg dialog
class FictionViewerDlg : public CDialog
{
// Construction
public:
FictionViewerDlg(CWnd* pParent = NULL); // standard constructor
int query_modified();
void OnOK();
void OnCancel();
// Dialog Data
//{{AFX_DATA(FictionViewerDlg)
enum { IDD = IDD_FICTION_VIEWER };
CString m_story_file;
CString m_font_file;
int m_fiction_music;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(FictionViewerDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(FictionViewerDlg)
virtual BOOL OnInitDialog();
afx_msg void OnClose();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_FICTIONVIEWERDLG_H__46BAD1B6_F9DC_4414_9C33_18EC17FD491F__INCLUDED_)
#if !defined(AFX_FICTIONVIEWERDLG_H__46BAD1B6_F9DC_4414_9C33_18EC17FD491F__INCLUDED_)
#define AFX_FICTIONVIEWERDLG_H__46BAD1B6_F9DC_4414_9C33_18EC17FD491F__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// FictionViewerDlg.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// FictionViewerDlg dialog
class FictionViewerDlg : public CDialog
{
// Construction
public:
FictionViewerDlg(CWnd* pParent = NULL); // standard constructor
int query_modified();
void OnOK();
void OnCancel();
// Dialog Data
//{{AFX_DATA(FictionViewerDlg)
enum { IDD = IDD_FICTION_VIEWER };
CString m_story_file;
CString m_font_file;
int m_fiction_music;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(FictionViewerDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(FictionViewerDlg)
virtual BOOL OnInitDialog();
afx_msg void OnClose();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_FICTIONVIEWERDLG_H__46BAD1B6_F9DC_4414_9C33_18EC17FD491F__INCLUDED_)
+3 -4
View File
@@ -16,7 +16,6 @@
#include "parse/sexp.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
@@ -154,7 +153,7 @@ void CAddVariableDlg::validate_variable_name(int set_focus)
// Check if any change and not already in list
if ( stricmp(temp_name, "<Variable Name>") ) {
if ( (strlen(temp_name) > 0) && (get_index_sexp_variable_name(LPCTSTR(temp_name)) == -1) ) { //not already in list and length > 0 {
if ( (strlen(temp_name) > 0) && (get_index_sexp_variable_name(LPCTSTR(temp_name)) == -1) ) { //not already in list and length > 0 { //-V805
// Goober5000 - replace spaces with hyphens
if (strchr(temp_name, ' ') != NULL)
{
@@ -175,7 +174,7 @@ void CAddVariableDlg::validate_variable_name(int set_focus)
m_name_validated = true;
} else {
// conflicting variable name
if (strlen(temp_name) == 0) {
if (strlen(temp_name) == 0) { //-V805
edit->SetWindowText("<Variable Name>");
}
m_name_validated = false;
@@ -205,7 +204,7 @@ void CAddVariableDlg::validate_data(int set_focus)
edit->GetWindowText(temp_data);
// check for 0 string length
if (strlen(temp_data) == 0) {
if (strlen(temp_data) == 0) { //-V805
m_data_validated = false;
} else {
if (m_type_number) {
-1
View File
@@ -15,7 +15,6 @@
#include "mission/missiongrid.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
-1
View File
@@ -19,7 +19,6 @@
#include "species_defs/species_defs.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
-1
View File
@@ -7,7 +7,6 @@
#include "ship/ship.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
+18 -12
View File
@@ -26,7 +26,6 @@
#include "mission/missionparse.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
@@ -130,6 +129,8 @@ void bg_bitmap_dlg::DoDataExchange(CDataExchange* pDX)
DDX_Check(pDX, IDC_SKY_FLAG_NO_CULL, m_sky_flag_4);
DDX_Check(pDX, IDC_SKY_FLAG_NO_GLOW, m_sky_flag_5);
DDX_Check(pDX, IDC_SKY_FLAG_CLAMP, m_sky_flag_6);
DDX_Text(pDX, IDC_NEB_FAR_MULTIPLIER, m_neb_far_multi);
DDX_Text(pDX, IDC_NEB_NEAR_MULTIPLIER, m_neb_near_multi);
//}}AFX_DATA_MAP
}
@@ -211,12 +212,12 @@ void bg_bitmap_dlg::create()
m_envmap = _T(The_mission.envmap_name);
for(i=0; i<MAX_NEB2_BITMAPS; i++){
if(strlen(Neb2_bitmap_filenames[i]) > 0){
if(strlen(Neb2_bitmap_filenames[i]) > 0){ //-V805
((CComboBox*)GetDlgItem(IDC_NEB2_TEXTURE))->AddString(Neb2_bitmap_filenames[i]);
}
}
// if we have a texture selected already
if(strlen(Neb2_texture_name) > 0){
if(strlen(Neb2_texture_name) > 0){ //-V805
m_neb2_texture = ((CComboBox*)GetDlgItem(IDC_NEB2_TEXTURE))->SelectString(-1, Neb2_texture_name);
if(m_neb2_texture == CB_ERR){
((CComboBox*)GetDlgItem(IDC_NEB2_TEXTURE))->SetCurSel(0);
@@ -229,8 +230,8 @@ void bg_bitmap_dlg::create()
// setup lightning storm names
((CComboBox*)GetDlgItem(IDC_NEB2_LIGHTNING))->ResetContent();
((CComboBox*)GetDlgItem(IDC_NEB2_LIGHTNING))->AddString(CString("none"));
for(i=0; i<Num_storm_types; i++){
((CComboBox*)GetDlgItem(IDC_NEB2_LIGHTNING))->AddString(CString(Storm_types[i].name));
for(size_t j=0; j<Storm_types.size(); j++){
((CComboBox*)GetDlgItem(IDC_NEB2_LIGHTNING))->AddString(CString(Storm_types[j].name));
}
((CComboBox*)GetDlgItem(IDC_NEB2_LIGHTNING))->SelectString(-1, Mission_parse_storm_name);
@@ -299,7 +300,9 @@ void bg_bitmap_dlg::create()
GetDlgItem(IDC_AMBIENT_G_TEXT)->SetWindowText(buf);
sprintf(buf, "Blue: %d", m_amb_blue.GetPos());
GetDlgItem(IDC_AMBIENT_B_TEXT)->SetWindowText(buf);
m_neb_near_multi = Neb2_fog_near_mult;
m_neb_far_multi = Neb2_fog_far_mult;
UpdateData(FALSE);
OnFullNeb();
@@ -421,6 +424,9 @@ void bg_bitmap_dlg::OnClose()
The_mission.skybox_flags |= MR_FORCE_CLAMP;
}
Neb2_fog_near_mult = m_neb_near_multi;
Neb2_fog_far_mult = m_neb_far_multi;
// close sun data
sun_data_close();
@@ -662,9 +668,9 @@ void bg_bitmap_dlg::sun_data_save_current()
// store the data
strcpy_s(sle->filename, s_name);
sle->ang.p = (float) fl_radian(s_pitch);
sle->ang.b = (float) fl_radian(s_bank);
sle->ang.h = (float) fl_radian(s_heading);
sle->ang.p = (float) fl_radians(s_pitch);
sle->ang.b = (float) fl_radians(s_bank);
sle->ang.h = (float) fl_radians(s_heading);
sle->scale_x = (float) s_scale;
sle->scale_y = 1.0f;
sle->div_x = 1;
@@ -826,9 +832,9 @@ void bg_bitmap_dlg::bitmap_data_save_current()
// store the data
strcpy_s(sle->filename, b_name);
sle->ang.p = (float) fl_radian(b_pitch);
sle->ang.b = (float) fl_radian(b_bank);
sle->ang.h = (float) fl_radian(b_heading);
sle->ang.p = (float) fl_radians(b_pitch);
sle->ang.b = (float) fl_radians(b_bank);
sle->ang.h = (float) fl_radians(b_heading);
sle->scale_x = (float) b_scale_x;
sle->scale_y = (float) b_scale_y;
sle->div_x = b_div_x;
+2
View File
@@ -85,6 +85,8 @@ public:
int m_sky_flag_6;
CString m_skybox_model;
CString m_envmap;
float m_neb_near_multi;
float m_neb_far_multi;
//}}AFX_DATA
// Overrides
+6 -3
View File
@@ -30,7 +30,6 @@
#include "localization/localize.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
@@ -187,7 +186,7 @@ void briefing_editor_dlg::create()
box->AddString(Icon_names[i]);
box = (CComboBox *) GetDlgItem(IDC_TEAM);
for (i=0; i<Num_team_names; i++)
for (i=0; i<Num_iffs; i++)
box->AddString(Iff_info[i].iff_name);
box = (CComboBox *) GetDlgItem(IDC_SHIP_TYPE);
@@ -989,7 +988,11 @@ void briefing_editor_dlg::OnMakeIcon()
if (ship >= 0)
name = Ships[ship].ship_name;
else if (waypoint >= 0)
name = Waypoint_lists[waypoint / 65536].name;
{
waypoint_list *wp_list = find_waypoint_list_with_instance(waypoint);
Assert(wp_list != NULL);
name = wp_list->get_name();
}
else if (jnp != NULL)
name = jnp->get_name_ptr();
else
+72 -72
View File
@@ -23,7 +23,6 @@
#include "mission/missiongoals.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
@@ -46,9 +45,9 @@ campaign_editor::campaign_editor()
m_type = -1;
m_num_players = _T("");
m_desc = _T("");
m_loop_desc = _T("");
m_loop_brief_anim = _T("");
m_loop_brief_sound = _T("");
m_branch_desc = _T("");
m_branch_brief_anim = _T("");
m_branch_brief_sound = _T("");
m_custom_tech_db = FALSE;
//}}AFX_DATA_INIT
@@ -72,14 +71,14 @@ void campaign_editor::DoDataExchange(CDataExchange* pDX)
DDX_CBIndex(pDX, IDC_CAMPAIGN_TYPE, m_type);
DDX_Text(pDX, IDC_NUM_PLAYERS, m_num_players);
DDX_Text(pDX, IDC_DESC2, m_desc);
DDX_Text(pDX, IDC_MISSISON_LOOP_DESC, m_loop_desc);
DDX_Text(pDX, IDC_LOOP_BRIEF_ANIM, m_loop_brief_anim);
DDX_Text(pDX, IDC_LOOP_BRIEF_SOUND, m_loop_brief_sound);
DDX_Text(pDX, IDC_MISSISON_LOOP_DESC, m_branch_desc);
DDX_Text(pDX, IDC_LOOP_BRIEF_ANIM, m_branch_brief_anim);
DDX_Text(pDX, IDC_LOOP_BRIEF_SOUND, m_branch_brief_sound);
DDX_Check(pDX, IDC_CUSTOM_TECH_DB, m_custom_tech_db);
//}}AFX_DATA_MAP
DDV_MaxChars(pDX, m_desc, MISSION_DESC_LENGTH - 1);
DDV_MaxChars(pDX, m_loop_desc, MISSION_DESC_LENGTH - 1);
DDV_MaxChars(pDX, m_branch_desc, MISSION_DESC_LENGTH - 1);
}
BEGIN_MESSAGE_MAP(campaign_editor, CFormView)
@@ -224,10 +223,10 @@ void campaign_editor::initialize( int init_files )
m_desc = _T("");
}
m_loop_desc = _T("");
m_branch_desc = _T("");
m_loop_brief_anim = _T("");
m_loop_brief_sound = _T("");
m_branch_brief_anim = _T("");
m_branch_brief_sound = _T("");
// single player should hide the two dialog items about number of players allowed
if ( m_type == CAMPAIGN_TYPE_SINGLE ) {
@@ -362,7 +361,7 @@ void campaign_editor::load_tree(int save_first)
// insert item into tree
int image, sel_image;
if (Links[i].mission_loop) {
if (Links[i].is_mission_loop || Links[i].is_mission_fork) {
image = BITMAP_BLUE_DOT;
sel_image = BITMAP_GREEN_DOT;
} else {
@@ -655,76 +654,76 @@ void campaign_editor::save_loop_desc_window()
{
char buffer[MISSION_DESC_LENGTH];
// update only if active link and there is a mission has mission loop
if ( (Cur_campaign_link >= 0) && Links[Cur_campaign_link].mission_loop ) {
deconvert_multiline_string(buffer, m_loop_desc, MISSION_DESC_LENGTH);
if (Links[Cur_campaign_link].mission_loop_txt) {
free(Links[Cur_campaign_link].mission_loop_txt);
// update only if active link and there is a mission has mission loop or fork
if ( (Cur_campaign_link >= 0) && (Links[Cur_campaign_link].is_mission_loop || Links[Cur_campaign_link].is_mission_fork) ) {
deconvert_multiline_string(buffer, m_branch_desc, MISSION_DESC_LENGTH);
if (Links[Cur_campaign_link].mission_branch_txt) {
free(Links[Cur_campaign_link].mission_branch_txt);
}
if (Links[Cur_campaign_link].mission_loop_brief_anim) {
free(Links[Cur_campaign_link].mission_loop_brief_anim);
if (Links[Cur_campaign_link].mission_branch_brief_anim) {
free(Links[Cur_campaign_link].mission_branch_brief_anim);
}
if (Links[Cur_campaign_link].mission_loop_brief_sound) {
free(Links[Cur_campaign_link].mission_loop_brief_sound);
if (Links[Cur_campaign_link].mission_branch_brief_sound) {
free(Links[Cur_campaign_link].mission_branch_brief_sound);
}
if (strlen(buffer)) {
Links[Cur_campaign_link].mission_loop_txt = strdup(buffer);
Links[Cur_campaign_link].mission_branch_txt = strdup(buffer);
} else {
Links[Cur_campaign_link].mission_loop_txt = NULL;
Links[Cur_campaign_link].mission_branch_txt = NULL;
}
deconvert_multiline_string(buffer, m_loop_brief_anim, MAX_FILENAME_LEN);
deconvert_multiline_string(buffer, m_branch_brief_anim, MAX_FILENAME_LEN);
if(strlen(buffer)){
Links[Cur_campaign_link].mission_loop_brief_anim = strdup(buffer);
Links[Cur_campaign_link].mission_branch_brief_anim = strdup(buffer);
} else {
Links[Cur_campaign_link].mission_loop_brief_anim = NULL;
Links[Cur_campaign_link].mission_branch_brief_anim = NULL;
}
deconvert_multiline_string(buffer, m_loop_brief_sound, MAX_FILENAME_LEN);
deconvert_multiline_string(buffer, m_branch_brief_sound, MAX_FILENAME_LEN);
if(strlen(buffer)){
Links[Cur_campaign_link].mission_loop_brief_sound = strdup(buffer);
Links[Cur_campaign_link].mission_branch_brief_sound = strdup(buffer);
} else {
Links[Cur_campaign_link].mission_loop_brief_sound = NULL;
Links[Cur_campaign_link].mission_branch_brief_sound = NULL;
}
}
}
void campaign_editor::update_loop_desc_window()
{
bool enable_loop_desc_window;
bool enable_branch_desc_window;
enable_loop_desc_window = false;
if ((Cur_campaign_link >= 0) && Links[Cur_campaign_link].mission_loop) {
enable_loop_desc_window = true;
enable_branch_desc_window = false;
if ((Cur_campaign_link >= 0) && (Links[Cur_campaign_link].is_mission_loop || Links[Cur_campaign_link].is_mission_fork)) {
enable_branch_desc_window = true;
}
// maybe enable description window
GetDlgItem(IDC_MISSISON_LOOP_DESC)->EnableWindow(enable_loop_desc_window);
GetDlgItem(IDC_LOOP_BRIEF_ANIM)->EnableWindow(enable_loop_desc_window);
GetDlgItem(IDC_LOOP_BRIEF_SOUND)->EnableWindow(enable_loop_desc_window);
GetDlgItem(IDC_LOOP_BRIEF_BROWSE)->EnableWindow(enable_loop_desc_window);
GetDlgItem(IDC_LOOP_BRIEF_SOUND_BROWSE)->EnableWindow(enable_loop_desc_window);
GetDlgItem(IDC_MISSISON_LOOP_DESC)->EnableWindow(enable_branch_desc_window);
GetDlgItem(IDC_LOOP_BRIEF_ANIM)->EnableWindow(enable_branch_desc_window);
GetDlgItem(IDC_LOOP_BRIEF_SOUND)->EnableWindow(enable_branch_desc_window);
GetDlgItem(IDC_LOOP_BRIEF_BROWSE)->EnableWindow(enable_branch_desc_window);
GetDlgItem(IDC_LOOP_BRIEF_SOUND_BROWSE)->EnableWindow(enable_branch_desc_window);
// set new text
if ((Cur_campaign_link >= 0) && Links[Cur_campaign_link].mission_loop_txt && enable_loop_desc_window) {
m_loop_desc = convert_multiline_string(Links[Cur_campaign_link].mission_loop_txt);
if ((Cur_campaign_link >= 0) && Links[Cur_campaign_link].mission_branch_txt && enable_branch_desc_window) {
m_branch_desc = convert_multiline_string(Links[Cur_campaign_link].mission_branch_txt);
} else {
m_loop_desc = _T("");
m_branch_desc = _T("");
}
// set new text
if ((Cur_campaign_link >= 0) && Links[Cur_campaign_link].mission_loop_brief_anim && enable_loop_desc_window) {
m_loop_brief_anim = convert_multiline_string(Links[Cur_campaign_link].mission_loop_brief_anim);
if ((Cur_campaign_link >= 0) && Links[Cur_campaign_link].mission_branch_brief_anim && enable_branch_desc_window) {
m_branch_brief_anim = convert_multiline_string(Links[Cur_campaign_link].mission_branch_brief_anim);
} else {
m_loop_brief_anim = _T("");
m_branch_brief_anim = _T("");
}
// set new text
if ((Cur_campaign_link >= 0) && Links[Cur_campaign_link].mission_loop_brief_sound && enable_loop_desc_window) {
m_loop_brief_sound = convert_multiline_string(Links[Cur_campaign_link].mission_loop_brief_sound);
if ((Cur_campaign_link >= 0) && Links[Cur_campaign_link].mission_branch_brief_sound && enable_branch_desc_window) {
m_branch_brief_sound = convert_multiline_string(Links[Cur_campaign_link].mission_branch_brief_sound);
} else {
m_loop_brief_sound = _T("");
m_branch_brief_sound = _T("");
}
// reset text
@@ -738,55 +737,56 @@ void campaign_editor::OnToggleLoop()
return;
}
// store mission looop text
// store mission loop text
UpdateData(TRUE);
if ( (Cur_campaign_link >= 0) && Links[Cur_campaign_link].mission_loop ) {
if (Links[Cur_campaign_link].mission_loop_txt) {
free(Links[Cur_campaign_link].mission_loop_txt);
if ( (Cur_campaign_link >= 0) && (Links[Cur_campaign_link].is_mission_loop || Links[Cur_campaign_link].is_mission_fork) ) {
if (Links[Cur_campaign_link].mission_branch_txt) {
free(Links[Cur_campaign_link].mission_branch_txt);
}
if (Links[Cur_campaign_link].mission_loop_brief_anim) {
free(Links[Cur_campaign_link].mission_loop_brief_anim);
if (Links[Cur_campaign_link].mission_branch_brief_anim) {
free(Links[Cur_campaign_link].mission_branch_brief_anim);
}
if (Links[Cur_campaign_link].mission_loop_brief_sound) {
free(Links[Cur_campaign_link].mission_loop_brief_sound);
if (Links[Cur_campaign_link].mission_branch_brief_sound) {
free(Links[Cur_campaign_link].mission_branch_brief_sound);
}
char buffer[MISSION_DESC_LENGTH];
deconvert_multiline_string(buffer, m_loop_desc, MISSION_DESC_LENGTH);
if (m_loop_desc && strlen(buffer)) {
Links[Cur_campaign_link].mission_loop_txt = strdup(buffer);
deconvert_multiline_string(buffer, m_branch_desc, MISSION_DESC_LENGTH);
if (m_branch_desc && strlen(buffer)) {
Links[Cur_campaign_link].mission_branch_txt = strdup(buffer);
} else {
Links[Cur_campaign_link].mission_loop_txt = NULL;
Links[Cur_campaign_link].mission_branch_txt = NULL;
}
deconvert_multiline_string(buffer, m_loop_brief_anim, MISSION_DESC_LENGTH);
if (m_loop_brief_anim && strlen(buffer)) {
Links[Cur_campaign_link].mission_loop_brief_anim = strdup(buffer);
deconvert_multiline_string(buffer, m_branch_brief_anim, MISSION_DESC_LENGTH);
if (m_branch_brief_anim && strlen(buffer)) {
Links[Cur_campaign_link].mission_branch_brief_anim = strdup(buffer);
} else {
Links[Cur_campaign_link].mission_loop_brief_anim = NULL;
Links[Cur_campaign_link].mission_branch_brief_anim = NULL;
}
deconvert_multiline_string(buffer, m_loop_brief_sound, MISSION_DESC_LENGTH);
if (m_loop_brief_sound && strlen(buffer)) {
Links[Cur_campaign_link].mission_loop_brief_sound = strdup(buffer);
deconvert_multiline_string(buffer, m_branch_brief_sound, MISSION_DESC_LENGTH);
if (m_branch_brief_sound && strlen(buffer)) {
Links[Cur_campaign_link].mission_branch_brief_sound = strdup(buffer);
} else {
Links[Cur_campaign_link].mission_loop_brief_sound = NULL;
Links[Cur_campaign_link].mission_branch_brief_sound = NULL;
}
}
// toggle to mission_loop setting
Links[Cur_campaign_link].mission_loop = !Links[Cur_campaign_link].mission_loop;
Links[Cur_campaign_link].is_mission_loop = !Links[Cur_campaign_link].is_mission_loop;
Links[Cur_campaign_link].is_mission_fork = false;
// reset loop desc window (gray if inactive)
update_loop_desc_window();
// set root icon
int bitmap1, bitmap2;
if (Links[Cur_campaign_link].mission_loop) {
if (Links[Cur_campaign_link].is_mission_loop || Links[Cur_campaign_link].is_mission_fork) {
bitmap2 = BITMAP_GREEN_DOT;
bitmap1 = BITMAP_BLUE_DOT;
} else {
@@ -820,7 +820,7 @@ void campaign_editor::OnBrowseLoopAni()
CFileDialog dlg(TRUE, "ani", NULL, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR, "Ani Files (*.ani)|*.ani");
if (dlg.DoModal() == IDOK) {
m_loop_brief_anim = dlg.GetFileName();
m_branch_brief_anim = dlg.GetFileName();
UpdateData(FALSE);
}
@@ -842,7 +842,7 @@ void campaign_editor::OnBrowseLoopSound()
"Voice Files (*.ogg, *.wav)|*.ogg;*.wav|Ogg Vorbis Files (*.ogg)|*.ogg|Wave Files (*.wav)|*.wav||");
if (dlg.DoModal() == IDOK) {
m_loop_brief_sound = dlg.GetFileName();
m_branch_brief_sound = dlg.GetFileName();
UpdateData(FALSE);
}
@@ -886,7 +886,7 @@ void campaign_editor::OnChangeDebriefingPersona()
if (persona < 0 || persona > 0xff)
persona = 0;
Campaign.missions[Cur_campaign_mission].debrief_persona_index = persona;
Campaign.missions[Cur_campaign_mission].debrief_persona_index = (ubyte) persona;
}
}
+3 -3
View File
@@ -56,9 +56,9 @@ public:
int m_type;
CString m_num_players;
CString m_desc;
CString m_loop_desc;
CString m_loop_brief_anim;
CString m_loop_brief_sound;
CString m_branch_desc;
CString m_branch_brief_anim;
CString m_branch_brief_sound;
BOOL m_custom_tech_db;
//}}AFX_DATA
-1
View File
@@ -19,7 +19,6 @@
#include "mission/missionparse.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
+44 -37
View File
@@ -18,7 +18,6 @@
#include "mission/missionparse.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
@@ -184,14 +183,14 @@ void campaign_tree_view::OnDraw(CDC* pDC)
Links[i].p2.x = Elements[t].box.left + Links[i].to_pos * Bx / (Elements[t].to_links + 1);
Links[i].p2.y = Elements[t].box.top;
// if mission_loop link, select blue pen
if (Links[i].mission_loop) {
// if special mission link, select blue pen
if (Links[i].is_mission_loop || Links[i].is_mission_fork) {
pDC->SelectObject(&blue_pen);
}
// if active link, select highlight pen (red - normal, green - mission loop)
// if active link, select highlight pen (red - normal, green - special)
if (i == Cur_campaign_link) {
if (Links[i].mission_loop) {
if (Links[i].is_mission_loop || Links[i].is_mission_fork) {
pDC->SelectObject(&green_pen);
} else {
pDC->SelectObject(&red_pen);
@@ -249,9 +248,9 @@ void stuff_link_with_formula(int *link_idx, int formula, int mission_num)
node2 = CAR(node);
Links[*link_idx].from = mission_num;
Links[*link_idx].sexp = CAR(node2);
Links[*link_idx].mission_loop_txt = NULL;
Links[*link_idx].mission_loop_brief_anim = NULL;
Links[*link_idx].mission_loop_brief_sound = NULL;
Links[*link_idx].mission_branch_txt = NULL;
Links[*link_idx].mission_branch_brief_anim = NULL;
Links[*link_idx].mission_branch_brief_sound = NULL;
sexp_mark_persistent(CAR(node2));
free_one_sexp(node2);
node3 = CADR(node2);
@@ -301,13 +300,20 @@ void campaign_tree_view::construct_tree()
// do main campaign path
stuff_link_with_formula(&link_idx, Campaign.missions[i].formula, i);
// do mission loop path
if ( Campaign.missions[i].has_mission_loop ) {
// do special mission path
if ( Campaign.missions[i].flags & CMISSION_FLAG_HAS_LOOP ) {
stuff_link_with_formula(&link_idx, Campaign.missions[i].mission_loop_formula, i);
Links[link_idx-1].mission_loop_txt = Campaign.missions[i].mission_loop_desc;
Links[link_idx-1].mission_loop_brief_anim = Campaign.missions[i].mission_loop_brief_anim;
Links[link_idx-1].mission_loop_brief_sound = Campaign.missions[i].mission_loop_brief_sound;
Links[link_idx-1].mission_loop = 1;
Links[link_idx-1].mission_branch_txt = Campaign.missions[i].mission_branch_desc;
Links[link_idx-1].mission_branch_brief_anim = Campaign.missions[i].mission_branch_brief_anim;
Links[link_idx-1].mission_branch_brief_sound = Campaign.missions[i].mission_branch_brief_sound;
Links[link_idx-1].is_mission_loop = true;
}
else if ( Campaign.missions[i].flags & CMISSION_FLAG_HAS_FORK ) {
Campaign.missions[i].mission_loop_formula = -1;
Links[link_idx-1].mission_branch_txt = Campaign.missions[i].mission_branch_desc;
Links[link_idx-1].mission_branch_brief_anim = Campaign.missions[i].mission_branch_brief_anim;
Links[link_idx-1].mission_branch_brief_sound = Campaign.missions[i].mission_branch_brief_sound;
Links[link_idx-1].is_mission_fork = true;
}
}
@@ -511,45 +517,45 @@ void campaign_tree_view::OnLButtonDown(UINT nFlags, CPoint point)
dc.DrawDragRect(Dragging_rect, Last_draw_size, NULL, CSize(0, 0));
} else {
if ( (Cur_campaign_link >= 0) && Links[Cur_campaign_link].mission_loop) {
// HACK!! UPDATE mission loop desc before changing selections
// save mission loop desc
if ( (Cur_campaign_link >= 0) && (Links[Cur_campaign_link].is_mission_loop || Links[Cur_campaign_link].is_mission_fork)) {
// HACK!! UPDATE mission loop/fork desc before changing selections
// save mission loop/fork desc
char buffer[MISSION_DESC_LENGTH];
box = (CEdit *) Campaign_tree_formp->GetDlgItem(IDC_MISSISON_LOOP_DESC);
box->GetWindowText(buffer, MISSION_DESC_LENGTH);
if (strlen(buffer)) {
if (Links[Cur_campaign_link].mission_loop_txt) {
free(Links[Cur_campaign_link].mission_loop_txt);
if (Links[Cur_campaign_link].mission_branch_txt) {
free(Links[Cur_campaign_link].mission_branch_txt);
}
Links[Cur_campaign_link].mission_loop_txt = strdup(buffer);
Links[Cur_campaign_link].mission_branch_txt = strdup(buffer);
} else {
Links[Cur_campaign_link].mission_loop_txt = NULL;
Links[Cur_campaign_link].mission_branch_txt = NULL;
}
// HACK!! UPDATE mission loop desc before changing selections
// save mission loop desc
// HACK!! UPDATE mission loop/fork desc before changing selections
// save mission loop/fork desc
box = (CEdit *) Campaign_tree_formp->GetDlgItem(IDC_LOOP_BRIEF_ANIM);
box->GetWindowText(buffer, MISSION_DESC_LENGTH);
if (strlen(buffer)) {
if (Links[Cur_campaign_link].mission_loop_brief_anim) {
free(Links[Cur_campaign_link].mission_loop_brief_anim);
if (Links[Cur_campaign_link].mission_branch_brief_anim) {
free(Links[Cur_campaign_link].mission_branch_brief_anim);
}
Links[Cur_campaign_link].mission_loop_brief_anim = strdup(buffer);
Links[Cur_campaign_link].mission_branch_brief_anim = strdup(buffer);
} else {
Links[Cur_campaign_link].mission_loop_brief_anim = NULL;
Links[Cur_campaign_link].mission_branch_brief_anim = NULL;
}
// HACK!! UPDATE mission loop desc before changing selections
// save mission loop desc
// HACK!! UPDATE mission loop/fork desc before changing selections
// save mission loop/fork desc
box = (CEdit *) Campaign_tree_formp->GetDlgItem(IDC_LOOP_BRIEF_SOUND);
box->GetWindowText(buffer, MISSION_DESC_LENGTH);
if (strlen(buffer)) {
if (Links[Cur_campaign_link].mission_loop_brief_sound) {
free(Links[Cur_campaign_link].mission_loop_brief_sound);
if (Links[Cur_campaign_link].mission_branch_brief_sound) {
free(Links[Cur_campaign_link].mission_branch_brief_sound);
}
Links[Cur_campaign_link].mission_loop_brief_sound = strdup(buffer);
Links[Cur_campaign_link].mission_branch_brief_sound = strdup(buffer);
} else {
Links[Cur_campaign_link].mission_loop_brief_sound = NULL;
Links[Cur_campaign_link].mission_branch_brief_sound = NULL;
}
}
Mission_dragging = Cur_campaign_mission = Cur_campaign_link = -1;
@@ -745,10 +751,11 @@ int campaign_tree_view::add_link(int from, int to)
Links[Total_links].from = from;
Links[Total_links].to = to;
Links[Total_links].sexp = Locked_sexp_true;
Links[Total_links].mission_loop = false;
Links[Total_links].mission_loop_txt = NULL;
Links[Total_links].mission_loop_brief_anim = NULL;
Links[Total_links].mission_loop_brief_sound = NULL;
Links[Total_links].is_mission_loop = false;
Links[Total_links].is_mission_fork = false;
Links[Total_links].mission_branch_txt = NULL;
Links[Total_links].mission_branch_brief_anim = NULL;
Links[Total_links].mission_branch_brief_sound = NULL;
Total_links++;
if (from != to) {
Elements[from].from_links++;
+5 -4
View File
@@ -28,10 +28,11 @@ typedef struct campaign_tree_link {
int node; // node tracker when link is in sexp tree window
int from_pos; // from link drawing offset
int to_pos; // to link drawing offset
bool mission_loop; // whether link leads to mission loop
char *mission_loop_txt; // text describing mission loop
char *mission_loop_brief_anim; // filename of anim to play in the brief
char *mission_loop_brief_sound; // filename of anim to play in the brief
bool is_mission_loop; // whether link leads to mission loop
bool is_mission_fork; // whether link leads to mission fork
char *mission_branch_txt; // text describing mission loop
char *mission_branch_brief_anim; // filename of anim to play in the brief
char *mission_branch_brief_sound; // filename of anim to play in the brief
CPoint p1; // coordinates of line last draw for link, from p1 to p2
CPoint p2;
} campaign_tree_link;
+2 -3
View File
@@ -22,7 +22,6 @@
#include "mission/missionparse.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
@@ -411,7 +410,7 @@ int campaign_tree_wnd::internal_error(char *msg, ...)
int campaign_tree_wnd::fred_check_sexp(int sexp, int type, char *msg, ...)
{
char buf[512], buf2[2048], buf3[4096];
char buf[512], buf2[2048], buf3[MAX_EVENT_SIZE];
int err = 0, z, faulty_node;
va_list args;
@@ -426,7 +425,7 @@ int campaign_tree_wnd::fred_check_sexp(int sexp, int type, char *msg, ...)
if (!z)
return 0;
convert_sexp_to_string(sexp, buf2, SEXP_ERROR_CHECK_MODE, 2048);
convert_sexp_to_string(sexp, buf2, SEXP_ERROR_CHECK_MODE, MAX_EVENT_SIZE);
sprintf(buf3, "Error in %s: %s\n\nIn sexpression: %s\n\n(Error appears to be: %s)",
buf, sexp_error_message(z), buf2, Sexp_nodes[faulty_node].text);
-1
View File
@@ -17,7 +17,6 @@
#include "localization/localize.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
+4 -6
View File
@@ -20,7 +20,6 @@
#include "iff_defs/iff_defs.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
@@ -120,11 +119,10 @@ void create_wing_dlg::OnOK()
}
}
for (i=0; i<MAX_WAYPOINT_LISTS; i++) {
if (Waypoint_lists[i].count && !stricmp(Waypoint_lists[i].name, m_name)) {
MessageBox("This wing name is already being used by a waypoint path");
return;
}
if (find_matching_waypoint_list(const_cast<char *>((const char *) m_name)) != NULL)
{
MessageBox("This wing name is already being used by a waypoint path");
return;
}
if (!stricmp(m_name.Left(1), "<")) {
-1
View File
@@ -7,7 +7,6 @@
#include "ship/ship.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
+36 -1
View File
@@ -14,13 +14,15 @@
#include "DebriefingEditorDlg.h"
#include "FREDDoc.h"
#include "mission/missionbriefcommon.h"
#include "mission/missionparse.h"
#include "globalincs/linklist.h"
#include "parse/sexp.h"
#include "gamesnd/eventmusic.h"
#include "cfile/cfile.h"
#include "sound/audiostr.h"
#include "localization/localize.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
@@ -36,6 +38,9 @@ debriefing_editor_dlg::debriefing_editor_dlg(CWnd* pParent /*=NULL*/)
m_voice = _T("");
m_stage_title = _T("");
m_rec_text = _T("");
m_debriefPass_music = 0;
m_debriefAvg_music = 0;
m_debriefFail_music = 0;
m_current_debriefing = -1;
//}}AFX_DATA_INIT
@@ -55,6 +60,9 @@ void debriefing_editor_dlg::DoDataExchange(CDataExchange* pDX)
DDX_Text(pDX, IDC_VOICE, m_voice);
DDX_Text(pDX, IDC_STAGE_TITLE, m_stage_title);
DDX_Text(pDX, IDC_REC_TEXT, m_rec_text);
DDX_CBIndex(pDX, IDC_SUCCESSFUL_MISSION_TRACK, m_debriefPass_music);
DDX_CBIndex(pDX, IDC_DEBRIEFING_TRACK, m_debriefAvg_music);
DDX_CBIndex(pDX, IDC_FAILED_MISSION_TRACK, m_debriefFail_music);
//}}AFX_DATA_MAP
DDV_MaxChars(pDX, m_text, MAX_BRIEF_LEN - 1);
@@ -116,12 +124,33 @@ BOOL debriefing_editor_dlg::OnInitDialog()
CDialog::OnInitDialog();
m_play_bm.LoadBitmap(IDB_PLAY);
((CButton *) GetDlgItem(IDC_PLAY)) -> SetBitmap(m_play_bm);
CComboBox *box;
box = (CComboBox *) GetDlgItem(IDC_ICON_IMAGE);
m_current_debriefing = 0;
UpdateData(FALSE);
Debriefing = &Debriefings[m_current_debriefing];
box = (CComboBox *) GetDlgItem(IDC_SUCCESSFUL_MISSION_TRACK);
box->AddString("None");
for (i=0; i<Num_music_files; i++)
box->AddString(Spooled_music[i].name);
box = (CComboBox *) GetDlgItem(IDC_DEBRIEFING_TRACK);
box->AddString("None");
for (i=0; i<Num_music_files; i++)
box->AddString(Spooled_music[i].name);
box = (CComboBox *) GetDlgItem(IDC_FAILED_MISSION_TRACK);
box->AddString("None");
for (i=0; i<Num_music_files; i++)
box->AddString(Spooled_music[i].name);
m_debriefPass_music = Mission_music[SCORE_DEBRIEF_SUCCESS] + 1;
m_debriefAvg_music = Mission_music[SCORE_DEBRIEF_AVERAGE] + 1;
m_debriefFail_music = Mission_music[SCORE_DEBRIEF_FAIL] + 1;
m_tree.link_modified(&modified); // provide way to indicate trees are modified in dialog
n = m_tree.select_sexp_node = select_sexp_node;
select_sexp_node = -1;
@@ -140,6 +169,7 @@ BOOL debriefing_editor_dlg::OnInitDialog()
}
}
CDialog::OnInitDialog();
update_data();
set_modified();
@@ -403,6 +433,11 @@ void debriefing_editor_dlg::OnClose()
m_voice_id = -1;
m_cur_stage = -1;
update_data(1);
Mission_music[SCORE_DEBRIEF_SUCCESS] = m_debriefPass_music - 1;
Mission_music[SCORE_DEBRIEF_AVERAGE] = m_debriefAvg_music - 1;
Mission_music[SCORE_DEBRIEF_FAIL] = m_debriefFail_music - 1;
CDialog::OnClose();
}
+4
View File
@@ -8,6 +8,7 @@
*/
#include "mission/missionbriefcommon.h"
/////////////////////////////////////////////////////////////////////////////
// debriefing_editor_dlg dialog
@@ -29,6 +30,9 @@ public:
CString m_voice;
CString m_stage_title;
CString m_rec_text;
int m_debriefPass_music;
int m_debriefAvg_music;
int m_debriefFail_music;
int m_current_debriefing;
//}}AFX_DATA
-1
View File
@@ -14,7 +14,6 @@
#include "dialog1.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
+11 -12
View File
@@ -27,7 +27,6 @@
#include "weapon/weapon.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
@@ -282,7 +281,7 @@ void DumpStats::get_background_stats(CString &buffer)
}
// nebula texture
if (strlen(Neb2_texture_name) > 0) {
if (strlen(Neb2_texture_name) > 0) { //-V805
temp.Format("\tNebula texture: %s\r\n", Neb2_texture_name);
buffer += temp;
}
@@ -386,11 +385,12 @@ void DumpStats::get_object_stats(CString &buffer)
// Waypoints
int total_waypoints = 0;
buffer += "\r\nWAYPOINTS\r\n";
for (i=0; i<Num_waypoint_lists; i++) {
temp.Format("\tWaypoint: %s, count: %d\r\n", Waypoint_lists[i].name, Waypoint_lists[i].count);
buffer += temp;
total_waypoints += Waypoint_lists[i].count;
SCP_list<waypoint_list>::iterator ii;
for (ii = Waypoint_lists.begin(); ii != Waypoint_lists.end(); ++ii) {
temp.Format("\tWaypoint: %s, count: %d\r\n", ii->get_name(), ii->get_waypoints().size());
buffer += temp;
total_waypoints += ii->get_waypoints().size();
}
if (total_waypoints > 0) {
@@ -483,7 +483,7 @@ void DumpStats::get_objectives_and_goals(CString &buffer)
// goals
for (i=0; i<Num_goals; i++) {
temp.Format("\tGoal: %s, text: ", Mission_goals[i].name, Mission_goals[i].message);
temp.Format("\tGoal: %s, text: %s", Mission_goals[i].name, Mission_goals[i].message);
buffer += temp;
switch(Mission_goals[i].type & GOAL_TYPE_MASK) {
@@ -570,15 +570,14 @@ void DumpStats::get_species_ship_breakdown(CString &buffer)
{
CString temp;
int i;
uint species;
int species;
object *objp;
ship *shipp;
buffer += "\r\nSHIP SPECIES BREAKDOWN\r\n";
for (species=0; species < Species_info.size(); species++) {
for (species=0; (uint) species < Species_info.size(); species++) {
buffer += Species_info[species].species_name;
buffer += "\r\n";
@@ -751,7 +750,7 @@ void dump_loadout(ship *shipp, CString &loadout)
void DumpStats::get_default_ship_loadouts(CString &buffer)
{
int i;
uint species;
int species;
object *objp;
ship *shipp;
CString temp, loadout;
@@ -759,7 +758,7 @@ void DumpStats::get_default_ship_loadouts(CString &buffer)
buffer += "\r\nSHIP SPECIES BREAKDOWN\r\n";
for (species=0; species < Species_info.size(); species++) {
for (species=0; (uint) species < Species_info.size(); species++) {
buffer += Species_info[species].species_name;
buffer += "\r\n";
+13 -10
View File
@@ -22,7 +22,6 @@
#include "localization/localize.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
@@ -82,15 +81,17 @@ void event_editor::DoDataExchange(CDataExchange* pDX)
DDX_CBString(pDX, IDC_WAVE_FILENAME, m_wave_filename);
DDX_LBIndex(pDX, IDC_MESSAGE_LIST, m_cur_msg);
// m_team == -1 maps to 2
if(m_team == -1){
m_team = 2;
m_team = MAX_TVT_TEAMS;
}
DDX_CBIndex(pDX, IDC_EVENT_TEAM, m_team);
// m_message_team == -1 maps to 2
if(m_message_team == -1){
m_message_team = 2;
m_message_team = MAX_TVT_TEAMS;
}
DDX_CBIndex(pDX, IDC_MESSAGE_TEAM, m_message_team);
//}}AFX_DATA_MAP
@@ -570,7 +571,7 @@ void event_editor::update_cur_message()
m_persona = 0;
}
if(m_messages[m_cur_msg].multi_team >= 2){
if(m_messages[m_cur_msg].multi_team >= MAX_TVT_TEAMS){
m_message_team = -1;
m_messages[m_cur_msg].multi_team = -1;
} else {
@@ -715,6 +716,7 @@ void event_editor::reset_event(int num, HTREEITEM after)
m_events[num].chain_delay = -1;
m_events[num].objective_text = NULL;
m_events[num].objective_key_text = NULL;
m_events[num].team = -1;
m_sig[num] = -1;
m_event_tree.item_index = -1;
@@ -1174,7 +1176,7 @@ int event_editor::save_message(int num)
// box list.
m_messages[num].persona_index = m_persona - 1;
if(m_message_team >= 2){
if(m_message_team >= MAX_TVT_TEAMS){
m_messages[num].multi_team = -1;
m_message_team = -1;
} else {
@@ -1227,6 +1229,7 @@ void event_editor::OnDeleteMsg()
((CListBox *) GetDlgItem(IDC_MESSAGE_LIST))->DeleteString(m_cur_msg);
sprintf(buf, "<%s>", m_messages[m_cur_msg].name);
update_sexp_references(m_messages[m_cur_msg].name, buf, OPF_MESSAGE);
update_sexp_references(m_messages[m_cur_msg].name, buf, OPF_MESSAGE_OR_STRING);
m_messages.erase(m_messages.begin() + m_cur_msg);
@@ -1251,7 +1254,7 @@ void event_editor::OnBrowseAvi()
z = cfile_push_chdir(CF_TYPE_INTERFACE);
CFileDialog dlg(TRUE, "ani", m_avi_filename, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR,
"Ani Files (*.ani)|*.ani|Avi Files (*.avi)|*.avi|Both (*.ani, *.avi)|*.ani;*.avi||");
"Ani Files (*.ani)|*.ani|Eff Files (*.eff)|*.eff|Avi Files (*.avi)|*.avi|Both (*.ani, *.avi)|*.ani;*.avi||");
if (dlg.DoModal() == IDOK) {
m_avi_filename = dlg.GetFileName();
@@ -1409,8 +1412,8 @@ void event_editor::OnSelchangeTeam()
UpdateData(TRUE);
// team == 2, means no team
if(m_team == 2){
// If the team isn't valid mark it as such.
if((m_team >= MAX_TVT_TEAMS) || (m_team < -1) ){
m_team = -1;
}
@@ -1426,8 +1429,8 @@ void event_editor::OnSelchangeMessageTeam()
UpdateData(TRUE);
// team == 2, means no team
if(m_message_team == 2){
// If the team isn't valid mark it as such.
if((m_message_team>= MAX_TVT_TEAMS) || (m_message_team < -1) ) {
m_message_team = -1;
}
+1 -1
View File
@@ -185,7 +185,7 @@ BOOL CFolderDialog::SetSelectedFolder( IN LPCTSTR pszPath )
VOID CFolderDialog::OnInitialized( VOID )
{
if( ::lstrlen( m_szSelPath ) > 0 )
if( ::lstrlen( m_szSelPath ) > 0 ) //-V805
SetSelection( m_szSelPath );
}
+42 -7
View File
@@ -25,9 +25,10 @@
#include "CampaignTreeWnd.h"
#include "CampaignTreeView.h"
#include "CampaignEditorDlg.h"
#include "debugconsole/dbugfile.h"
#include "globalincs/mspdb_callstack.h"
#include "AFXADV.H"
#ifdef NDEBUG
#ifndef FRED
#error macro FRED is not defined when trying to build release Fred. Please define FRED macro in build settings in all Fred projects
@@ -35,7 +36,6 @@
#endif
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
@@ -80,12 +80,12 @@ window_data Mission_notes_wnd_data;
BEGIN_MESSAGE_MAP(CFREDApp, CWinApp)
//{{AFX_MSG_MAP(CFREDApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
// Standard print setup command
ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
@@ -97,7 +97,6 @@ CFREDApp::CFREDApp()
{
app_init = 0;
DBUGFILE_INIT();
SCP_mspdbcs_Initialise( );
#ifndef NDEBUG
@@ -108,7 +107,6 @@ CFREDApp::CFREDApp()
CFREDApp::~CFREDApp()
{
SCP_mspdbcs_Cleanup( );
DBUGFILE_DEINIT();
}
/////////////////////////////////////////////////////////////////////////////
@@ -125,7 +123,7 @@ BOOL CFREDApp::InitInstance()
// disable the debug memory stuff
_CrtSetDbgFlag(~(_CRTDBG_ALLOC_MEM_DF) & _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG));
// _CrtSetDbgFlag(~(_CRTDBG_ALLOC_MEM_DF) & _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG));
// Standard initialization
// If you are not using these features and wish to reduce the size
@@ -236,9 +234,23 @@ BOOL CFREDApp::InitInstance()
*str_end = '\0';
// Goober5000 - figure out where the FRED file dialog should go
if ((m_pRecentFileList != NULL) && (m_pRecentFileList->GetSize() > 0))
{
// use the most recently opened file to supply the default folder
m_sInitialDir = m_pRecentFileList->operator[](0); // lol syntax
}
else
{
// use FRED's own directory to search for missions
m_sInitialDir = Fred_base_dir;
m_sInitialDir += "\\data\\missions";
}
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
ParseCommandLine(cmdInfo);
m_nCmdShow = Main_wnd_data.p.showCmd;
@@ -309,6 +321,25 @@ void CFREDApp::OnAppAbout()
aboutDlg.DoModal();
}
// G5K - from http://www.experts-exchange.com/Programming/System/Windows__Programming/MFC/Q_20155824.html
void CFREDApp::OnFileOpen()
{
// use the initial dir the first time we prompt for a file
// name. after a successful open, the file name will be
// changed to be the empty string and the default dir
// will be supplied by the CFileDialog internal memory
if(!DoPromptFileName(m_sInitialDir, AFX_IDS_OPENFILE, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST, TRUE, NULL))
{
// open cancelled
return;
}
AfxGetApp()->OpenDocumentFile(m_sInitialDir);
// if returns NULL, the user has already been alerted
// now erase the initial dir since we only want to use it once
m_sInitialDir.Empty();
}
/////////////////////////////////////////////////////////////////////////////
// CFREDApp commands
@@ -668,3 +699,7 @@ int CFREDApp::ExitInstance()
return CWinApp::ExitInstance();
}
// Empty functions to make fred link with the sexp_mission_set_subspace
void game_start_subspace_ambient_sound() {}
void game_stop_subspace_ambient_sound() {}
+2
View File
@@ -52,6 +52,7 @@ typedef struct window_data {
class CFREDApp : public CWinApp
{
int app_init;
CString m_sInitialDir;
public:
void record_window_data(window_data *wndd, CWnd *wnd);
@@ -75,6 +76,7 @@ public:
//{{AFX_MSG(CFREDApp)
afx_msg void OnAppAbout();
afx_msg void OnFileOpen();
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
+744 -1234
View File
File diff suppressed because it is too large. Load diff
+3 -4
View File
@@ -50,7 +50,6 @@
extern int Num_objects;
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
@@ -427,7 +426,7 @@ int CFREDDoc::load_mission(char *pathname, int flags)
generate_weaponry_usage_list(i, used_pool);
for (j=0; j<Team_data[i].num_weapon_choices; j++) {
// The amount used in wings is always set by a static loadout entry so skip any that were set by Sexp variables
if ((Team_data[i].weaponry_pool_variable[j] == -1) && (Team_data[i].weaponry_amount_variable[j] == -1) ) {
if ( (!strlen(Team_data[i].weaponry_pool_variable[j])) && (!strlen(Team_data[i].weaponry_amount_variable[j])) ) {
// convert weaponry_pool to be extras available beyond the current ships weapons
Team_data[i].weaponry_count[j] -= used_pool[Team_data[i].weaponry_pool[j]];
if (Team_data[i].weaponry_count[j] < 0) {
@@ -446,8 +445,8 @@ int CFREDDoc::load_mission(char *pathname, int flags)
// add the weapon as a new entry
Team_data[i].weaponry_pool[Team_data[i].num_weapon_choices] = j;
Team_data[i].weaponry_count[Team_data[i].num_weapon_choices] = used_pool[j];
Team_data[i].weaponry_amount_variable[Team_data[i].num_weapon_choices] = -1;
Team_data[i].weaponry_pool_variable[Team_data[i].num_weapon_choices++] = -1;
strcpy_s(Team_data[i].weaponry_amount_variable[Team_data[i].num_weapon_choices], "");
strcpy_s(Team_data[i].weaponry_pool_variable[Team_data[i].num_weapon_choices++], "");
}
}
}
+38 -32
View File
@@ -58,7 +58,6 @@ extern float flFrametime;
extern subsys_to_render Render_subsys;
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
@@ -404,44 +403,47 @@ void process_system_keys(int key)
void render_waypoints(void)
{
int i, j;
vertex v;
waypoint_list *ptr;
for (i=0; i<Num_waypoint_lists; i++)
SCP_list<waypoint_list>::iterator ii;
SCP_list<waypoint>::iterator jj;
for (ii = Waypoint_lists.begin(); ii != Waypoint_lists.end(); ++ii)
{
ptr = &Waypoint_lists[i];
for (j=0; j<ptr->count; j++)
vec3d *prev_vec = NULL;
for (jj = ii->get_waypoints().begin(); jj != ii->get_waypoints().end(); ++jj)
{
g3_rotate_vertex(&v, &ptr->waypoints[j]);
g3_rotate_vertex(&v, jj->get_pos());
if (!(v.codes & CC_BEHIND))
{
if (!(g3_project_vertex(&v) & PF_OVERFLOW))
{
if (cur_waypoint_list == i && cur_waypoint == j)
if (cur_waypoint_list == &(*ii) && cur_waypoint == &(*jj))
gr_set_color(255, 255, 255);
else if (Waypoint_lists[i].flags[j] & WL_MARKED)
else if (Objects[jj->get_objnum()].flags & OF_MARKED)
gr_set_color(160, 255, 0);
else
gr_set_color(160, 96, 0);
g3_draw_sphere(&v, LOLLIPOP_SIZE);
if (j)
gr_set_color(0, 0, 0);
else
if (prev_vec == NULL)
gr_set_color(160, 96, 0);
else
gr_set_color(0, 0, 0);
g3_draw_sphere(&v, LOLLIPOP_SIZE * 0.66667f);
gr_set_color(160, 96, 0);
g3_draw_sphere(&v, LOLLIPOP_SIZE * 0.33333f);
}
}
render_model_x(jj->get_pos(), The_grid, 1);
gr_set_color(160, 96, 0);
if (prev_vec != NULL)
rpd_line(prev_vec, jj->get_pos());
prev_vec = jj->get_pos();
}
for (j=0; j<ptr->count; j++)
render_model_x(&ptr->waypoints[j], The_grid, 1);
gr_set_color(160, 96, 0);
for (j=1; j<ptr->count; j++)
rpd_line(&ptr->waypoints[j-1], &ptr->waypoints[j]);
}
}
@@ -584,7 +586,7 @@ void fredhtl_render_subsystem_bounding_box(subsys_to_render * s2r)
g3_rotate_vertex(&text_center, &center_pt);
g3_project_vertex(&text_center);
gr_set_color_fast(&colour_white);
gr_string_win( (int)text_center.sx, (int)text_center.sy, buf);
gr_string_win( (int)text_center.screen.xyw.x, (int)text_center.screen.xyw.y, buf);
}
void display_active_ship_subsystem()
@@ -903,7 +905,7 @@ void render_one_model_htl(object *objp)
if (Fred_outline) {
model_set_outline_color(Fred_outline >> 16, (Fred_outline >> 8) & 0xff, Fred_outline & 0xff);
j |= MR_SHOW_OUTLINE;
j |= MR_SHOW_OUTLINE_HTL;
}
g3_done_instance(0);
@@ -1002,7 +1004,7 @@ void display_distances()
if (!(g3_project_vertex(&v) & PF_OVERFLOW)) {
sprintf(buf, "%.1f", vm_vec_dist(&objp->pos, &o2->pos));
gr_set_color_fast(&colour_white);
gr_string_win((int) v.sx, (int) v.sy, buf);
gr_string_win((int) v.screen.xyw.x, (int) v.screen.xyw.y, buf);
}
}
@@ -1066,9 +1068,10 @@ void display_ship_info()
sprintf(buf, "%s\n%s", shipp->ship_name, Ship_info[ship_type].short_name);
} else if (objp->type == OBJ_WAYPOINT) {
sprintf(buf, "%s\nWaypoint %d",
Waypoint_lists[objp->instance / 65536].name,
(objp->instance & 0xffff) + 1);
int idx;
waypoint_list *wp_list = find_waypoint_list_with_instance(objp->instance, &idx);
Assert(wp_list != NULL);
sprintf(buf, "%s\nWaypoint %d", wp_list->get_name(), idx + 1);
} else if (objp->type == OBJ_POINT) {
if (objp->instance == BRIEFING_LOOKAT_POINT_ID)
@@ -1100,7 +1103,7 @@ void display_ship_info()
else
gr_set_color_fast(&colour_white);
gr_string_win((int) v.sx, (int) v.sy, buf);
gr_string_win((int) v.screen.xyw.x, (int) v.screen.xyw.y, buf);
}
}
@@ -1532,8 +1535,10 @@ void render_frame()
pos.xyz.x, pos.xyz.y, pos.xyz.z, a.h, a.p, a.b);
} else if (Objects[Cursor_over].type == OBJ_WAYPOINT) {
sprintf(buf, "%s\nWaypoint %d\n( %.1f , %.1f , %.1f ) ",
Waypoint_lists[inst / 65536].name, (inst & 0xffff) + 1, pos.xyz.x, pos.xyz.y, pos.xyz.z);
int idx;
waypoint_list *wp_list = find_waypoint_list_with_instance(inst, &idx);
Assert(wp_list != NULL);
sprintf(buf, "%s\nWaypoint %d\n( %.1f , %.1f , %.1f ) ", wp_list->get_name(), idx + 1, pos.xyz.x, pos.xyz.y, pos.xyz.z);
} else if (Objects[Cursor_over].type == OBJ_POINT) {
sprintf(buf, "Briefing icon\n( %.1f , %.1f , %.1f ) ", pos.xyz.x, pos.xyz.y, pos.xyz.z);
@@ -1547,8 +1552,8 @@ void render_frame()
gr_get_string_size(&w, &h, buf);
x = (int) v.sx;
y = (int) v.sy + 20;
x = (int) v.screen.xyw.x;
y = (int) v.screen.xyw.y + 20;
gr_set_color_fast(&colour_white);
gr_rect(x-7, y-6, w+8, h+7);
@@ -1876,6 +1881,7 @@ int object_check_collision(object *objp, vec3d *p0, vec3d *p1, vec3d *hitpos)
} else
return fvi_ray_sphere(hitpos, p0, p1, &objp->pos, (objp->radius > 0.1f) ? objp->radius : LOLLIPOP_SIZE);
mc.model_instance_num = -1;
mc.orient = &objp->orient; // The object's orient
mc.pos = &objp->pos; // The object's position
mc.p0 = p0; // Point 1 of ray to check
@@ -1953,8 +1959,8 @@ int select_object(int cx, int cy)
g3_rotate_vertex(&vt, &ptr->pos);
if (!(vt.codes & CC_BEHIND))
if (!(g3_project_vertex(&vt) & PF_OVERFLOW)) {
hitpos.xyz.x = vt.sx - cx;
hitpos.xyz.y = vt.sy - cy;
hitpos.xyz.x = vt.screen.xyw.x - cx;
hitpos.xyz.y = vt.screen.xyw.y - cy;
dist = hitpos.xyz.x * hitpos.xyz.x + hitpos.xyz.y * hitpos.xyz.y;
if ((dist < 8) && (dist < best_dist)) {
best = OBJ_INDEX(ptr);
+1 -4
View File
@@ -15,7 +15,7 @@
#include "ship/ship.h"
#include "graphics/2d.h"
#include "mission/missionparse.h"
#include "network/psnet.h"
#include "network/psnet2.h"
#include "stats/scoring.h"
#include "cfile/cfile.h"
@@ -188,7 +188,6 @@ int Framerate_delay;
void game_start_time(){}
void game_stop_time(){}
int game_get_default_skill_level(){return 0;}
void game_load_palette(){}
float FreeSpace_gamma;
int set_cdrom_path(int){return 0;}
int find_freespace_cd(char*){return 0;}
@@ -212,11 +211,9 @@ int last_single_step;
void get_version_string_short(char *){}
void game_tst_mark(struct object *, struct ship *){}
int tst;
int game_do_cd_mission_check(char *){return 1;}
//int Player_multi_died_check;
int Show_framerate = 0;
void game_feature_not_in_demo_popup() {}
void alt_tab_pause(){}
void game_feature_disabled_popup() {}
+38 -43
View File
@@ -54,7 +54,6 @@
#include "VoiceActingManager.h"
#include "FictionViewerDlg.h"
#include "cmdline/cmdline.h"
#include "debugconsole/dbugfile.h"
#include "object/objectdock.h"
#include "species_defs/species_defs.h"
#include "sound/audiostr.h"
@@ -65,7 +64,6 @@
#include "gl/glu.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
@@ -677,8 +675,9 @@ int drag_objects()
if (objp->flags & OF_MARKED) {
vm_vec_add(&objp->pos, &objp->pos, &movement_vector);
if (objp->type == OBJ_WAYPOINT) {
Waypoint_lists[objp->instance / 65536].waypoints[objp->instance & 0xffff] =
objp->pos;
waypoint *wpt = find_waypoint_with_instance(objp->instance);
Assert(wpt != NULL);
wpt->set_pos(&objp->pos);
}
}
@@ -903,15 +902,18 @@ void CFREDView::OnLButtonDown(UINT nFlags, CPoint point)
{
// RT point
int list = -1;
int waypoint_instance = -1;
if (!Fred_active) {
CView::OnLButtonDown(nFlags, point);
return;
}
if (cur_waypoint != -1)
list = cur_waypoint_list * 65536 + cur_waypoint;
if (cur_waypoint != NULL)
{
Assert(cur_waypoint_list != NULL);
waypoint_instance = Objects[cur_waypoint->get_objnum()].instance;
}
marking_box.x1 = point.x;
marking_box.y1 = point.y;
@@ -926,7 +928,7 @@ void CFREDView::OnLButtonDown(UINT nFlags, CPoint point)
if (!Bg_bitmap_dialog) {
if (on_object == -1) {
Selection_lock = 0; // force off selection lock
on_object = create_object_on_grid(list);
on_object = create_object_on_grid(waypoint_instance);
} else
Dup_drag = 1;
@@ -1310,8 +1312,8 @@ void select_objects()
g3_rotate_vertex(&v, &ptr->pos);
if (!(v.codes & CC_BEHIND) && valid)
if (!(g3_project_vertex(&v) & PF_OVERFLOW)) {
x = (int) v.sx;
y = (int) v.sy;
x = (int) v.screen.xyw.x;
y = (int) v.screen.xyw.y;
if (x >= marking_box.x1 && x <= marking_box.x2 && y >= marking_box.y1 && y <= marking_box.y2) {
if (ptr->flags & OF_MARKED)
@@ -1421,9 +1423,12 @@ void CFREDView::OnContextMenu(CWnd* /*pWnd*/, CPoint point)
str.Format("Edit %s", Objects[objnum].jnp->get_name_ptr());
} else if (Objects[objnum].type == OBJ_WAYPOINT) {
int idx;
waypoint_list *wp_list = find_waypoint_list_with_instance(Objects[objnum].instance, &idx);
Assert(wp_list != NULL);
id = ID_EDITORS_WAYPOINT;
str.Format("Edit %s:%d", Waypoint_lists[Objects[objnum].instance / 65536].name,
(Objects[objnum].instance & 0xffff) + 1);
str.Format("Edit %s:%d", wp_list->get_name(), idx + 1);
} else if (Objects[objnum].type == OBJ_POINT) {
return;
@@ -2447,12 +2452,6 @@ int CFREDView::global_error_check()
count++;
}
}
if (!count && Ships[i].weapons.num_secondary_banks > 0){
if (error("Player \"%s\" has no secondary weapons. Should have at least 1", Ships[i].ship_name)){
return 1;
}
}
}
if (Ships[i].objnum != OBJ_INDEX(ptr)){
@@ -2486,7 +2485,7 @@ int CFREDView::global_error_check()
}
// wing squad logo check - Goober5000
if (strlen(Wings[wing].wing_squad_filename) > 0)
if (strlen(Wings[wing].wing_squad_filename) > 0) //-V805
{
if (The_mission.game_type & MISSION_TYPE_MULTI)
{
@@ -2520,17 +2519,18 @@ int CFREDView::global_error_check()
}
}
} else if (ptr->type == OBJ_WAYPOINT) {
j = i / 65536; // waypoint path number
z = i & 0xffff; // waypoint number in path
if (j < 0 || j >= Num_waypoint_lists){
int waypoint_num;
waypoint_list *wp_list = find_waypoint_list_with_instance(i, &waypoint_num);
if (wp_list == NULL) {
return internal_error("Object references an illegal waypoint path number");
}
if (z >= Waypoint_lists[j].count){
if (waypoint_num < 0 || (uint) waypoint_num >= wp_list->get_waypoints().size()) {
return internal_error("Object references an illegal waypoint number in path");
}
sprintf(buf, "%s:%d", Waypoint_lists[j].name, z + 1);
sprintf(buf, "%s:%d", wp_list->get_name(), waypoint_num + 1);
names[obj_count] = new char[strlen(buf) + 1];
strcpy(names[obj_count], buf);
flags[obj_count] = 1;
@@ -2783,18 +2783,18 @@ int CFREDView::global_error_check()
return internal_error("Num_wings is incorrect");
}
for (i=0; i<Num_waypoint_lists; i++) {
SCP_list<waypoint_list>::iterator ii;
for (ii = Waypoint_lists.begin(); ii != Waypoint_lists.end(); ++ii) {
for (z=0; z<obj_count; z++){
if (names[z]){
if (!stricmp(names[z], Waypoint_lists[i].name)){
if (!stricmp(names[z], ii->get_name())){
return internal_error("Waypoint path name is also used by an object (%s)", names[z]);
}
}
}
j = Waypoint_lists[i].count;
while (j--) {
sprintf(buf, "%s:%d", Waypoint_lists[i].name, j + 1);
for (j = 0; (uint) j < ii->get_waypoints().size(); j++) {
sprintf(buf, "%s:%d", ii->get_name(), j + 1);
for (z=0; z<obj_count; z++){
if (names[z]){
if (!stricmp(names[z], buf)){
@@ -3272,7 +3272,7 @@ int CFREDView::internal_error(char *msg, ...)
int CFREDView::fred_check_sexp(int sexp, int type, char *msg, ...)
{
char buf[512], buf2[2048], buf3[4096];
char buf[512], buf2[2048], buf3[MAX_EVENT_SIZE];
int err = 0, z, faulty_node;
va_list args;
@@ -3287,7 +3287,7 @@ int CFREDView::fred_check_sexp(int sexp, int type, char *msg, ...)
if (!z)
return 0;
convert_sexp_to_string(sexp, buf2, SEXP_ERROR_CHECK_MODE, 2048);
convert_sexp_to_string(sexp, buf2, SEXP_ERROR_CHECK_MODE, MAX_EVENT_SIZE);
sprintf(buf3, "Error in %s: %s\n\nIn sexpression: %s\n(Error appears to be: %s)",
buf, sexp_error_message(z), buf2, Sexp_nodes[faulty_node].text);
@@ -3396,10 +3396,10 @@ char *error_check_initial_orders(ai_goal *goals, int ship, int wing)
found = 0;
if (flag > 0) {
if (*goals[i].ship_name == '<')
if (*goals[i].target_name == '<')
return "Invalid target";
if (!stricmp(goals[i].ship_name, source))
if (!stricmp(goals[i].target_name, source))
if (ship >= 0)
return "Target of ship's goal is itself";
else
@@ -3408,11 +3408,7 @@ char *error_check_initial_orders(ai_goal *goals, int ship, int wing)
inst = team2 = -1;
if (flag == 1) { // target waypoint required
for (j=0; j<Num_waypoint_lists; j++)
if (!stricmp(goals[i].ship_name, Waypoint_lists[j].name))
found = 1;
if (!found)
if (find_matching_waypoint_list(goals[i].target_name) == NULL)
return "*Invalid target waypoint path name";
} else if (flag == 2) { // target ship required
@@ -3420,7 +3416,7 @@ char *error_check_initial_orders(ai_goal *goals, int ship, int wing)
while (ptr != END_OF_LIST(&obj_used_list)) {
if (ptr->type == OBJ_SHIP || ptr->type == OBJ_START) {
inst = ptr->instance;
if (!stricmp(goals[i].ship_name, Ships[inst].ship_name)) {
if (!stricmp(goals[i].target_name, Ships[inst].ship_name)) {
found = 1;
break;
}
@@ -3441,7 +3437,7 @@ char *error_check_initial_orders(ai_goal *goals, int ship, int wing)
} else if (flag == 3) { // target wing required
for (j=0; j<MAX_WINGS; j++)
if (Wings[j].wave_count && !stricmp(Wings[j].name, goals[i].ship_name))
if (Wings[j].wave_count && !stricmp(Wings[j].name, goals[i].target_name))
break;
if (j >= MAX_WINGS)
@@ -3459,13 +3455,13 @@ char *error_check_initial_orders(ai_goal *goals, int ship, int wing)
while (ptr != END_OF_LIST(&obj_used_list)) {
if (ptr->type == OBJ_SHIP || ptr->type == OBJ_START) {
inst = ptr->instance;
if (!stricmp(goals[i].ship_name, Ships[inst].ship_name)) {
if (!stricmp(goals[i].target_name, Ships[inst].ship_name)) {
found = 2;
break;
}
} else if (ptr->type == OBJ_WAYPOINT) {
if (!stricmp(goals[i].ship_name, object_name(OBJ_INDEX(ptr)))) {
if (!stricmp(goals[i].target_name, object_name(OBJ_INDEX(ptr)))) {
found = 1;
break;
}
@@ -4590,7 +4586,6 @@ void CFREDView::OnDestroy()
{
audiostream_close();
snd_close();
DBUGFILE_OUTPUT_0("About to gr_close");
gr_close();
os_set_window(NULL);
-1
View File
@@ -18,7 +18,6 @@
#include "editor.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
Loaded 100 of 746 files, more files were not shown because too many files have changed in this diff. Show more