[chronojump] Jumps profile says error in index if DJa is lower than a jump
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Jumps profile says error in index if DJa is lower than a jump
- Date: Thu, 7 Jan 2021 18:51:31 +0000 (UTC)
commit 8b38988b58e5687153131cd8a9f01f44e51b7a6c
Author: Xavier de Blas <xaviblas gmail com>
Date: Thu Jan 7 19:50:26 2021 +0100
Jumps profile says error in index if DJa is lower than a jump
src/jumpsProfile.cs | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
---
diff --git a/src/jumpsProfile.cs b/src/jumpsProfile.cs
index 54abda88..a32ec870 100644
--- a/src/jumpsProfile.cs
+++ b/src/jumpsProfile.cs
@@ -27,7 +27,7 @@ public class JumpsProfileIndex
{
public string name;
- public enum ErrorCodes { NEEDJUMP, NEGATIVE, NONE_OK }
+ public enum ErrorCodes { NEEDJUMP, NEGATIVE, DJATOOLOW, NONE_OK }
public ErrorCodes errorCode;
public string Text;
public Cairo.Color Color;
@@ -76,6 +76,8 @@ public class JumpsProfileIndex
ErrorMessage = Catalog.GetString("Need to execute jump/s"); //TODO: write which jumps
else if(errorCode == ErrorCodes.NEGATIVE)
ErrorMessage = string.Format(Catalog.GetString("Negative index: {0} is higher than
{1}"), jumpLowerName, jumpHigherName);
+ else if(errorCode == ErrorCodes.DJATOOLOW)
+ ErrorMessage = string.Format("Jump {0} too low", "Dja"); //TODO: Catalog on this
string
}
private double calculateIndex (Types type, double higher, double lower, double dja)
@@ -88,7 +90,17 @@ public class JumpsProfileIndex
}
if(type == Types.FMAX) //this index only uses higher
+ {
+ if(higher > dja)
+ {
+ errorCode = ErrorCodes.DJATOOLOW;
+ return 0;
+ }
+
+ LogB.Information(string.Format("calculateIndex, type:{0}, higher:{1}, lower:{2},
dja:{3}, value:{4}",
+ type, higher, lower, dja, higher/dja));
return higher / dja;
+ }
if(lower == 0) {
errorCode = ErrorCodes.NEEDJUMP;
@@ -100,6 +112,15 @@ public class JumpsProfileIndex
//return 0;
}
+ if(higher > dja) // at least a jump is higher than DJa
+ {
+ errorCode = ErrorCodes.DJATOOLOW;
+ return 0;
+ }
+
+ LogB.Information(string.Format("calculateIndex, type:{0}, higher:{1}, lower:{2}, dja:{3},
value:{4}",
+ type, higher, lower, dja, (higher-lower)/dja));
+
return (higher - lower) / dja;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]