mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-31 07:53:36 +00:00
ALL: Switch to Common::hypotenuse()
This commit is contained in:
parent
b1c5e63de0
commit
b53a7db0da
@ -178,10 +178,6 @@ int MADSEngine::getRandomNumber(int minNumber, int maxNumber) {
|
||||
return minNumber + _randomSource.getRandomNumber(range);
|
||||
}
|
||||
|
||||
int MADSEngine::hypotenuse(int xv, int yv) {
|
||||
return (int)sqrt((double)(xv * xv + yv * yv));
|
||||
}
|
||||
|
||||
bool MADSEngine::canLoadGameStateCurrently() {
|
||||
return !_game->_winStatus && !_game->globals()[5]
|
||||
&& _dialogs->_pendingDialog == DIALOG_NONE
|
||||
|
@ -124,7 +124,6 @@ public:
|
||||
|
||||
int getRandomNumber(int maxNumber);
|
||||
int getRandomNumber(int minNumber, int maxNumber);
|
||||
int hypotenuse(int xv, int yv);
|
||||
|
||||
/**
|
||||
* Returns true if it is currently okay to restore a game
|
||||
|
@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
#include "common/scummsys.h"
|
||||
#include "common/math.h"
|
||||
#include "mads/mads.h"
|
||||
#include "mads/scene.h"
|
||||
#include "mads/nebular/nebular_scenes.h"
|
||||
@ -1375,14 +1376,14 @@ void Scene103::step() {
|
||||
|
||||
case 72: {
|
||||
Common::Point pt = _vm->_game->_player._playerPos;
|
||||
int dist = _vm->hypotenuse(pt.x - 58, pt.y - 93);
|
||||
int dist = Common::hypotenuse(pt.x - 58, pt.y - 93);
|
||||
_vm->_sound->command(27, (dist * -128 / 378) + 127);
|
||||
}
|
||||
break;
|
||||
|
||||
case 73: {
|
||||
Common::Point pt = _vm->_game->_player._playerPos;
|
||||
int dist = _vm->hypotenuse(pt.x - 266, pt.y - 81);
|
||||
int dist = Common::hypotenuse(pt.x - 266, pt.y - 81);
|
||||
_vm->_sound->command(27, (dist * -127 / 378) + 127);
|
||||
}
|
||||
break;
|
||||
@ -1393,15 +1394,15 @@ void Scene103::step() {
|
||||
|
||||
if (_scene->_frameStartTime >= _updateClock) {
|
||||
Common::Point pt = _vm->_game->_player._playerPos;
|
||||
int dist = _vm->hypotenuse(pt.x - 79, pt.y - 137);
|
||||
int dist = Common::hypotenuse(pt.x - 79, pt.y - 137);
|
||||
_vm->_sound->command(29, (dist * -127 / 378) + 127);
|
||||
|
||||
pt = _vm->_game->_player._playerPos;
|
||||
dist = _vm->hypotenuse(pt.x - 69, pt.y - 80);
|
||||
dist = Common::hypotenuse(pt.x - 69, pt.y - 80);
|
||||
_vm->_sound->command(30, (dist * -127 / 378) + 127);
|
||||
|
||||
pt = _vm->_game->_player._playerPos;
|
||||
dist = _vm->hypotenuse(pt.x - 266, pt.y - 138);
|
||||
dist = Common::hypotenuse(pt.x - 266, pt.y - 138);
|
||||
_vm->_sound->command(32, (dist * -127 / 378) + 127);
|
||||
|
||||
_updateClock = _scene->_frameStartTime + _vm->_game->_player._ticksAmount;
|
||||
|
@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
#include "common/scummsys.h"
|
||||
#include "common/math.h"
|
||||
#include "mads/mads.h"
|
||||
#include "mads/scene.h"
|
||||
#include "mads/nebular/nebular_scenes.h"
|
||||
@ -149,7 +150,7 @@ void Scene401::step() {
|
||||
}
|
||||
|
||||
if (_scene->_frameStartTime >= _timer) {
|
||||
int dist = 64 - ((_vm->hypotenuse(_game._player._playerPos.x - 219, _game._player._playerPos.y - 115) * 64) / 120);
|
||||
int dist = 64 - ((Common::hypotenuse(_game._player._playerPos.x - 219, _game._player._playerPos.y - 115) * 64) / 120);
|
||||
|
||||
if (dist > 64)
|
||||
dist = 64;
|
||||
|
@ -20,6 +20,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/math.h"
|
||||
|
||||
#include "pink/archive.h"
|
||||
#include "pink/cel_decoder.h"
|
||||
#include "pink/pink.h"
|
||||
@ -110,7 +112,7 @@ WalkAction *WalkMgr::getWalkAction() {
|
||||
double WalkMgr::getLengthBetweenLocations(WalkLocation *first, WalkLocation *second) {
|
||||
Coordinates firstCoord = getLocationCoordinates(first->getName());
|
||||
Coordinates secondCoord = getLocationCoordinates(second->getName());
|
||||
return hypot(secondCoord.point.x - firstCoord.point.x, secondCoord.point.y - firstCoord.point.y);
|
||||
return Common::hypotenuse(secondCoord.point.x - firstCoord.point.x, secondCoord.point.y - firstCoord.point.y);
|
||||
}
|
||||
|
||||
Coordinates WalkMgr::getLocationCoordinates(const Common::String &locationName) {
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
/* Various utility functions RLL finds useful. */
|
||||
|
||||
#include "common/math.h"
|
||||
#include "common/textconsole.h"
|
||||
|
||||
#include "sword25/gfx/image/art.h"
|
||||
@ -365,8 +366,8 @@ static void art_vpath_render_bez(ArtVpath **p_vpath, int *pn, int *pn_max,
|
||||
* the other two control points are the same as the start point,
|
||||
* too.
|
||||
*/
|
||||
if (!(hypot(x1 - x0, y1 - y0) < 0.001
|
||||
&& hypot(x2 - x0, y2 - y0) < 0.001))
|
||||
if (!(Common::hypotenuse(x1 - x0, y1 - y0) < 0.001
|
||||
&& Common::hypotenuse(x2 - x0, y2 - y0) < 0.001))
|
||||
subDivide = true;
|
||||
} else {
|
||||
/* we can avoid subdivision if:
|
||||
|
@ -20,6 +20,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/math.h"
|
||||
#include "graphics/cursorman.h"
|
||||
|
||||
#include "tsage/scenes.h"
|
||||
@ -3885,10 +3886,6 @@ void Scene1575::synchronize(Serializer &s) {
|
||||
s.syncAsSint16LE(_field41A);
|
||||
}
|
||||
|
||||
double hypotenuse(double v1, double v2) {
|
||||
return sqrt(v1 * v1 + v2 * v2);
|
||||
}
|
||||
|
||||
void Scene1575::postInit(SceneObjectList *OwnerList) {
|
||||
loadScene(1575);
|
||||
R2_GLOBALS._uiElements._active = false;
|
||||
@ -3914,8 +3911,8 @@ void Scene1575::postInit(SceneObjectList *OwnerList) {
|
||||
_arrActor[i].postInit();
|
||||
_arrActor[i].setup(1575, 2, k5A7F6[3 * i + 2]);
|
||||
|
||||
double v1 = hypotenuse(2.0, 3 - k5A7F6[3 * i]);
|
||||
v1 += hypotenuse(2.0, 3 - k5A7F6[3 * i + 1]);
|
||||
double v1 = Common::hypotenuse<double>(2.0, 3 - k5A7F6[3 * i]);
|
||||
v1 += Common::hypotenuse<double>(2.0, 3 - k5A7F6[3 * i + 1]);
|
||||
int yp = (int)(sqrt(v1) * 75.0 / 17.0 - 161.0);
|
||||
|
||||
int angle = R2_GLOBALS._gfxManagerInstance.getAngle(
|
||||
|
Loading…
x
Reference in New Issue
Block a user