Fix build on SunOS (lots of ambiguous math)

This commit is contained in:
wiedi 2014-02-09 17:09:03 +00:00
parent 7ca0ae55ba
commit 2cad61d2e8
11 changed files with 314 additions and 6 deletions

View file

@ -1,4 +1,4 @@
$NetBSD: distinfo,v 1.8 2012/10/11 11:36:20 marino Exp $
$NetBSD: distinfo,v 1.9 2014/02/09 17:09:03 wiedi Exp $
SHA1 (ivan-0.50.tar.gz) = e4c5ae2b9bdfd59a0ed3c87a504043df12b0f1a4
RMD160 (ivan-0.50.tar.gz) = 7e84340cd8fdfbdaaf7fde730fc0a76b137e2e91
@ -6,6 +6,15 @@ Size (ivan-0.50.tar.gz) = 803651 bytes
SHA1 (patch-FeLib_Source_bitmap.cc) = 88a4c73046069aed5e3a3c67ed22a1f22230254a
SHA1 (patch-FeLib_Source_festring.cpp) = f45e5a3228f168888ecb5f645f463a2b8a3d903a
SHA1 (patch-FeLib_Source_fetime.cpp) = f941686fedd9603f1d89c0edb205caceef4b27ba
SHA1 (patch-Main_Source_bodypart.cpp) = 56880c6515a615dbd51e423416c35f8fa19aa2c2
SHA1 (patch-Main_Source_char.cpp) = e6c5417416330a79fd38d0227d329db63f36c002
SHA1 (patch-Main_Source_gear.cpp) = 6fb8ee978033701b86bbaf14f17fde78194c530d
SHA1 (patch-Main_Source_human.cpp) = db8160fd618c2481046df42d4a389259bc0cde2a
SHA1 (patch-Main_Source_item.cpp) = e546ccba7a445f818aab9cd22b74aa0d99efa745
SHA1 (patch-Main_Source_materias.cpp) = b4ad153e784acab903aacb16457162253a13c3fd
SHA1 (patch-Main_Source_rain.cpp) = c42e2bc7022b8584adadd27a906307b9f517a2ba
SHA1 (patch-Main_Source_stack.cpp) = 6af80f842478be248b80d46c5cd72c02de6dfc7b
SHA1 (patch-Main_Source_wsquare.cpp) = 8d0c40235bdfef17b1d1030a543aee313740f22b
SHA1 (patch-aa) = a52f3945a79e12cc72d30d9609c4bf390809a5bd
SHA1 (patch-ab) = 63f215564ee0922d1daa5240b5a3b3b4afc5db24
SHA1 (patch-ac) = 42150fb33cbc0136bd702ab5cb26dcbc9d7c717c
@ -16,7 +25,7 @@ SHA1 (patch-ag) = 58c92ccf5cad81c8030bb0e7f885e95b1ca4d555
SHA1 (patch-ah) = 56fa7992634cd699eeccbb6702f2ec499d149a21
SHA1 (patch-ai) = 0bd4ee24abae746489452a5a3fba11f5cb1965e4
SHA1 (patch-aj) = 61d62867bb5fee01f8c243bc255de30a85781a76
SHA1 (patch-ak) = 3ca89be9258c4ecc4a2ba16df9faa574983affa1
SHA1 (patch-ak) = f7c043fad5c5cc1c72fd4dbc6db0a4ae3bce8d51
SHA1 (patch-al) = 32e9e591e5967ec24525c5a6d5ddbb6294287b3b
SHA1 (patch-am) = a631ea77b56262915181f8b0a6ed700596c820e1
SHA1 (patch-an) = 48e334a68d12bfc23ea642956e0119ee0c6189c0

View file

