forked from Mirrors/openclonk
Fix variable_out_of_scope warnings in Objects
parent
4c43ebf58c
commit
1bb728b047
|
@ -93,14 +93,12 @@ private func GetRestingPlace(proplist coordinates)
|
||||||
// Try to rest in nearby grass
|
// Try to rest in nearby grass
|
||||||
for (var grass in FindObjects(Find_Distance(150), Find_ID(Grass), Sort_Distance()))
|
for (var grass in FindObjects(Find_Distance(150), Find_ID(Grass), Sort_Distance()))
|
||||||
{
|
{
|
||||||
if (!Random(2)) continue;
|
if (!Random(2))
|
||||||
break;
|
{
|
||||||
}
|
coordinates.x = grass->GetX() + Random(4) - 2;
|
||||||
if (grass)
|
coordinates.y = grass->GetY() + 2;
|
||||||
{
|
return true;
|
||||||
coordinates.x = grass->GetX() + Random(4) - 2;
|
}
|
||||||
coordinates.y = grass->GetY() + 2;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -327,16 +327,17 @@ func TaskWalkTo(spot)
|
||||||
{
|
{
|
||||||
var iX = GetX();
|
var iX = GetX();
|
||||||
var iY = GetY();
|
var iY = GetY();
|
||||||
|
var sX, sY;
|
||||||
|
|
||||||
if (GetType(spot) == C4V_C4Object)
|
if (GetType(spot) == C4V_C4Object)
|
||||||
{
|
{
|
||||||
var sX = spot->GetX();
|
sX = spot->GetX();
|
||||||
var sY = spot->GetY();
|
sY = spot->GetY();
|
||||||
}
|
}
|
||||||
else if (GetType(spot) == C4V_PropList)
|
else if (GetType(spot) == C4V_PropList)
|
||||||
{
|
{
|
||||||
var sX = spot.x;
|
sX = spot.x;
|
||||||
var sY = spot.y;
|
sY = spot.y;
|
||||||
}
|
}
|
||||||
else return;
|
else return;
|
||||||
|
|
||||||
|
@ -361,16 +362,17 @@ func TaskSwimTo(spot)
|
||||||
{
|
{
|
||||||
var iX = GetX();
|
var iX = GetX();
|
||||||
var iY = GetY();
|
var iY = GetY();
|
||||||
|
var sX, sY;
|
||||||
|
|
||||||
if (GetType(spot) == C4V_C4Object)
|
if (GetType(spot) == C4V_C4Object)
|
||||||
{
|
{
|
||||||
var sX = spot->GetX();
|
sX = spot->GetX();
|
||||||
var sY = spot->GetY();
|
sY = spot->GetY();
|
||||||
}
|
}
|
||||||
else if (GetType(spot) == C4V_PropList)
|
else if (GetType(spot) == C4V_PropList)
|
||||||
{
|
{
|
||||||
var sX = spot.x;
|
sX = spot.x;
|
||||||
var sY = spot.y;
|
sY = spot.y;
|
||||||
}
|
}
|
||||||
else return;
|
else return;
|
||||||
|
|
||||||
|
@ -934,4 +936,4 @@ local ContactCalls = true;
|
||||||
public func Definition(proplist def)
|
public func Definition(proplist def)
|
||||||
{
|
{
|
||||||
def.PictureTransformation = Trans_Mul(Trans_Translate(2000, 3000, 0), Trans_Scale(1400), Trans_Rotate(20, 1, 0, 0), Trans_Rotate(60, 0, 1, 0));
|
def.PictureTransformation = Trans_Mul(Trans_Translate(2000, 3000, 0), Trans_Scale(1400), Trans_Rotate(20, 1, 0, 0), Trans_Rotate(60, 0, 1, 0));
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,17 +104,17 @@ public func Place(int count)
|
||||||
{
|
{
|
||||||
if (this != Cloud)
|
if (this != Cloud)
|
||||||
return;
|
return;
|
||||||
var max_tries = count * 500;
|
var created = 0;
|
||||||
for (var i = 0; i < count && max_tries > 0; max_tries--)
|
for (var max_tries = count * 500; created < count && max_tries > 0; max_tries--)
|
||||||
{
|
{
|
||||||
var pos;
|
var pos = FindPosInMat("Sky", 0, 0, LandscapeWidth(), LandscapeHeight());
|
||||||
if ((pos = FindPosInMat("Sky", 0, 0, LandscapeWidth(), LandscapeHeight())) && MaterialDepthCheck(pos[0], pos[1], "Sky", 200))
|
if (pos && MaterialDepthCheck(pos[0], pos[1], "Sky", 200))
|
||||||
{
|
{
|
||||||
CreateObjectAbove(Cloud, pos[0], pos[1], NO_OWNER);
|
CreateObjectAbove(Cloud, pos[0], pos[1], NO_OWNER);
|
||||||
i++;
|
created++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return i;
|
return created;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Changes the precipitation type of this cloud.
|
// Changes the precipitation type of this cloud.
|
||||||
|
|
|
@ -159,6 +159,7 @@ private func LaunchEnemyAt(proplist prop_enemy, int wave_nr, int enemy_plr, prop
|
||||||
for (var inv in ForceToInventoryArray(prop_enemy.Inventory))
|
for (var inv in ForceToInventoryArray(prop_enemy.Inventory))
|
||||||
{
|
{
|
||||||
// Special way to pick up carry heavy objects instantly.
|
// Special way to pick up carry heavy objects instantly.
|
||||||
|
var inv_obj;
|
||||||
if (inv->~IsCarryHeavy() && (enemy->GetOCF() & OCF_CrewMember))
|
if (inv->~IsCarryHeavy() && (enemy->GetOCF() & OCF_CrewMember))
|
||||||
inv_obj = enemy->CreateCarryHeavyContents(inv);
|
inv_obj = enemy->CreateCarryHeavyContents(inv);
|
||||||
else
|
else
|
||||||
|
|
|
@ -517,10 +517,11 @@ static const SBRD_BestTime = 1;
|
||||||
|
|
||||||
private func UpdateScoreboardTitle()
|
private func UpdateScoreboardTitle()
|
||||||
{
|
{
|
||||||
|
var caption;
|
||||||
if (cp_count > 0)
|
if (cp_count > 0)
|
||||||
var caption = Format("$MsgCaptionX$", cp_count);
|
caption = Format("$MsgCaptionX$", cp_count);
|
||||||
else
|
else
|
||||||
var caption = "$MsgCaptionNone$";
|
caption = "$MsgCaptionNone$";
|
||||||
return Scoreboard->SetTitle(caption);
|
return Scoreboard->SetTitle(caption);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -581,7 +582,7 @@ protected func FxIntDirNextCPTimer(object target, effect fx)
|
||||||
var green = BoundBy(510 - dist, 0, 255);
|
var green = BoundBy(510 - dist, 0, 255);
|
||||||
var blue = 0;
|
var blue = 0;
|
||||||
// Arrow is colored a little different for the finish.
|
// Arrow is colored a little different for the finish.
|
||||||
if (cp->GetCPMode() & PARKOUR_CP_Finish)
|
if (nextcp->GetCPMode() & PARKOUR_CP_Finish)
|
||||||
blue = 128;
|
blue = 128;
|
||||||
var color = RGBa(red, green, blue, 128);
|
var color = RGBa(red, green, blue, 128);
|
||||||
// Draw arrow.
|
// Draw arrow.
|
||||||
|
|
|
@ -98,15 +98,17 @@ public func SetData(
|
||||||
var index = -1;
|
var index = -1;
|
||||||
for(var i = 0; i < GetLength(Scoreboard_data); ++i)
|
for(var i = 0; i < GetLength(Scoreboard_data); ++i)
|
||||||
{
|
{
|
||||||
if(Scoreboard_data[i].ID != ID) continue;
|
if(Scoreboard_data[i].ID == ID)
|
||||||
index = i;
|
{
|
||||||
break;
|
index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(index == -1) return;
|
if(index == -1) return;
|
||||||
|
|
||||||
Scoreboard_data[i][key] = to;
|
Scoreboard_data[index][key] = to;
|
||||||
if(sort_parameter)
|
if(sort_parameter)
|
||||||
Scoreboard_data[i][Format("%s_", key)] = sort_parameter;
|
Scoreboard_data[index][Format("%s_", key)] = sort_parameter;
|
||||||
Scoreboard->Update(ID);
|
Scoreboard->Update(ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,4 +324,4 @@ public func SetTitle(string title)
|
||||||
{
|
{
|
||||||
SetScoreboardData(SBRD_Caption, SBRD_Caption, title);
|
SetScoreboardData(SBRD_Caption, SBRD_Caption, title);
|
||||||
Scoreboard_title_set = true;
|
Scoreboard_title_set = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,15 +56,16 @@ protected func FxRestoreTimer(object target, effect, int time)
|
||||||
var init_x = effect.init_x;
|
var init_x = effect.init_x;
|
||||||
var init_y = effect.init_y;
|
var init_y = effect.init_y;
|
||||||
var to_container = effect.to_container;
|
var to_container = effect.to_container;
|
||||||
|
var to_x, to_y;
|
||||||
if (to_container)
|
if (to_container)
|
||||||
{
|
{
|
||||||
var to_x = to_container->GetX();
|
to_x = to_container->GetX();
|
||||||
var to_y = to_container->GetY();
|
to_y = to_container->GetY();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var to_x = effect.to_x;
|
to_x = effect.to_x;
|
||||||
var to_y = effect.to_y;
|
to_y = effect.to_y;
|
||||||
}
|
}
|
||||||
// Are the coordinates specified now, if not remove effect.
|
// Are the coordinates specified now, if not remove effect.
|
||||||
if (to_x == nil || to_y == nil)
|
if (to_x == nil || to_y == nil)
|
||||||
|
|
|
@ -117,6 +117,9 @@ func Reposition(int x, int y)
|
||||||
y = BoundBy(y, -dimension_y - clonk_height/2, dimension_y + clonk_height/2);
|
y = BoundBy(y, -dimension_y - clonk_height/2, dimension_y + clonk_height/2);
|
||||||
// Try to combine the structure with other structures.
|
// Try to combine the structure with other structures.
|
||||||
var found = false;
|
var found = false;
|
||||||
|
// Hopefully, in the end this contains a single sticking direction.
|
||||||
|
var single_stick_to = 0;
|
||||||
|
|
||||||
if (structure->~ConstructionCombineWith())
|
if (structure->~ConstructionCombineWith())
|
||||||
{
|
{
|
||||||
// There is no use in doing all the other checks if no sticking direction is defined at all
|
// There is no use in doing all the other checks if no sticking direction is defined at all
|
||||||
|
@ -153,9 +156,6 @@ func Reposition(int x, int y)
|
||||||
//
|
//
|
||||||
// Whichever part is howered on is checked first for stick direction
|
// Whichever part is howered on is checked first for stick direction
|
||||||
|
|
||||||
// Hopefully, in the end this contains a single sticking direction.
|
|
||||||
var single_stick_to = 0;
|
|
||||||
|
|
||||||
// Left
|
// Left
|
||||||
if (other_offset_x < other_width / -6)
|
if (other_offset_x < other_width / -6)
|
||||||
{
|
{
|
||||||
|
@ -314,4 +314,4 @@ func Flip()
|
||||||
// UI not saved.
|
// UI not saved.
|
||||||
func SaveScenarioObject() { return false; }
|
func SaveScenarioObject() { return false; }
|
||||||
|
|
||||||
local Plane = 210;
|
local Plane = 210;
|
||||||
|
|
|
@ -93,10 +93,11 @@ private func Perish()
|
||||||
// If fullgrown is true, the branch will be fully grown but not bear a fruit!
|
// If fullgrown is true, the branch will be fully grown but not bear a fruit!
|
||||||
public func GrowBranch(bool fullgrown, int branch)
|
public func GrowBranch(bool fullgrown, int branch)
|
||||||
{
|
{
|
||||||
|
var next_to_grow;
|
||||||
if (branch != nil)
|
if (branch != nil)
|
||||||
var next_to_grow = branch;
|
next_to_grow = branch;
|
||||||
else
|
else
|
||||||
var next_to_grow = GetNextGrowableBranch(fullgrown);
|
next_to_grow = GetNextGrowableBranch(fullgrown);
|
||||||
if (next_to_grow == -1) return false;
|
if (next_to_grow == -1) return false;
|
||||||
|
|
||||||
if (branches[next_to_grow].grow_animation != branch_proto.grow_animation) // Already growing, fullgrown must be true
|
if (branches[next_to_grow].grow_animation != branch_proto.grow_animation) // Already growing, fullgrown must be true
|
||||||
|
@ -352,4 +353,4 @@ local Description = "$Description$";
|
||||||
local Collectible = 0;
|
local Collectible = 0;
|
||||||
local growth = 3;
|
local growth = 3;
|
||||||
local degrowth = -6;
|
local degrowth = -6;
|
||||||
local fastgrowth = 9;
|
local fastgrowth = 9;
|
||||||
|
|
|
@ -197,8 +197,8 @@ private func Seed()
|
||||||
if (this.Confinement)
|
if (this.Confinement)
|
||||||
plant->KeepArea(this.Confinement);
|
plant->KeepArea(this.Confinement);
|
||||||
}
|
}
|
||||||
|
return plant;
|
||||||
}
|
}
|
||||||
return plant;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
local Name = "$Name$";
|
local Name = "$Name$";
|
||||||
|
@ -206,4 +206,4 @@ local Touchable = 0;
|
||||||
local BlastIncinerate = 2;
|
local BlastIncinerate = 2;
|
||||||
local ContactIncinerate = 6;
|
local ContactIncinerate = 6;
|
||||||
local NoBurnDecay = true;
|
local NoBurnDecay = true;
|
||||||
local Components = {Wood = 4};
|
local Components = {Wood = 4};
|
||||||
|
|
Loading…
Reference in New Issue