Commit graph

121 commits

Author SHA1 Message Date
Daniel Gibson
7dcae96bae Fix -Wformat-security warnings - thanks James Addison!
This is based on https://github.com/dhewm/dhewm3/pull/500
by https://github.com/jayaddison

See also https://github.com/blendogames/quadrilateralcowboy/pull/4
2024-03-18 23:56:51 +01:00
Daniel Gibson
d6caed016e Fix renderlights loaded from savegames aliasing other lights
Some entities wrote the handle from gameRenderWorld->AddLightDef()
into savegames and reused it after restoring it.
That's a bad idea, because at that point the handle most likely belongs
to something else (likely some idLight). The most visible issue this
can create is that the flashlight may not work correctly after loading
a savegame with flashlight on, when it happens to alias a light that's
updated each frame to (mostly) being off..

The correct way to handle this (THAT FOR SOME REASON WAS ALREADY
IMPLEMENTED IN D3XP BUT NOT THE BASE GAME - WHY?!) is to get a fresh
handle with AddLightDef() when restoring a savegame - unless the handle
was -1, which means that the light didn't exist when saving.

fixes #495
2024-03-18 23:56:40 +01:00
Daniel Gibson
ce46ff9c9d Fix some ubsan warnings 2024-03-18 23:51:39 +01:00
Daniel Gibson
0e135ff901 StartSoundShader() event: special-case for soundName "", refs #494
Some level scripts in d3xp (erebus4, erebus4, phobos2) use
  $entity.startSoundShader( "", SND_CHANNEL_BODY );
(or whatever channel) to stop the sound currently playing there.
With s_playDefaultSound 1 that results in a beep..
Added a special case to that event implementation to call StopSound()
instead when the soundName is "" (or NULL)
2024-03-18 23:51:39 +01:00
Daniel Gibson
e093ace3e4 Improve some messages in game code
- TestHugeTranslation() prints positions (and asserts only afterwards),
  from "Work around assertion in alphalabs4, fix #409"
- idCompiler::CompileFile() prints proper filename
  from "Fix usage of invalid pointer in idCompiler::CompileFile()"
2022-05-29 01:13:53 +02:00
Daniel Gibson
3d19e0e20f Use idStr::Copynz() instead of strncpy()
to guarantee \0-termination
(only the applicable parts of that dhewm3 commit)
2022-05-29 01:13:53 +02:00
Daniel Gibson
79f58c761c From dhewm3: Fix most (according to warnings) remaining 64bit issues in tool code
only the TypeInfo changes are applicable to the SDK
2022-05-29 01:13:53 +02:00
Daniel Gibson
21aa6d4930 Remove usage of C++11 nullptr 2022-05-29 01:13:53 +02:00
Daniel Gibson
ffa6aed043 Fix player's clipModel->axis when loading savegame, fixes #328
idClipModel::axis is an idMat3 rotation matrix.
Usually it's an identity matrix, but if the player is pushed around by
an idPush entity it's modified and apparently can (wrongly) remain
modified, possibly when saving while idPush is active.
This seems to happen sometimes on the crashing elevator in game/delta1.
The fix/workaround is to reset it to mat3_identity when loading a
savegame.
2021-02-22 06:07:51 +01:00
Daniel Gibson
70f01e6c9f Add information about dhewm3 build to savegames
like the dhewm3 version and the OS and architecture of the dhewm3
version that created the savegame.
Also added an internalSavegameVersion so be independent of BUILD_NUMBER

fixes #344
2021-02-22 06:06:22 +01:00
Daniel Gibson
ad2bb56fed Fix savegame-compatibility of scripts, increase BUILD_NUMBER
"Fix "t->c->value.argSize == func->parmTotal" Assertion in Scripts, #303"
had broken old savegames because the script checksum
(idProgram::CalculateChecksum()) changed, see #344.
This is fixed now, also the BUILD_NUMBER is increased so old savegames
can be identified for a workaround.

