Skip to content

Commit

Permalink
Updated to Version 1.19.5-rc.1
Browse files Browse the repository at this point in the history
  • Loading branch information
VintageStory CI committed Mar 7, 2024
1 parent f979d49 commit 80bba40
Show file tree
Hide file tree
Showing 1,014 changed files with 25,749 additions and 25,385 deletions.
20 changes: 14 additions & 6 deletions Client/Input/EnumGlKeys.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using OpenTK.Windowing.GraphicsLibraryFramework;

namespace Vintagestory.API.Client
Expand Down Expand Up @@ -53,16 +54,23 @@ public static string GetKeyName(GlKeys key)
}
return keyName.ToUpperInvariant();
}

/// <summary>
/// Returns the printable character for a key. Does return null on none printable keys like <see cref="GlKeys.Enter"/>
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static string GetPrintableChar(int key)
{
var keycode = KeyConverter.GlKeysToNew[key];
return GLFW.GetKeyName((Keys)keycode, 0);
try
{
var keycode = KeyConverter.GlKeysToNew[key];
return GLFW.GetKeyName((Keys)keycode, 0);
}
catch (IndexOutOfRangeException)
{
return string.Empty;
}
}
}

Expand Down Expand Up @@ -210,11 +218,11 @@ static KeyConverter()
}
}
}

/// <summary>
/// Internally the game uses OpenTK and their Keys are by default mapped to US QWERTY Keyboard layout which the GlKeys also do.
/// Upon typing text in a Text input field it will produce the correct characters according to your keyboard layout.
///
///
/// If you need to get the character for the current Keyboard layout use <see cref="GlKeyNames.GetKeyName"/>
/// </summary>
public enum GlKeys
Expand Down Expand Up @@ -366,4 +374,4 @@ public enum GlKeys

// We reserve 240-248 for mouse buttons - see also KeyCombination.MouseStart
}
}
}
8 changes: 7 additions & 1 deletion Client/Texture/ITextureSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,16 @@ protected TextureAtlasPosition getOrCreateTexPos(AssetLocation texturePath)
if (texAsset != null)
{
targetAtlas.GetOrInsertTexture(texturePath, out _, out texpos, () => texAsset.ToBitmap(capi));
if (texpos == null)
{
capi.World.Logger.Error("{0}, require texture {1} which exists, but unable to upload it or allocate space", sourceForErrorLogging, texturePath);
texpos = targetAtlas.UnknownTexturePosition;
}
}
else
{
capi.World.Logger.Warning("{0}, require texture {1}, but no such texture found.", sourceForErrorLogging, texturePath);
capi.World.Logger.Error("{0}, require texture {1}, but no such texture found.", sourceForErrorLogging, texturePath);
texpos = targetAtlas.UnknownTexturePosition;
}
}

Expand Down
15 changes: 15 additions & 0 deletions Client/UI/CairoFont.cs
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,21 @@ public static CairoFont WhiteSmallishText()
};
}

/// <summary>
/// Creates a white text for smallish dialogs, using the specified base font
/// </summary>
/// <param name="baseFont"></param>
/// <returns></returns>
public static CairoFont WhiteSmallishText(string baseFont)
{
return new CairoFont()
{
Color = (double[])GuiStyle.DialogDefaultTextColor.Clone(),
Fontname = baseFont,
UnscaledFontsize = GuiStyle.SmallishFontSize
};
}

/// <summary>
/// Creates a white text for small dialogs.
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions Common/API/IEventAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ public interface IEventAPI
/// </summary>
/// <param name="OnTimePassed"></param>
/// <param name="millisecondDelay"></param>
/// <param name="permittedWhilePaused"></param>
/// <returns>listenerId</returns>
long RegisterCallback(Action<float> OnTimePassed, int millisecondDelay, bool permittedWhilePaused);