@ -0,0 +1,32 @@
$NetBSD: patch-Main_Source_bodypart.cpp,v 1.1 2014/02/09 17:09:03 wiedi Exp $
fix ambiguous math functions on SunOS
--- Main/Source/bodypart.cpp.orig 2004-12-10 15:51:44.000000000 +0000
+++ Main/Source/bodypart.cpp
@@ -585,7 +585,7 @@ int corpse::GetOfferValue(int Receiver)
double corpse::GetWeaponStrength() const
{
- return GetFormModifier() * GetDeceased()->GetTorso()->GetMainMaterial()->GetStrengthValue() * sqrt(GetDeceased()->GetTorso()->GetMainMaterial()->GetWeight());
+ return GetFormModifier() * GetDeceased()->GetTorso()->GetMainMaterial()->GetStrengthValue() * sqrt((double)GetDeceased()->GetTorso()->GetMainMaterial()->GetWeight());
}
truth corpse::CanBeEatenByAI(const character* Eater) const
@@ -1742,7 +1742,7 @@ void bodypart::Be()
void bodypart::SpillBlood(int HowMuch, v2 Pos)
{
if(HowMuch && (!Master || Master->SpillsBlood()) && (IsAlive() || MainMaterial->IsLiquid()) && !game::IsInWilderness())
- GetNearLSquare(Pos)->SpillFluid(0, CreateBlood(long(HowMuch * sqrt(BodyPartVolume) / 2)), false, false);
+ GetNearLSquare(Pos)->SpillFluid(0, CreateBlood(long(HowMuch * sqrt((double)BodyPartVolume) / 2)), false, false);
}
void bodypart::SpillBlood(int HowMuch)
@@ -1750,7 +1750,7 @@ void bodypart::SpillBlood(int HowMuch)
if(HowMuch && (!Master || Master->SpillsBlood()) && (IsAlive() || MainMaterial->IsLiquid()) && !game::IsInWilderness())
for(int c = 0; c < GetSquaresUnder(); ++c)
if(GetLSquareUnder(c))
- GetLSquareUnder(c)->SpillFluid(0, CreateBlood(long(HowMuch * sqrt(BodyPartVolume) / 2)), false, false);
+ GetLSquareUnder(c)->SpillFluid(0, CreateBlood(long(HowMuch * sqrt((double)BodyPartVolume) / 2)), false, false);
}
void bodypart::SignalEnchantmentChange()

View file

