Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing casts and remove FloatMath methods calls #93

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/com/watabou/pixeldungeon/actors/mobs/Mimic.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void storeInBundle( Bundle bundle ) {
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle );
items = new ArrayList<Item>( (Collection<? extends Item>) bundle.getCollection( ITEMS ) );
items = new ArrayList<Item>( (Collection<? extends Item>)(Object) bundle.getCollection( ITEMS ) );
adjustStats( bundle.getInt( LEVEL ) );
}

Expand Down
8 changes: 4 additions & 4 deletions src/com/watabou/pixeldungeon/effects/Flare.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ public Flare( int nRays, float radius ) {
for (int i=0; i < nRays; i++) {

float a = i * 3.1415926f * 2 / nRays;
v[0] = FloatMath.cos( a ) * radius;
v[1] = FloatMath.sin( a ) * radius;
v[0] = (float)Math.cos( a ) * radius;
v[1] = (float)Math.sin( a ) * radius;
vertices.put( v );

a += 3.1415926f * 2 / nRays / 2;
Comment on lines 89 to 94

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our static analysis engine detects that your pull request includes a change that uses the rough value of Math.PI. According to the best practice, it's recommended to use the predefined library constant for code clarity and better precision.

v[0] = FloatMath.cos( a ) * radius;
v[1] = FloatMath.sin( a ) * radius;
v[0] = (float)Math.cos( a ) * radius;
v[1] = (float)Math.sin( a ) * radius;
vertices.put( v );

indices.put( (short)0 );
Expand Down
6 changes: 3 additions & 3 deletions src/com/watabou/pixeldungeon/effects/Speck.java
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,9 @@ public void update() {
break;

case CHANGE:
am = (float)FloatMath.sqrt( (p < 0.5f ? p : 1 - p) * 2);
am = (float) Math.sqrt( (p < 0.5f ? p : 1 - p) * 2);
scale.y = (1 + p) * 0.5f;
scale.x = scale.y * FloatMath.cos( left * 15 );
scale.x = scale.y * (float) Math.cos( left * 15 );
break;

case HEART:
Expand All @@ -401,7 +401,7 @@ public void update() {
break;

case COIN:
scale.x = FloatMath.cos( left * 5 );
scale.x = (float) Math.cos( left * 5 );
rm = gm = bm = (Math.abs( scale.x ) + 1) * 0.5f;
am = p < 0.9f ? 1 : (1 - p) * 10;
break;
Expand Down
2 changes: 1 addition & 1 deletion src/com/watabou/pixeldungeon/items/Heap.java
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ public void destroy() {
public void restoreFromBundle( Bundle bundle ) {
pos = bundle.getInt( POS );
type = Type.valueOf( bundle.getString( TYPE ) );
items = new LinkedList<Item>( (Collection<? extends Item>) bundle.getCollection( ITEMS ) );
items = new LinkedList<Item>( (Collection<? extends Item>)(Object) bundle.getCollection( ITEMS ) );
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/com/watabou/pixeldungeon/levels/RegularLevel.java
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ public void storeInBundle( Bundle bundle ) {
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle );

rooms = new HashSet<Room>( (Collection<? extends Room>) bundle.getCollection( "rooms" ) );
rooms = new HashSet<Room>( (Collection<? extends Room>)(Object) bundle.getCollection( "rooms" ) );
for (Room r : rooms) {
if (r.type == Type.WEAK_FLOOR) {
weakFloorCreated = true;
Expand Down