Expand Down
2 changes: 1 addition & 1 deletion Common/Collectible/Collectible.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1671,7 +1671,7 @@ public virtual void GetHeldItemInfo(ItemSlot inSlot, StringBuilder dsc, IWorldAc



if (GrindingProps != null)
if (GrindingProps?.GroundStack?.ResolvedItemstack != null)
{
dsc.AppendLine(Lang.Get("When ground: Turns into {0}x {1}", GrindingProps.GroundStack.ResolvedItemstack.StackSize, GrindingProps.GroundStack.ResolvedItemstack.GetName()));
}
Expand Down
6 changes: 5 additions & 1 deletion Common/Entity/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1467,10 +1467,14 @@ public virtual void UpdateDebugAttributes()
{
if (World.Side != EnumAppSide.Client) return;

DebugAttributes.SetString("Entity Id", ""+EntityId);
DebugAttributes.SetString("Entity Id", "" + EntityId);
DebugAttributes.SetString("Yaw", string.Format("{0:0.##}", Pos.Yaw));

if (AnimManager != null) UpdateAnimationDebugAttributes(); // for EntityItem, AnimManager will be null
}

protected virtual void UpdateAnimationDebugAttributes()
{
string anims = "";
int i = 0;
foreach (string anim in AnimManager.ActiveAnimationsByAnimCode.Keys)
Expand Down
7 changes: 0 additions & 7 deletions Common/Entity/EntityAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -603,13 +603,6 @@ protected virtual void HandleHandAnimations(float dt)

}

public virtual void StopHandAnims()
{

}



/// <summary>
/// updated by GetWalkSpeedMultiplier()
/// </summary>
Expand Down
14 changes: 13 additions & 1 deletion Common/Entity/EntityItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,19 @@ public override void Initialize(EntityProperties properties, ICoreAPI api, long

public override void OnGameTick(float dt)
{
if (World.Side == EnumAppSide.Client) base.OnGameTick(dt);
if (World.Side == EnumAppSide.Client)
{
try
{
base.OnGameTick(dt);
}
catch (Exception e)
{
if (World == null) throw new NullReferenceException("'World' was null for EntityItem; entity is " + (alive ? "alive" : "post-lifetime"));
Api.Logger.Error("Erroring EntityItem tick: please report this as a bug!");
Api.Logger.Error(e);
}
}
else
{
// simplified server tick
Expand Down
27 changes: 20 additions & 7 deletions Common/Entity/EntityPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ public override double GetWalkSpeedMultiplier(double groundDragFactor = 0.3)
public void OnSelfBeforeRender(float dt)
{
updateEyeHeight(dt);
HandleSeraphHandAnimations(dt);
}


Expand Down Expand Up @@ -762,7 +763,7 @@ void updateLocalEyePosImmersiveFpMode()
float strongWindAccum = 0;
bool haveHandUseOrHit;

protected override void HandleHandAnimations(float dt)
public void HandleSeraphHandAnimations(float dt)
{
protectEyesFromWind(dt);

Expand All @@ -780,8 +781,7 @@ protected override void HandleHandAnimations(float dt)
bool wasUseStack = plrAnimMngr.IsHeldUseActive();

bool nowHitStack = interact == EnumHandInteract.HeldItemAttack || servercontrols.LeftMouseDown;
bool wasHitStack = plrAnimMngr.IsHeldHitActive();

bool wasHitStack = plrAnimMngr.IsHeldHitActive(1f);

string nowHeldRightUseAnim = rightstack?.Collectible.GetHeldTpUseAnimation(RightHandItemSlot, this);
string nowHeldRightHitAnim = rightstack?.Collectible.GetHeldTpHitAnimation(RightHandItemSlot, this);
Expand Down Expand Up @@ -850,10 +850,23 @@ protected override void HandleHandAnimations(float dt)
bool authorative = plrAnimMngr.IsHeldHitAuthorative();
plrAnimMngr.StopHeldAttackAnim();

if (!authorative && nowHitStack)
if (plrAnimMngr.lastRunningHeldHitAnimation != null && authorative)
{
if (servercontrols.LeftMouseDown)
{
plrAnimMngr.ResetAnimation(nowHeldRightHitAnim);
controls.HandUse = EnumHandInteract.None;
plrAnimMngr.StartHeldHitAnim(nowHeldRightHitAnim);
haveHandUseOrHit = true;
}

} else
{
plrAnimMngr.StartHeldHitAnim(nowHeldRightHitAnim);
haveHandUseOrHit = true;
if (!authorative && nowHitStack)
{
plrAnimMngr.StartHeldHitAnim(nowHeldRightHitAnim);
haveHandUseOrHit = true;
}
}
}

Expand Down Expand Up @@ -990,7 +1003,7 @@ protected bool canPlayEdgeSitAnim()

Block frontBelowBlock = bl.GetBlock(frontBelowPos);
var frontBellowCollBoxes = frontBelowBlock.GetCollisionBoxes(bl, frontBelowPos);
if (frontBellowCollBoxes == null) return true;
if (frontBellowCollBoxes == null || frontBellowCollBoxes.Length == 0) return true;

double sitHeight = pos.Y - (frontBelowPos.Y + frontBellowCollBoxes.Max(box => box.Y2));

Expand Down
12 changes: 6 additions & 6 deletions Common/Entity/PlayerAnimationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,16 @@ public override bool IsAnimationActive(params string[] anims)
return base.IsAnimationActive(anims);
}

public bool IsAnimationActiveOrRunning(string anim)
public bool IsAnimationActiveOrRunning(string anim, float untilProgress = 0.95f)
{
if (anim == null || Animator == null) return false;
return IsAnimationMostlyRunning(anim) || IsAnimationMostlyRunning(anim + fpEnding);
return IsAnimationMostlyRunning(anim, untilProgress) || IsAnimationMostlyRunning(anim + fpEnding, untilProgress);
}

protected bool IsAnimationMostlyRunning(string anim)
protected bool IsAnimationMostlyRunning(string anim, float untilProgress = 0.95f)
{
var ranim = Animator.GetAnimationState(anim);
return ranim != null && ranim.Running && ranim.AnimProgress < 0.95;
return ranim != null && ranim.Running && ranim.AnimProgress < untilProgress && ranim.Active /* ranim.Active check makes a short left mouse click with axe in hands look much better */;
}

protected override void onReceivedServerAnimation(AnimationMetaData animmetadata)
Expand Down Expand Up @@ -271,9 +271,9 @@ public bool IsHeldUseActive()
return lastActiveHeldUseAnimation != null && IsAnimationActiveOrRunning(lastActiveHeldUseAnimation);
}

public bool IsHeldHitActive()
public bool IsHeldHitActive(float untilProgress = 0.95f)
{
return lastActiveHeldHitAnimation != null && IsAnimationActiveOrRunning(lastActiveHeldHitAnimation);
return lastActiveHeldHitAnimation != null && IsAnimationActiveOrRunning(lastActiveHeldHitAnimation, untilProgress);
}

public bool IsLeftHeldActive()
Expand Down
3 changes: 2 additions & 1 deletion Common/Model/Animation/AnimationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ public virtual void ResetAnimation(string animCode)
var state = Animator?.GetAnimationState(animCode);
if (state != null)
{
state.EasingFactor = 0;
//state.EasingFactor = 0;
state.CurrentFrame = 0;
state.Iterations = 0;
}
}

Expand Down
2 changes: 1 addition & 1 deletion Common/Model/Animation/RunningAnimation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class RunningAnimation

public ShapeElementWeights[] ElementWeights;

public float AnimProgress => CurrentFrame / Animation.QuantityFrames;
public float AnimProgress => CurrentFrame / (Animation.QuantityFrames-1);

public void LoadWeights(ShapeElement[] rootElements)
{
Expand Down
6 changes: 3 additions & 3 deletions Config/GameVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ public static class GameVersion
/// <summary>
/// Assembly Info Version number in the format: major.minor.revision
/// </summary>
public const string OverallVersion = "1.19.4";
public const string OverallVersion = "1.19.5";

/// <summary>
/// Whether this is a stable or unstable version
/// </summary>
public const EnumGameBranch Branch = EnumGameBranch.Stable;
public const EnumGameBranch Branch = EnumGameBranch.Unstable;

/// <summary>
/// Version number in the format: major.minor.revision[appendix]
/// </summary>
public const string ShortGameVersion = OverallVersion + "";
public const string ShortGameVersion = OverallVersion + "-rc.1";

public static EnumReleaseType ReleaseType => GetReleaseType(ShortGameVersion);

Expand Down
36 changes: 36 additions & 0 deletions Util/StringUtil.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,49 @@
using System;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Globalization;
using System.Numerics;
using System.Text;
using Vintagestory.API.Config;

namespace Vintagestory.API.Util
{
public static class StringUtil
{
// Use this if and only if 'Denial of Service' attacks are not a concern (i.e. never used for free-form user input),
// or are otherwise mitigated
public static unsafe int GetNonRandomizedHashCode(this string str)
{
fixed (char* src = str)
{
Debug.Assert(src[str.Length] == '\0', "src[this.Length] == '\\0'");
Debug.Assert(((int)src) % 4 == 0, "Managed string should start at 4 bytes boundary");

uint hash1 = (5381 << 16) + 5381;
uint hash2 = hash1;

uint* ptr = (uint*)src;
int length = str.Length;

while (length > 2)
{
length -= 4;
// Where length is 4n-1 (e.g. 3,7,11,15,19) this additionally consumes the null terminator
hash1 = (BitOperations.RotateLeft(hash1, 5) + hash1) ^ ptr[0];
hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ ptr[1];
ptr += 2;
}

if (length > 0)
{
// Where length is 4n-3 (e.g. 1,5,9,13,17) this additionally consumes the null terminator
hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ ptr[0];
}

return (int)(hash1 + (hash2 * 1566083941));
}
}

/// <summary>
/// IMPORTANT! This method should be used for every IndexOf operation in our code (except possibly in localised output to the user). This is important in order to avoid any
/// culture-specific different results even when indexing GLSL shader code or other code strings, etc., or other strings in English, when the current culture is a different language
Expand Down
Loading

0 comments on commit 80bba40

Please sign in to comment.