|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Jul 2005
Città: Silent Hill
Messaggi: 1471
|
Buggone di livello A: stone che non si trasformano
Il gioco crasha ad ogni partita perchè le stone non si trasformano in gemme:
Codice:
OS: Windows XP Version: 5.1 Architecture: x86 VM Vendor: Sun Microsystems Inc. Version: 1.6.0_02 Class Path: DiamondCrush.exe JNI Library Path: lib/win32 Exception: class java.util.ConcurrentModificationException Message: null Display Adapter Driver: ati2dvag 6.14.10.6606 Stacktrace: java.util.ConcurrentModificationException at java.util.AbstractList$Itr.checkForComodification(Unknown Source) at java.util.AbstractList$Itr.next(Unknown Source) at it.diamonds.grid.Grid.runIteration(Unknown Source) at it.diamonds.grid.state.StoneTurnState.update(Unknown Source) at it.diamonds.grid.state.GemsPairOnControlState.update(Unknown Source) at it.diamonds.GameTurn.update(Unknown Source) at it.diamonds.grid.GridController.update(Unknown Source) at it.diamonds.PlayField.updatePlayField(Unknown Source) at it.diamonds.PlayField.update(Unknown Source) at it.diamonds.GameLoop.updateState(Unknown Source) at it.diamonds.AbstractLoop.loopStep(Unknown Source) at it.diamonds.Game.loopStep(Unknown Source) at it.diamonds.Game.loop(Unknown Source) at it.diamonds.Game.main(Unknown Source)
__________________
DIAMOND CRUSH - Aut viam inveniam, aut faciam. |
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Oct 2002
Città: San Jose, California
Messaggi: 11794
|
Dire che stiamo andando a rilento e siamo sbadati e' un eufemismo.
Siamo proprio fermi. Allora? Questo e' un bug gravissimo che va sistemato ora. Chi se ne occupa?
__________________
"We in the game industry are lucky enough to be able to create our visions" @ NVIDIA |
|
|
|
|
|
#3 | |
|
Senior Member
Iscritto dal: Nov 2002
Città: Cosenza --> Roma
Messaggi: 853
|
Quote:
__________________
GNU MyServer Wants YOU!! We live thinking we will never die. We die thinking we had never lived. Jason Becker |
|
|
|
|
|
|
#4 |
|
Senior Member
Iscritto dal: Nov 2002
Città: Cosenza --> Roma
Messaggi: 853
|
ho introdotto un sistema di asynchronousInsertion delle droppable in Grid. Allora, test che evidenzia il bug:
Codice:
public void testNoCuncurrentModificationOnStoneTransformation()
{
try
{
Droppable anotherStone = createStone(DIAMOND);
stone.getAnimatedSprite().setCurrentFrame(5);
anotherStone.getAnimatedSprite().setCurrentFrame(5);
grid.insertDroppable(anotherStone, 5, 0);
grid.insertDroppable(stone, 5, 2);
grid.runIteration(iteration);
grid.garbageCollectDroppables();
grid.performAsynchronousInsertions();
}
catch (ConcurrentModificationException e)
{
fail();
}
}
Codice:
public void asynchronousInsertDroppable(Droppable droppable, int row, int column)
{
canInsertDroppable(droppable, row, column);
setDroppablePositionInGrid(droppable, row, column);
droppablesAsynchronousInserted.add(droppable);
}
private void setDroppablePositionInGrid(Droppable droppable, int row, int column)
{
droppable.getRegion().setRow(row);
droppable.getRegion().setColumn(column);
alignDroppableToCellUpperBound(droppable);
}
private void canInsertDroppable(Droppable droppable, int row, int column)
{
if (droppable == null)
{
throw new IllegalArgumentException();
}
if (isCellOccupiedWithNoToGarbageCollectDroppable(row, column))
{
throw new IllegalArgumentException();
}
if (droppableList.contains(droppable))
{
throw new IllegalArgumentException();
}
if (droppablesAsynchronousInserted.contains(droppable))
{
throw new IllegalArgumentException();
}
}
private boolean isCellOccupiedWithNoToGarbageCollectDroppable(int row, int column)
{
return !isCellFree(Cell.create(row, column)) && !droppablesToGarbageCollect.contains(getDroppableAt(Cell.create(row, column)));
}
public void performAsynchronousInsertions()
{
droppableList.addAll(droppablesAsynchronousInserted);
droppablesAsynchronousInserted.clear();
}
Codice:
public class TestGridAsynchronousInsertions extends GridTestCase
{
public void setUp()
{
super.setUp();
}
public void testNoSynchronousInsertion()
{
Droppable droppable = createGem(DroppableColor.DIAMOND);
grid.asynchronousInsertDroppable(droppable, 5, 0);
assertNull(grid.getDroppableAt(Cell.create(5, 0)));
}
public void testAsynchronousInsertion()
{
Droppable droppable = createGem(DroppableColor.DIAMOND);
grid.asynchronousInsertDroppable(droppable, 5, 0);
grid.performAsynchronousInsertions();
assertSame(droppable,grid.getDroppableAt(Cell.create(5, 0)));
}
public void testNoAsynchronousInsertionOnNonFreeCell()
{
Droppable droppable = createGem(DroppableColor.DIAMOND);
grid.insertDroppable(droppable, 0, 0);
try
{
grid.asynchronousInsertDroppable(droppable, 0, 0);
fail();
}
catch (IllegalArgumentException e)
{
;
}
}
public void testNoAsynchronousInsertionOfAlreadyInsertedDroppable()
{
Droppable droppable = createGem(DroppableColor.DIAMOND);
grid.insertDroppable(droppable, 0, 0);
try
{
grid.asynchronousInsertDroppable(droppable, 5, 0);
fail();
}
catch (IllegalArgumentException e)
{
;
}
}
public void testNoTwoAsynchronousInsertionOfSameDroppable()
{
Droppable droppable = createGem(DroppableColor.DIAMOND);
grid.asynchronousInsertDroppable(droppable, 0, 0);
try
{
grid.asynchronousInsertDroppable(droppable, 5, 0);
fail();
}
catch (IllegalArgumentException e)
{
;
}
}
public void testNoNullDroppableAsynchronousInserted()
{
try
{
grid.asynchronousInsertDroppable(null, 5, 0);
fail();
}
catch (IllegalArgumentException e)
{
;
}
}
public void testNoDroppableInsertionOfAlreadyAsnchronousInsertedDroppable()
{
Droppable droppable = createGem(DroppableColor.DIAMOND);
grid.asynchronousInsertDroppable(droppable, 0, 0);
try
{
grid.insertDroppable(droppable, 5, 0);
fail();
}
catch (IllegalArgumentException e)
{
;
}
}
public void testAsynchronousInsertionOnCellBeOccupiedWithToGarbageCollectDroppable()
{
Droppable droppable = createGem(DroppableColor.DIAMOND);
Droppable droppableToRemove = createGem(DroppableColor.DIAMOND);
grid.insertDroppable(droppableToRemove, 5, 0);
grid.addDroppableToGarbage(droppableToRemove);
try
{
grid.asynchronousInsertDroppable(droppable, 5, 0);
}
catch (IllegalArgumentException e)
{
fail();
}
}
public void testNoDoubleAsynchronousInsertion()
{
Droppable droppable = createGem(DroppableColor.DIAMOND);
grid.asynchronousInsertDroppable(droppable, 5, 0);
grid.performAsynchronousInsertions();
grid.performAsynchronousInsertions();
assertEquals(1, grid.getNumberOfDroppables());
}
public void testDroppableAsynchronousInsertedInRightPlace()
{
Droppable droppable = createGem(DroppableColor.DIAMOND);
grid.asynchronousInsertDroppable(droppable, 5, 3);
grid.performAsynchronousInsertions();
assertEquals(gridPosition.getX()+3*Cell.SIZE_IN_PIXELS, droppable.getAnimatedSprite().getPosition().getX());
assertEquals(gridPosition.getY()+5*Cell.SIZE_IN_PIXELS, droppable.getAnimatedSprite().getPosition().getY());
}
}
__________________
GNU MyServer Wants YOU!! We live thinking we will never die. We die thinking we had never lived. Jason Becker |
|
|
|
|
|
#5 |
|
Senior Member
Iscritto dal: Jul 2005
Città: Silent Hill
Messaggi: 1471
|
Il bug è risolto quindi? Con l'ultima build non mi si presenta.
__________________
DIAMOND CRUSH - Aut viam inveniam, aut faciam. |
|
|
|
|
|
#6 | |
|
Senior Member
Iscritto dal: Oct 2002
Città: San Jose, California
Messaggi: 11794
|
Quote:
E poi, non so veramente piu' come dirtelo, gli spazi non costano nulla, metti questi spazi attorno agli operatori e le interlinee. I tuoi metodi sono un wall text spesso incomprensibile. Inoltre: Codice:
private void canInsertDroppable(Droppable droppable, int row, int column)
{
if (droppable == null)
{
throw new IllegalArgumentException();
}
if (isCellOccupiedWithNoToGarbageCollectDroppable(row, column))
{
throw new IllegalArgumentException();
}
if (droppableList.contains(droppable))
{
throw new IllegalArgumentException();
}
if (droppablesAsynchronousInserted.contains(droppable))
{
throw new IllegalArgumentException();
}
}
In futuro sto seriamente pensando a importi alcune regole: - se scrivi un metodo in versione wall-text faccio il revert - se scrivi anche un solo if faccio il revert - se aggiungi un metodo alla classe Grid faccio il revert E poi ti spezzo le ginocchia
__________________
"We in the game industry are lucky enough to be able to create our visions" @ NVIDIA Ultima modifica di fek : 11-03-2008 alle 15:04. |
|
|
|
|
|
|
#7 | ||||
|
Senior Member
Iscritto dal: Nov 2002
Città: Cosenza --> Roma
Messaggi: 853
|
Quote:
beh dai, faceva parte del refactoring che avevo in mente di fare togliere sti metodi che ho aggiunto e il garbage collector da grid Quote:
mea culpa, cerco almeno di fare un sorce -> format prima di committare Quote:
Quote:
__________________
GNU MyServer Wants YOU!! We live thinking we will never die. We die thinking we had never lived. Jason Becker |
||||
|
|
|
|
|
#8 | |
|
Senior Member
Iscritto dal: Apr 2003
Città: Genova
Messaggi: 4747
|
Quote:
ma... ma... passare a qualcosa del tipo "for(...) droppable = droppable.transform()" senza complicarsi la vita con inserimenti asincroni ( e soprattutto eliminando una iteration ) ? non fare l' errore che faceva (e qualche volta ancora fa ) il sottoscritto, non cedere alla tentazione di aggiungere 1000 righe di codice per qualcosa che magari si può fare con una o due...
__________________
Jappilas is a character created by a friend for his own comic - I feel honored he allowed me to bear his name Saber's true name belongs to myth - a Heroic Soul out of legends, fighting in our time to fullfill her only wish Let her image remind of her story, and of the emotions that flew from my heart when i assisted to her Fate
Ultima modifica di jappilas : 11-03-2008 alle 15:44. |
|
|
|
|
|
|
#9 | |
|
Senior Member
Iscritto dal: Dec 2000
Città: bologna
Messaggi: 1309
|
Quote:
Ops. Ho appena avuto un idea geniale E' un idea che mi è venuta durante sto post, ma a braccio dovrebbe funzionare. E dovrebbe eliminare sia l'inserimento asincrono, sia il garbage collector delle gemme. |
|
|
|
|
|
|
#10 | ||||
|
Senior Member
Iscritto dal: Oct 2002
Città: San Jose, California
Messaggi: 11794
|
Quote:
Va benissimo togliere il garbage collector. Prova con il suggerimenti di jappi. Quote:
Non basta fare un format, devi proprio imparare a raggruppare il codice per blocchi logici (che poi estrarrai in metodi Quote:
Quote:
__________________
"We in the game industry are lucky enough to be able to create our visions" @ NVIDIA |
||||
|
|
|
|
|
#11 | |
|
Senior Member
Iscritto dal: Oct 2002
Città: San Jose, California
Messaggi: 11794
|
Quote:
__________________
"We in the game industry are lucky enough to be able to create our visions" @ NVIDIA |
|
|
|
|
|
|
#12 |
|
Senior Member
Iscritto dal: Oct 2002
Città: San Jose, California
Messaggi: 11794
|
Ho le lacrime agli occhi.
__________________
"We in the game industry are lucky enough to be able to create our visions" @ NVIDIA |
|
|
|
|
|
#13 | |
|
Senior Member
Iscritto dal: Jul 2005
Città: Silent Hill
Messaggi: 1471
|
Quote:
![]()
__________________
DIAMOND CRUSH - Aut viam inveniam, aut faciam. |
|
|
|
|
|
|
#14 |
|
Senior Member
Iscritto dal: Dec 2000
Città: bologna
Messaggi: 1309
|
|
|
|
|
|
|
#15 |
|
Senior Member
Iscritto dal: Oct 2002
Città: San Jose, California
Messaggi: 11794
|
A che punto siamo con questo bug?
__________________
"We in the game industry are lucky enough to be able to create our visions" @ NVIDIA |
|
|
|
|
|
#16 | |
|
Senior Member
Iscritto dal: Nov 2005
Messaggi: 1545
|
Quote:
La soluzione e` il clone della lista IMHO |
|
|
|
|
|
|
#17 | |
|
Senior Member
Iscritto dal: Dec 2000
Città: bologna
Messaggi: 1309
|
Quote:
per il clone basta fare new LinkedList(droppables). Va fatto in 2 punti del codice(quello che itera e da un altra parte, basta cercare dove viene usata la garbageDeletion). poi si toglie la garbage deletione e si rimette quella normale. Uguale per l'inserimento |
|
|
|
|
|
|
#18 | ||
|
Senior Member
Iscritto dal: Apr 2003
Città: Genova
Messaggi: 4747
|
Quote:
comunque il senso non era che *quella* fosse una soluzione perfetta, ma suggerire di cercare una soluzione (qualsiasi) rapida, che sfrutti quello che già abbiamo e il polimorfismo quanto più possibile Quote:
__________________
Jappilas is a character created by a friend for his own comic - I feel honored he allowed me to bear his name Saber's true name belongs to myth - a Heroic Soul out of legends, fighting in our time to fullfill her only wish Let her image remind of her story, and of the emotions that flew from my heart when i assisted to her Fate
Ultima modifica di jappilas : 12-03-2008 alle 14:07. |
||
|
|
|
|
|
#19 | |
|
Senior Member
Iscritto dal: Nov 2005
Città: Bologna
Messaggi: 1303
|
Quote:
E poi non c'e' gia' il metodo clone() che fa tutto? |
|
|
|
|
|
|
#20 | ||
|
Senior Member
Iscritto dal: Dec 2000
Città: bologna
Messaggi: 1309
|
perchè per iterare è più efficiente una linkedList, e perchè manco avevo visto che era un arrayList(alla fine è una lista temporanea, può essere quello che vuole)
Quote:
Quote:
btw provo a fare il refactoring |
||
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 10:41.





















