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
Sven Eberhardt 2013-03-26 00:45:44 +01:00
parent 671a815223
commit c115fbfaa0
15 changed files with 49 additions and 34 deletions

View File

@ -1,7 +1,7 @@
[Material]
Name=Brick
Shape=Smoother
Density=50
Density=90
Friction=15
Placement=80
TextureOverlay=brick1

View File

@ -1,7 +1,7 @@
[Material]
Name=BrickSoft
Shape=Smoother
Density=50
Density=90
Friction=15
Placement=60
TextureOverlay=brick1

View File

@ -1,7 +1,7 @@
[Material]
Name=Coal
Shape=Rough
Density=50
Density=60
Friction=75
DigFree=1
BlastFree=1

View File

@ -1,7 +1,7 @@
[Material]
Name=Earth
Shape=Smooth
Density=50
Density=60
Friction=80
DigFree=1
BlastFree=1

View File

@ -1,7 +1,7 @@
[Material]
Name=Gold
Shape=Rough
Density=50
Density=70
Friction=100
BlastFree=1
Blast2Object=Nugget

View File

@ -1,7 +1,7 @@
[Material]
Name=Granite
Shape=Rough
Density=50
Density=80
Friction=100
MaxAirSpeed=100
MaxSlide=250

View File

@ -1,7 +1,7 @@
[Material]
Name=Ice
Shape=TopFlat
Density=50
Density=60
Friction=15
DigFree=1
BlastFree=1

View File

@ -1,7 +1,7 @@
[Material]
Name=Ore
Shape=Rough
Density=50
Density=70
Friction=100
BlastFree=1
Blast2Object=Ore

View File

@ -1,7 +1,7 @@
[Material]
Name=Rock
Shape=Rough
Density=50
Density=70
Friction=100
BlastFree=1
Blast2Object=Rock

View File

@ -1,7 +1,7 @@
[Material]
Name=Sand
Shape=Smooth
Density=50
Density=60
Friction=80
DigFree=1
BlastFree=1

View File

@ -1,7 +1,7 @@
[Material]
Name=Sulphur
Shape=Rough
Density=50
Density=60
Friction=75
DigFree=1
BlastFree=1

View File

@ -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;

View File

@ -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();
}

View File

@ -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;
}

View File

@ -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);