@ -0,0 +1,50 @@
$NetBSD: patch-Main_Source_char.cpp,v 1.1 2014/02/09 17:09:03 wiedi Exp $
fix ambiguous math functions on SunOS
--- Main/Source/char.cpp.orig 2004-12-10 21:10:02.000000000 +0000
+++ Main/Source/char.cpp
@@ -2169,7 +2169,7 @@ void character::Vomit(v2 Pos, int Amount
}
if(!game::IsInWilderness())
- GetNearLSquare(Pos)->ReceiveVomit(this, liquid::Spawn(GetVomitMaterial(), long(sqrt(GetBodyVolume()) * Amount / 1000)));
+ GetNearLSquare(Pos)->ReceiveVomit(this, liquid::Spawn(GetVomitMaterial(), long(sqrt((double)GetBodyVolume()) * Amount / 1000)));
}
truth character::Polymorph(character* NewForm, int Counter)
@@ -4261,7 +4261,7 @@ void character::DrawPanel(truth Animatio
void character::CalculateDodgeValue()
{
- DodgeValue = 0.05 * GetMoveEase() * GetAttribute(AGILITY) / sqrt(GetSize());
+ DodgeValue = 0.05 * GetMoveEase() * GetAttribute(AGILITY) / sqrt((double)GetSize());
if(IsFlying())
DodgeValue *= 2;
@@ -7396,7 +7396,7 @@ void character::SpillFluid(character* Sp
for(c = 0; c < BodyParts; ++c)
if(GetBodyPart(c))
{
- Modifier[c] = long(sqrt(GetBodyPart(c)->GetVolume()));
+ Modifier[c] = long(sqrt((double)GetBodyPart(c)->GetVolume()));
if(Modifier[c])
Modifier[c] *= 1 + (RAND() & 3);
@@ -7706,7 +7706,7 @@ void characterdatabase::PostProcess()
void character::EditDealExperience(long Price)
{
- EditExperience(CHARISMA, sqrt(Price) / 5, 1 << 9);
+ EditExperience(CHARISMA, sqrt((double)Price) / 5, 1 << 9);
}
void character::PrintBeginLeprosyMessage() const
@@ -7951,7 +7951,7 @@ void character::RegenerateStamina()
if(Sweats() && TorsoIsAlive() && !RAND_N(30) && !game::IsInWilderness())
{
- long Volume = long(.05 * sqrt(GetBodyVolume()));
+ long Volume = long(.05 * sqrt((double)GetBodyVolume()));
if(GetTirednessState() == FAINTING)
Volume <<= 1;

View file

@ -0,0 +1,32 @@
$NetBSD: patch-Main_Source_gear.cpp,v 1.1 2014/02/09 17:09:03 wiedi Exp $
fix ambiguous math functions on SunOS
--- Main/Source/gear.cpp.orig 2004-12-10 15:51:45.000000000 +0000
+++ Main/Source/gear.cpp
@@ -159,7 +159,7 @@ long meleeweapon::GetPrice() const
WeaponStrengthModifier *= WeaponStrengthModifier;
WeaponStrengthModifier *= GetMainMaterial()->GetWeight();
WeaponStrengthModifier *= Max((10 + Enchantment) * 0.1, 0.1);
- return long(WeaponStrengthModifier / (20000000.0 * sqrt(GetWeight())))
+ return long(WeaponStrengthModifier / (20000000.0 * sqrt((double)GetWeight())))
+ GetEnchantedPrice(Enchantment);
}
@@ -492,7 +492,7 @@ truth thunderhammer::ReceiveDamage(chara
long armor::GetPrice() const
{
double StrengthValue = GetStrengthValue();
- return long(StrengthValue * StrengthValue * StrengthValue * 20 / sqrt(GetWeight()));
+ return long(StrengthValue * StrengthValue * StrengthValue * 20 / sqrt((double)GetWeight()));
}
int belt::GetFormModifier() const
@@ -543,7 +543,7 @@ truth armor::CanBePiledWith(const item*
long shield::GetPrice() const /* temporary... */
{
double StrengthValue = GetStrengthValue();
- return long(sqrt(GetBaseBlockValue()) * StrengthValue * StrengthValue) + item::GetPrice();
+ return long(sqrt((double)GetBaseBlockValue()) * StrengthValue * StrengthValue) + item::GetPrice();
}
void armor::Save(outputfile& SaveFile) const

View file

@ -0,0 +1,14 @@
$NetBSD: patch-Main_Source_human.cpp,v 1.1 2014/02/09 17:09:03 wiedi Exp $
fix ambiguous sqrt on SunOS
--- Main/Source/human.cpp.orig 2004-12-10 21:10:04.000000000 +0000
+++ Main/Source/human.cpp
@@ -2701,7 +2701,7 @@ void smith::BeTalkedTo()
void humanoid::CalculateDodgeValue()
{
- DodgeValue = 0.05 * GetMoveEase() * GetAttribute(AGILITY) / sqrt(GetSize());
+ DodgeValue = 0.05 * GetMoveEase() * GetAttribute(AGILITY) / sqrt((double)GetSize());
if(IsFlying())
DodgeValue *= 2;

View file

@ -0,0 +1,68 @@
$NetBSD: patch-Main_Source_item.cpp,v 1.1 2014/02/09 17:09:03 wiedi Exp $
fix ambiguous math functions on SunOS
--- Main/Source/item.cpp.orig 2004-12-10 15:51:46.000000000 +0000
+++ Main/Source/item.cpp
@@ -88,7 +88,7 @@ item::~item()
void item::Fly(character* Thrower, int Direction, int Force)
{
- int Range = Force * 25 / Max(long(sqrt(GetWeight())), 1L);
+ int Range = Force * 25 / Max(long(sqrt((double)GetWeight())), 1L);
lsquare* LSquareUnder = GetLSquareUnder();
RemoveFromSlot();
@@ -137,7 +137,7 @@ void item::Fly(character* Thrower, int D
if(!JustHit->IsFlyable())
{
Breaks = true;
- JustHit->GetOLTerrain()->HasBeenHitByItem(Thrower, this, int(BaseDamage * sqrt(RangeLeft)));
+ JustHit->GetOLTerrain()->HasBeenHitByItem(Thrower, this, int(BaseDamage * sqrt((double)RangeLeft)));
break;
}
else
@@ -153,7 +153,7 @@ void item::Fly(character* Thrower, int D
if(JustHit->GetCharacter())
{
- int Damage = int(BaseDamage * sqrt(RangeLeft));
+ int Damage = int(BaseDamage * sqrt((double)RangeLeft));
double ToHitValue = BaseToHitValue * RangeLeft;
int Returned = HitCharacter(Thrower, JustHit->GetCharacter(), Damage, ToHitValue, Direction);
@@ -170,7 +170,7 @@ void item::Fly(character* Thrower, int D
}
if(Breaks)
- ReceiveDamage(Thrower, int(sqrt(GetWeight() * RangeLeft) / 10), THROW|PHYSICAL_DAMAGE, Direction);
+ ReceiveDamage(Thrower, int(sqrt((double) (GetWeight() * RangeLeft)) / 10), THROW|PHYSICAL_DAMAGE, Direction);
if(Exists() && GetLSquareUnder()->GetRoom())
GetLSquareUnder()->GetRoom()->AddItemEffect(this);
@@ -200,7 +200,7 @@ int item::HitCharacter(character* Throwe
double item::GetWeaponStrength() const
{
- return GetFormModifier() * GetMainMaterial()->GetStrengthValue() * sqrt(GetMainMaterial()->GetWeight());
+ return GetFormModifier() * GetMainMaterial()->GetStrengthValue() * sqrt((double)GetMainMaterial()->GetWeight());
}
int item::GetStrengthRequirement() const
@@ -786,7 +786,7 @@ int item::GetOfferValue(int Receiver) co
{
/* Temporary */
- int OfferValue = int(sqrt(GetTruePrice()));
+ int OfferValue = int(sqrt((double)GetTruePrice()));
if(Receiver == GetAttachedGod())
OfferValue <<= 1;
@@ -1489,7 +1489,7 @@ long item::GetFixPrice() const
Clone->RemoveRust();
long FixPrice = Clone->GetTruePrice();
Clone->SendToHell();
- return Max(long(3.5 * sqrt(FixPrice)), 10L);
+ return Max(long(3.5 * sqrt((double)FixPrice)), 10L);
}
void item::AddTrapName(festring& String, int Amount) const

View file

@ -0,0 +1,32 @@
$NetBSD: patch-Main_Source_materias.cpp,v 1.1 2014/02/09 17:09:03 wiedi Exp $
fix ambiguous math functions on SunOS
--- Main/Source/materias.cpp.orig 2004-10-26 19:37:03.000000000 +0000
+++ Main/Source/materias.cpp
@@ -117,7 +117,7 @@ material* organic::EatEffect(character*
if(GetSpoilLevel() > 0)
{
- Eater->BeginTemporaryState(CONFUSED, int(Amount * GetSpoilLevel() * sqrt(GetNutritionValue()) / 1000));
+ Eater->BeginTemporaryState(CONFUSED, int(Amount * GetSpoilLevel() * sqrt((double)GetNutritionValue()) / 1000));
if(GetBodyFlags() & CAN_HAVE_PARASITE
&& !(RAND() % (250 / GetSpoilLevel())))
@@ -125,7 +125,7 @@ material* organic::EatEffect(character*
}
if(GetSpoilLevel() > 4)
- Eater->BeginTemporaryState(POISONED, int(Amount * (GetSpoilLevel() - 4) * sqrt(GetNutritionValue()) / 1000));
+ Eater->BeginTemporaryState(POISONED, int(Amount * (GetSpoilLevel() - 4) * sqrt((double)GetNutritionValue()) / 1000));
if(Volume != Amount)
{
@@ -281,7 +281,7 @@ truth ironalloy::TryToRust(long Modifier
if(!Volume)
Volume = GetVolume();
- long Chance = long(30000000. * sqrt(Volume) / (Modifier * GetRustModifier()));
+ long Chance = long(30000000. * sqrt((double)Volume) / (Modifier * GetRustModifier()));
if(Chance <= 1 || !(RAND() % Chance))
return true;

View file

@ -0,0 +1,23 @@
$NetBSD: patch-Main_Source_rain.cpp,v 1.1 2014/02/09 17:09:03 wiedi Exp $
fix ambiguous math functions on SunOS
--- Main/Source/rain.cpp.orig 2004-10-26 19:37:04.000000000 +0000
+++ Main/Source/rain.cpp
@@ -12,7 +12,7 @@
/* Compiled through materset.cpp */
-rain::rain(liquid* Liquid, lsquare* LSquareUnder, v2 Speed, int Team, truth OwnLiquid) : entity(OwnLiquid ? HAS_BE : 0), Next(0), Drop(0), Liquid(Liquid), LSquareUnder(LSquareUnder), Speed(Speed), SpeedAbs(long(sqrt(Speed.GetLengthSquare()))), Drops(0), OwnLiquid(OwnLiquid), Team(Team)
+rain::rain(liquid* Liquid, lsquare* LSquareUnder, v2 Speed, int Team, truth OwnLiquid) : entity(OwnLiquid ? HAS_BE : 0), Next(0), Drop(0), Liquid(Liquid), LSquareUnder(LSquareUnder), Speed(Speed), SpeedAbs(long(sqrt((double)Speed.GetLengthSquare()))), Drops(0), OwnLiquid(OwnLiquid), Team(Team)
{
Emitation = Liquid->GetEmitation();
BeCounter = RAND_N(50);
@@ -164,7 +164,7 @@ void rain::Load(inputfile& SaveFile)
Emitation = Liquid->GetEmitation();
SaveFile >> Speed;
Team = ReadType<uchar>(SaveFile);
- SpeedAbs = long(sqrt(Speed.GetLengthSquare()));
+ SpeedAbs = long(sqrt((double)Speed.GetLengthSquare()));
}
outputfile& operator<<(outputfile& SaveFile, const rain* Rain)

View file

@ -0,0 +1,23 @@
$NetBSD: patch-Main_Source_stack.cpp,v 1.1 2014/02/09 17:09:03 wiedi Exp $
fix ambiguous math functions on SunOS
--- Main/Source/stack.cpp.orig 2004-12-10 15:51:48.000000000 +0000
+++ Main/Source/stack.cpp
@@ -1170,7 +1170,7 @@ void stack::SpillFluid(character* Spille
if(!Items)
return;
- double ChanceMultiplier = 1. / (300 + sqrt(Volume));
+ double ChanceMultiplier = 1. / (300 + sqrt((double)Volume));
itemvector ItemVector;
FillItemVector(ItemVector);
@@ -1178,7 +1178,7 @@ void stack::SpillFluid(character* Spille
if(ItemVector[c]->Exists() && ItemVector[c]->AllowFluids())
{
long ItemVolume = ItemVector[c]->GetVolume();
- double Root = sqrt(ItemVolume);
+ double Root = sqrt((double)ItemVolume);
if(Root > RAND() % 200 || Root > RAND() % 200)
{

View file

@ -0,0 +1,14 @@
$NetBSD: patch-Main_Source_wsquare.cpp,v 1.1 2014/02/09 17:09:03 wiedi Exp $
fix ambiguous fabs(int) on SunOS
--- Main/Source/wsquare.cpp.orig 2004-12-10 15:51:48.000000000 +0000
+++ Main/Source/wsquare.cpp
@@ -167,7 +167,7 @@ truth wsquare::SignalSeen()
void wsquare::CalculateLuminance()
{
- double T = log(1. + fabs(GetWorldMap()->GetAltitude(Pos)) / 500.);
+ double T = log(1. + fabs((double)GetWorldMap()->GetAltitude(Pos)) / 500.);
int Element = Min((128 - int(37.5 * T)), 255);
Luminance = MakeRGB24(Element, Element, Element);
}

View file

@ -1,8 +1,8 @@
$NetBSD: patch-ak,v 1.1 2008/07/27 21:44:47 dholland Exp $
$NetBSD: patch-ak,v 1.2 2014/02/09 17:09:03 wiedi Exp $
--- Main/Source/lsquare.cpp~ 2004-12-10 10:51:47.000000000 -0500
+++ Main/Source/lsquare.cpp 2008-07-27 16:34:33.000000000 -0400
@@ -1585,7 +1585,7 @@
--- Main/Source/lsquare.cpp.orig 2004-12-10 15:51:47.000000000 +0000
+++ Main/Source/lsquare.cpp
@@ -1585,7 +1585,7 @@ truth lsquare::Duplicate(const beamdata&
character* Character = GetCharacter();
if(Character)
@ -11,3 +11,14 @@ $NetBSD: patch-ak,v 1.1 2008/07/27 21:44:47 dholland Exp $
if(GetStack()->Duplicate(DuplicatedSomething ? 4 : 5, Beam.SpecialParameters))
DuplicatedSomething = true;
@@ -2186,8 +2186,8 @@ void lsquare::SpillFluid(character* Spil
Spiller->Hostility(GetCharacter());
long CharVolume = GetCharacter()->GetVolume();
- double ChanceMultiplier = 1. / (300 + sqrt(GetStack()->GetVolume() + CharVolume));
- double Root = sqrt(CharVolume);
+ double ChanceMultiplier = 1. / (300 + sqrt((double)(GetStack()->GetVolume() + CharVolume)));
+ double Root = sqrt((double)CharVolume);
if(ForceHit || Root > RAND() % 400 || Root > RAND() % 400)
{