Skip to content
Merged
2 changes: 2 additions & 0 deletions Core/GameEngine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ set(GAMEENGINE_SRC
# Include/Common/DamageFX.h
# Include/Common/DataChunk.h
Include/Common/Debug.h
Include/Common/Diagnostic/SimulationMathCrc.h
# Include/Common/Dict.h
# Include/Common/Directory.h
# Include/Common/DisabledTypes.h
Expand Down Expand Up @@ -573,6 +574,7 @@ set(GAMEENGINE_SRC
Source/Common/crc.cpp
Source/Common/CRCDebug.cpp
# Source/Common/DamageFX.cpp
Source/Common/Diagnostic/SimulationMathCrc.cpp
# Source/Common/Dict.cpp
# Source/Common/DiscreteCircle.cpp
Source/Common/FramePacer.cpp
Expand Down
25 changes: 25 additions & 0 deletions Core/GameEngine/Include/Common/Diagnostic/SimulationMathCrc.h
Comment thread
xezon marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
** Command & Conquer Generals Zero Hour(tm)
** Copyright 2026 TheSuperHackers
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

class SimulationMathCrc
{
public:
static UnsignedInt calculate();
};
73 changes: 73 additions & 0 deletions Core/GameEngine/Source/Common/Diagnostic/SimulationMathCrc.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
** Command & Conquer Generals Zero Hour(tm)
** Copyright 2026 TheSuperHackers
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "PreRTS.h"

#include "Common/Diagnostic/SimulationMathCrc.h"
#include "Common/XferCRC.h"
#include "WWMath/matrix3d.h"
#include "WWMath/wwmath.h"
#include "GameLogic/FPUControl.h"

#include <math.h>

static void appendSimulationMathCrc(XferCRC &xfer)
{
Matrix3D matrix;
Matrix3D factorsMatrix;

matrix.Set(
4.1f, 1.2f, 0.3f, 0.4f,
0.5f, 3.6f, 0.7f, 0.8f,
0.9f, 1.0f, 2.1f, 1.2f);

factorsMatrix.Set(
WWMath::Sin(0.7f) * log10f(2.3f),
WWMath::Cos(1.1f) * powf(1.1f, 2.0f),
tanf(0.3f),
asinf(0.967302263f),
acosf(0.967302263f),
atanf(0.967302263f) * powf(1.1f, 2.0f),
atan2f(0.4f, 1.3f),
sinhf(0.2f),
coshf(0.4f) * tanhf(0.5f),
sqrtf(55788.84375f),
expf(0.1f) * log10f(2.3f),
logf(1.4f));

Matrix3D::Multiply(matrix, factorsMatrix, &matrix);
matrix.Get_Inverse(matrix);
Comment thread
stephanmeesters marked this conversation as resolved.

xfer.xferMatrix3D(&matrix);
}

UnsignedInt SimulationMathCrc::calculate()
{
XferCRC xfer;
xfer.open("SimulationMathCrc");

setFPMode();

appendSimulationMathCrc(xfer);

_fpreset();

xfer.close();

return xfer.getCRC();
}
Loading