Don't use this commit without the next one which will further modify the
savegame format (for the new BUILD_NUMBER 1305)
2021-02-22 06:06:22 +01:00
Daniel Gibson
1f0e16fae2 Fix "t->c->value.argSize == func->parmTotal" Assertion in Scripts, #303
If a "class" (object) in a Script has multiple member function
prototypes, and one function implementation later calls another before
that is implemented, there was an assertion when the script was parsed
(at map start), because the size of function arguments at the call-site
didn't match what the function expected - because the function hadn't
calculated that size yet, that only happened once its own
implementation was parsed.
Now it's calculated (and stored) when the prototype/declaration is
parsed to prevent this issue, which seems to be kinda common with Mods,
esp. Script-only mods, as the release game DLLs had Assertions disabled.
2021-01-18 03:05:03 +01:00
Daniel Gibson
335858bd5a Fix lingering messages in HUD after loading savegame
If you save, you get a message like "Game Saved..." which goes away
after a few seconds. This happens at the very end of idPlayer::Save():
    if ( hud ) {
        hud->SetStateString( "message", /* .. left out .. */ );
        hud->HandleNamedEvent( "Message" );
    }
And handled in hud.gui, "onNamedEvent Message { ..."

However, if you save again before it's gone, it'll be shown after
loading the savegame and not go away until you save again..
This works around that issue by setting an empty message after loading
a savegame.

