Fix warnings in fix library

Fix most of "narrowing conversion" warnings.
This commit is contained in:
Azamat H. Hackimov
2024-04-27 02:26:20 +03:00
committed by Jeod
parent 536b83d10f
commit 48a97dec38
2 changed files with 19 additions and 22 deletions

View File

@@ -64,18 +64,17 @@
* $NoKeywords: $
*/
#include "fix.h"
#include <cmath>
#include <ctime>
#include <time.h>
#include <stdlib.h>
#include "fix.h"
#include "psrand.h"
// Tables for trig functions
float sincos_table[321]; // 256 entries + 64 sin-only + 1 for interpolation
angle asin_table[257]; // 1 quadrants worth, +1 for interpolation
angle acos_table[257];
#define PI 3.141592654
// Generate the data for the trig tables
void InitMathTables() {
int i;
@@ -83,13 +82,13 @@ void InitMathTables() {
for (i = 0; i < 321; i++) {
rad = (float)((double)i / 256.0 * 2 * PI);
sincos_table[i] = (float)sin(rad);
sincos_table[i] = std::sin(rad);
}
for (i = 0; i < 256; i++) {
s = asin((float)i / 256.0);
c = acos((float)i / 256.0);
s = std::asin((float)i / 256.0f);
c = std::acos((float)i / 256.0f);
s = (s / (PI * 2));
c = (c / (PI * 2));
@@ -102,7 +101,7 @@ void InitMathTables() {
acos_table[256] = acos_table[255];
// Initialize a random seed.
ps_srand(time(NULL));
ps_srand(time(nullptr));
}
// Returns the sine of the given angle. Linearly interpolates between two entries in a 256-entry table
@@ -179,7 +178,7 @@ angle FixAsin(float v) {
fix vv;
int i, f, aa;
vv = FloatToFix(fabs(v));
vv = FloatToFix(std::fabs(v));
if (vv >= F1_0) // check for out of range
return 0x4000;
@@ -201,7 +200,7 @@ angle FixAcos(float v) {
fix vv;
int i, f, aa;
vv = FloatToFix(fabs(v));
vv = FloatToFix(std::fabs(v));
if (vv >= F1_0) // check for out of range
return 0;
@@ -231,12 +230,12 @@ angle FixAtan2(float cos, float sin) {
q = (sin * sin) + (cos * cos);
m = sqrt(q);
m = std::sqrt(q);
if (m == 0)
return 0;
if (fabs(sin) < fabs(cos)) {
if (std::fabs(sin) < std::fabs(cos)) {
// sin is smaller, use arcsin
t = FixAsin(sin / m);
if (cos < 0)