forked from Mirrors/openclonk
FnBlastFree: Added max_density parameter.
Also updated material densities and added attribute MaxPickDensity to pickaxe, so it's now possible to define a pickaxe that cannot go through granite.scancodes-fix
parent
671a815223
commit
c115fbfaa0
|
@ -1,7 +1,7 @@
|
|||
[Material]
|
||||
Name=Brick
|
||||
Shape=Smoother
|
||||
Density=50
|
||||
Density=90
|
||||
Friction=15
|
||||
Placement=80
|
||||
TextureOverlay=brick1
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[Material]
|
||||
Name=BrickSoft
|
||||
Shape=Smoother
|
||||
Density=50
|
||||
Density=90
|
||||
Friction=15
|
||||
Placement=60
|
||||
TextureOverlay=brick1
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[Material]
|
||||
Name=Coal
|
||||
Shape=Rough
|
||||
Density=50
|
||||
Density=60
|
||||
Friction=75
|
||||
DigFree=1
|
||||
BlastFree=1
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[Material]
|
||||
Name=Earth
|
||||
Shape=Smooth
|
||||
Density=50
|
||||
Density=60
|
||||
Friction=80
|
||||
DigFree=1
|
||||
BlastFree=1
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[Material]
|
||||
Name=Gold
|
||||
Shape=Rough
|
||||
Density=50
|
||||
Density=70
|
||||
Friction=100
|
||||
BlastFree=1
|
||||
Blast2Object=Nugget
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[Material]
|
||||
Name=Granite
|
||||
Shape=Rough
|
||||
Density=50
|
||||
Density=80
|
||||
Friction=100
|
||||
MaxAirSpeed=100
|
||||
MaxSlide=250
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[Material]
|
||||
Name=Ice
|
||||
Shape=TopFlat
|
||||
Density=50
|
||||
Density=60
|
||||
Friction=15
|
||||
DigFree=1
|
||||
BlastFree=1
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[Material]
|
||||
Name=Ore
|
||||
Shape=Rough
|
||||
Density=50
|
||||
Density=70
|
||||
Friction=100
|
||||
BlastFree=1
|
||||
Blast2Object=Ore
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[Material]
|
||||
Name=Rock
|
||||
Shape=Rough
|
||||
Density=50
|
||||
Density=70
|
||||
Friction=100
|
||||
BlastFree=1
|
||||
Blast2Object=Rock
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[Material]
|
||||
Name=Sand
|
||||
Shape=Smooth
|
||||
Density=50
|
||||
Density=60
|
||||
Friction=80
|
||||
DigFree=1
|
||||
BlastFree=1
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[Material]
|
||||
Name=Sulphur
|
||||
Shape=Rough
|
||||
Density=50
|
||||
Density=60
|
||||
Friction=75
|
||||
DigFree=1
|
||||
BlastFree=1
|
||||
|
|
|
@ -124,7 +124,7 @@ protected func DoSwing(object clonk, int ix, int iy)
|
|||
}
|
||||
|
||||
//Do blastfree after landscape checks are made. Otherwise, mat always returns as "tunnel"
|
||||
BlastFree(GetX()+x2,GetY()+y2,5,GetController());
|
||||
BlastFree(GetX()+x2,GetY()+y2,5,GetController(),MaxPickDensity);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -176,3 +176,4 @@ local Name = "$Name$";
|
|||
local Description = "$Description$";
|
||||
local UsageHelp = "$UsageHelp$";
|
||||
local Rebuy = true;
|
||||
local MaxPickDensity = 80;
|
||||
|
|
|
@ -430,11 +430,12 @@ static long FnExtractMaterialAmount(C4PropList * _this, long x, long y, long mat
|
|||
return extracted;
|
||||
}
|
||||
|
||||
static C4Void FnBlastFree(C4PropList * _this, long iX, long iY, long iLevel, Nillable<long> iCausedBy)
|
||||
static C4Void FnBlastFree(C4PropList * _this, long iX, long iY, long iLevel, Nillable<long> iCausedBy, Nillable<long> iMaxDensity)
|
||||
{
|
||||
if (iCausedBy.IsNil() && Object(_this)) iCausedBy = Object(_this)->Controller;
|
||||
if (iMaxDensity.IsNil()) iMaxDensity = C4M_Vehicle;
|
||||
|
||||
::Landscape.BlastFree(iX, iY, iLevel, iCausedBy, Object(_this));
|
||||
::Landscape.BlastFree(iX, iY, iLevel, iCausedBy, Object(_this), iMaxDensity);
|
||||
return C4Void();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
|
||||
* OpenClonk, http://www.openclonk.org
|
||||
*
|
||||
* Copyright (c) 1998-2000 Matthes Bender
|
||||
|
@ -393,10 +393,10 @@ int32_t C4Landscape::DigFree(int32_t tx, int32_t ty, int32_t rad, C4Object *by_o
|
|||
return DigFreeShape(&vertices[0],vertices.size(),by_object, no_dig2objects);
|
||||
}
|
||||
|
||||
void C4Landscape::BlastFree(int32_t tx, int32_t ty, int32_t rad, int32_t caused_by, C4Object *by_object)
|
||||
void C4Landscape::BlastFree(int32_t tx, int32_t ty, int32_t rad, int32_t caused_by, C4Object *by_object, int32_t iMaxDensity)
|
||||
{
|
||||
std::vector<int32_t> vertices(GetRoundPolygon(tx,ty,rad,30));
|
||||
BlastFreeShape(&vertices[0],vertices.size(),by_object,caused_by);
|
||||
BlastFreeShape(&vertices[0],vertices.size(),by_object,caused_by,iMaxDensity);
|
||||
}
|
||||
|
||||
void C4Landscape::ShakeFree(int32_t tx, int32_t ty, int32_t rad)
|
||||
|
@ -458,22 +458,29 @@ int32_t C4Landscape::DigFreeShape(int *vtcs, int length, C4Object *by_object, bo
|
|||
return amount;
|
||||
}
|
||||
|
||||
void C4Landscape::BlastFreeShape(int *vtcs, int length, C4Object *by_object, int32_t by_player)
|
||||
void C4Landscape::BlastFreeShape(int *vtcs, int length, C4Object *by_object, int32_t by_player, int32_t iMaxDensity)
|
||||
{
|
||||
C4MaterialList *MaterialContents = NULL;
|
||||
|
||||
C4Rect BoundingBox = getBoundingBox(vtcs,length);
|
||||
|
||||
uint8_t *pblast_tbl = NULL, blast_tbl[256];
|
||||
if (iMaxDensity < C4M_Vehicle)
|
||||
{
|
||||
for (int32_t i=0; i<256; ++i) blast_tbl[i] = (GetPixDensity(i)<=iMaxDensity);
|
||||
pblast_tbl = blast_tbl;
|
||||
}
|
||||
|
||||
if(by_object)
|
||||
{
|
||||
if(!by_object->MaterialContents)
|
||||
by_object->MaterialContents = new C4MaterialList;
|
||||
ForPolygon(vtcs,length/2,&C4Landscape::BlastFreePix,by_object->MaterialContents);
|
||||
ForPolygon(vtcs,length/2,&C4Landscape::BlastFreePix,by_object->MaterialContents, 0, pblast_tbl);
|
||||
}
|
||||
else
|
||||
{
|
||||
MaterialContents = new C4MaterialList;
|
||||
ForPolygon(vtcs,length/2,&C4Landscape::BlastFreePix,MaterialContents);
|
||||
ForPolygon(vtcs,length/2,&C4Landscape::BlastFreePix,MaterialContents,iMaxDensity);
|
||||
}
|
||||
|
||||
// create objects from the material
|
||||
|
@ -1016,21 +1023,27 @@ int32_t C4Landscape::ForPolygon(int *vtcs, int length, bool (C4Landscape::*fnCal
|
|||
// Fix coordinates
|
||||
if (x1>x2) Swap(x1,x2);
|
||||
// Set line
|
||||
if (conversion_table)
|
||||
for (int xcnt=x2-x1-1; xcnt>=0; xcnt--) Surface8->SetPix(x1+xcnt, y, conversion_table[uint8_t(GetPix(x1+xcnt, y))]);
|
||||
else if(col)
|
||||
for (int xcnt=x2-x1-1; xcnt>=0; xcnt--) Surface8->SetPix(x1+xcnt, y, col);
|
||||
else
|
||||
if (fnCallback)
|
||||
{
|
||||
for (int xcnt=x2-x1-1; xcnt>=0; xcnt--)
|
||||
{
|
||||
int32_t mat = GetMat(x1+xcnt,y);
|
||||
if((this->*fnCallback)(x1+xcnt,y))
|
||||
if(mats_count)
|
||||
{
|
||||
mats_count->Add(mat,1);
|
||||
amount++;
|
||||
}
|
||||
uint8_t pix = GetPix(x1+xcnt, y);
|
||||
if (!conversion_table || conversion_table[pix])
|
||||
{
|
||||
int32_t mat = GetPixMat(pix);
|
||||
if((this->*fnCallback)(x1+xcnt,y))
|
||||
if(mats_count)
|
||||
{
|
||||
mats_count->Add(mat,1);
|
||||
amount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (conversion_table)
|
||||
for (int xcnt=x2-x1-1; xcnt>=0; xcnt--) Surface8->SetPix(x1+xcnt, y, conversion_table[uint8_t(GetPix(x1+xcnt, y))]);
|
||||
else
|
||||
for (int xcnt=x2-x1-1; xcnt>=0; xcnt--) Surface8->SetPix(x1+xcnt, y, col);
|
||||
edge = edge->next->next;
|
||||
}
|
||||
|
||||
|
|
|
@ -233,13 +233,13 @@ public:
|
|||
C4MaterialList *mats_count = NULL, int col = 0, uint8_t *conversion_table = NULL);
|
||||
|
||||
int32_t DigFreeShape(int *vtcs, int length, C4Object *by_object = NULL, bool no_dig2objects = false);
|
||||
void BlastFreeShape(int *vtcs, int length, C4Object *by_object = NULL, int32_t by_player = NO_OWNER);
|
||||
void BlastFreeShape(int *vtcs, int length, C4Object *by_object = NULL, int32_t by_player = NO_OWNER, int32_t iMaxDensity = C4M_Vehicle);
|
||||
|
||||
void ClearFreeRect(int32_t tx, int32_t ty, int32_t wdt, int32_t hgt);
|
||||
int32_t DigFreeRect(int32_t tx, int32_t ty, int32_t wdt, int32_t hgt, C4Object *by_object = NULL, bool no_dig2objects = false);
|
||||
int32_t DigFree(int32_t tx, int32_t ty, int32_t rad, C4Object *by_object = NULL, bool no_dig2objects = false);
|
||||
void ShakeFree(int32_t tx, int32_t ty, int32_t rad);
|
||||
void BlastFree(int32_t tx, int32_t ty, int32_t rad, int32_t caused_by = NO_OWNER, C4Object *by_object = NULL);
|
||||
void BlastFree(int32_t tx, int32_t ty, int32_t rad, int32_t caused_by = NO_OWNER, C4Object *by_object = NULL, int32_t iMaxDensity = C4M_Vehicle);
|
||||
|
||||
void CheckInstabilityRange(int32_t tx, int32_t ty);
|
||||
bool CheckInstability(int32_t tx, int32_t ty, int32_t recursion_count=0);
|
||||
|
|
Loading…
Reference in New Issue