The underlying problem (which is not fixed!) seems to be that the
transition GUI command (that's executed when hud.gui handles the
"Message" event that's used to show this message) is probably not
properly saved/restored so fading out the message isn't continued
after loading.
2021-01-18 03:05:01 +01:00
revility
8d0cbcc054 weapons may cast shadows now
Player weapons can now cast shadows.  Materials might need to be updated as well to fully work.
2020-05-31 22:03:38 +02:00
revility
c793d85bcb Fixed no_stamina disabling shield gauge
Commented out the no_stamina bit.  Stamina in Rivensin is used for the energy shield and not running.  If this was set in a map, the shield was disabled.  Noticeable if playing some user made maps and Hell levels in vanilla campaign.
2020-02-14 03:30:06 +01:00
Daniel Gibson
b651f9dc1d Hopefully fix "shooting arrows at Dead Souls" freezing game
For some reason the idMoveableArrow's animator didn't have a modelDef,
which caused masterAnimator->GetJointTransform() to return immediately
without setting masterAxis or masterOrigin - so they contained garbage
data which lead to NaNs which lead to trouble.

I check for that issue now to make sure they're initialized, but I'm not
100% sure this is a proper fix - the underlying issue is that this
animator has no modelDef. Is that bad? Could it create other issues?
No idea.
2019-01-05 06:09:17 +01:00
revility
54a98ddfe5 ejectbrass fix
brass was not ejecting from the weapon models due to checking if view models are shown... but this is a thirdperson mod and none are used.
2018-11-22 04:11:15 +01:00
Daniel Gibson
3240589cec idProjectile::Launch() warns about missing snd_tracer 2018-11-18 19:12:43 +01:00
Daniel Gibson
53ab8e1031 Fix some (mostly Savegame-related) Crashes
Somehow I must have added that
savefile->WriteFloat( spreadCrouchFactor );
twice when merging the Ruiner/Rivensin changes into the SDK.. damn.
(As it's only read once, all data read from the savegame after it
 will be garbage)

I had a crash when creating a Savegame in idAnimState::Save(),
because animator was NULL - so I added a check for that.

The rest has been found with GCC address sanitizer (ASan)
2018-11-18 06:07:31 +01:00
Daniel Gibson
1fe2a59637 (Hopefully) fix one of the assertions rarely happening in Rivensen
I hope I guessed this right: This could prevent the rare assertion
in RenderWorld.cpp:954 ("bounds[0][0] <= bounds[1][0]
  && bounds[0][1] <= bounds[1][1] && bounds[0][2] <= bounds[1][2]").
2018-11-11 23:55:26 +01:00
Daniel Gibson
97aa34a2f2 cursor and ingame menu scaling
Cursor now uses 2 different guis based upon aspect ratio just like
the hud. This is due to the translations of of the cross hairs being
off if a 4:3 cursor is on top of a 16:9 render view.
Requires additional key in the player def just like the hud does.
In game menu no longer stretches. Looks much better.
This is the menu that displays the advanced controls.

(DG: based on revility's commit with same message, removed stuff already
 implemented here and cleaned up the rest a bit)
2018-11-11 23:51:42 +01:00
Daniel Gibson
b54c0ffefd Load guis/hud16_9.gui when using a widescreen resolution 2018-11-05 01:21:14 +01:00
revility
435b835d59
updated a few default settings
pm_crouchviewheight updated.  origin was set from near the player's stomach and not the neck
pm_thirdpersonsidescale default value reduced.  Player can still adjust the amount in the main menu.
2018-11-03 16:17:26 -04:00
revility
b26313e2ef
pm_crossHairSideScale added
Added new cvar pm_crossHairSideScale
Corrected description of pm_ProjectileOrigin....  this does not effect projectiles.  Only the tracers, models or particles attached to them.
2018-10-30 18:59:49 -04:00
revility
6caceeb84b
pm_crossHairSideScale added 2018-10-30 18:56:49 -04:00
revility
6117962437
offset view position
adds a new cvar pm_crossHairSideScale to move the view position origin sideways.  Useful if pm_crosshairorigin is set to 0 and aiming around corners.  weapon projectiles use this as their spawn position. cross hairs use it as the origin of the trace line. default is 0. player should adjust to their liking and current camera settings. If set too far over, the player can shoot around walls.
2018-10-30 18:55:54 -04:00
revility
83a1d2a83d
smoothen crosshairs when attached to bone
removed bobbing and jittering while the crosshair origin is set to use a joint on the player model (pm_crosshairorigin 1). Was very noticeable while looking at steps.
2018-10-29 20:47:57 -04:00
revility
d903e48819 Increased max globals
Needed if you want to play some of the vanilla doom 3 maps by default.  Note that you will need to update more stuff like statements, globals, etc. for the game to start with all of them.  Another note that the scripts are not loaded by default in ruiner/Rivensin due to none of the maps being tested.  Most of them are not third person friendly.  Someday I hope to get a mini version of the campaign ported.
2018-10-21 04:31:15 +02:00
revility
de2705c680 enabled firstperson view when using guis
Game will go into first person while at a gui and then back to thirdperson when leaving.  Needed for maps which use gui consoles in them.  Check comments in code for full details.  Probably a better way to do this.
2018-10-21 04:31:15 +02:00
revility
e8267fd6c0 CheckCrossHairOrigin added
CheckCrossHairOrigin is used when entering and exiting guis to get the player's current setting and restore it when leaving the gui.  Check the player.cpp for full details.
2018-10-21 04:31:15 +02:00
revility
f060e97aae pm_thirdperson cvar archive removed
This was done so pm_thirdperson wil always reset to 1 when starting the game.  If the game crashes or quits while in first person it was starting back up in it before.
2018-10-21 04:31:15 +02:00
revility
1f82525502 pm_projectileOrigin added
New cvar to enable and disable launching projectiles from the weapon's world model barrel joint and also towards the crosshair's position.  launchfrombarrel must be set to 0 in projectile def files to use.  Done incase a weapon doesn't need it or has issues using it in the future.  none currently do.
2018-10-21 04:31:15 +02:00
revility
d92edb81e2 pm_projectileorigin added
new cvar to enable and disable the new projectile direction correction for weapons.  check the weapon.cpp for more info.
2018-10-21 04:31:15 +02:00
revility
10be5f2713 pm_crossHairOrigin added
Changes cross hair trace line origin from the camera's origin to a joint on the player's model defined in player.cpp file
Done this way because pm_modelview cvar has some kind of over ride going on when the levels start.  Consider this a work  around fix.
2018-10-21 04:31:15 +02:00
revility
918d780d36 added pm_crossHairOrigin cvar
Changes cross hair trace line origin from the camera's origin to a joint on the player's model defined in player.cpp file
2018-10-21 04:31:15 +02:00
revility
63152f3283 Weapon firing bug fix
Not sure how or why it happened, but the code was causing the bow to use wrong cross hairs, and auto weapon switch.  I believe there was a mistake on my end when cleaning up the code in the player.cpp and playercursor.cpp files.
Additionally having a second weapon to use the soul cube hud notice is not needed as the planned weapon is not happening anytime soon.
2018-10-21 04:31:15 +02:00
revility
8d95330115 Added soulcube clone
Only the soul cube can display hud notifications when enough kills are done.  this adds support for a 2nd weapon to do so. weapon is not in 2010 but will be 2018 build.  Code should still be compatible with 2010 build.
2018-10-21 04:31:15 +02:00
revility
066c8b3263 always enable pm_modelview
fix pm_modelview resetting on map loads.  Cross hair fix.  Still needs some tweaks and test.
2018-10-21 04:31:15 +02:00
revility
5eb99fb857 Cleaned code
Removed commented code from early 2000's tests.  Was never used. 
Cleaned up my comments a bit too :)
2018-10-21 04:31:15 +02:00
revility
451cb994ee Removed commented out code
Removed commented out code.  Was from very old cross hair system back in the early 2000's.
2018-10-21 04:31:15 +02:00
revility
72f407bbd7 cvar_archive hdr, pm_modelview, pm_thirdperson
This should fix hdr always resetting every time the game is restarted, thirdperson view sometimes not enabled by default, and the need for pm_modelview to be turned on for cross hair trace line origin fix.
Also cleaned up formatting around hdr cvars, and third person camera cvars.
2018-10-21 04:31:15 +02:00
revility
825f5f8372 pm_modelview enabled by default
Enabling the pm_modelview and setting the correct joint in the player.cpp file corrects issues with the trace line used for creating thirdperson crosshair getting cut off early due to objects being to close.  Most mostly noticeable shooting around corners.
2018-10-21 04:31:15 +02:00
revility
e8744d3172 Headshot Frozen ragdoll bug fix
line 2403
2018-10-21 04:31:15 +02:00
revility
37780e0801 New shield int
tellishield is used in player.cpp as part of the shield/shield spell system.
Mostly used in game script to check if the shield is active or not.
2018-10-21 04:31:15 +02:00
revility
3a5de32467 launch projectile direction updated.
Further comments on changes to launching projectiles and "launchfrombarrel" key used in projectile defs.
2018-10-21 04:31:15 +02:00
revility
81931da8c5 Replaced stamina system with shield system
Stamina is now used for the player's shield spell.  hold down the old zoom key to activate while the player has stamina.  Calls are made to the player's script to UpdateSkin.  UpdateSkin is new and not apart of vanilla d3 or Rivensin 2010 build
Stamina use also is no longer associated with player's movement and does not adjust movement speed.
The telishield key is used via the player script file to check if active and change the torso animations to blocking/spell casting.
2018-10-21 04:31:15 +02:00
revility
864fa1fd3d Update Player.cpp
Added the telishield key for the player def and script to use.  This key disables the player taking damage and can be checked in the script for stuff like changing skins, etc.

cross hair fix:  pm_modelview .  This cvar changes the origin of the playerview to a joint for the crosshairs.  This is set to a joint close to the player weapons to prevent the trace line used for cross hairs stopping too early when shooting around corners. 
Additionally pm_modelview's axis is now the renderview axis and not the joint other wise the thirdperson crosshair is displayed in wrong directions.
pm_modelview is now on by default.
2018-10-21 04:31:15 +02:00
revility
d1093579ff Update Player.h
adds the telishield key for the player.def & script to use.  When set to 1, the player will take no damage.  Done this way so we can check it and also apply other effects such as player skin changing.
2018-10-21 04:31:15 +02:00
revility
dd30a38bb1 Update Weapon.cpp
launch from barrel is no longer needed for projectiles to launch from the weapon's barrel, and then to the thirdperson cross hair position.  This fixes the projectiles not launching to the center of the thirdperson cross and also fixes the offset when aiming too high or too low.
projectiles in weapon.def files need launchfrombarrel set to 0 for this work.  the crosshair offsets also need to be adjust in the cursor.gui file as each one offset manually in Rivensin/Ruiner 2010 build.
2018-10-21 04:31:15 +02:00
revility
85352e4a48 Update Actor.cpp
sdk side of the fix to stop ragdolls from freezing during a head shot.  Other parts were in the ai script files due too much sys.waits.
2018-10-21 04:31:15 +02:00