Ja, natürlich beschuldige ich nicht die STL. Ich hatte nur vorher noch nie ein ähnliches Problem
@FauleSocke: Ich verstehe nicht. Ich habe den ganauesten Punkt angegeben, den der Debugger in c++-code anzeigen kann. Was kannst du denn noch brauchen? soll ich den gesamten quellcode ins Internet stellen? Der ist ziemlich chaotisch und unschön. oder die Debug-exe?
Also: hier ist die Funktion, die einen neuen virtuellen(?) Zug startet:
Ich hab jezt ned alles kommentiert und will auch jetzt nicht jede einzelne Funktion genau erläutern, ich hoffe das wichtigste ist klar.
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
void CGame::StartTryDraw(){
list<CPiece>::iterator It;
vector<sBoardCopy>::iterator It2;
if (TryDrawDebug == 0){ // TryDrawDebug enthält anzahl der virtuellen Züge
if (m_pHand){ // Figur in der "Hand" des Spielers (die er angeklickt hat)
m_HandCopy = *m_pHand; // OK, alles kommentiere ich jetzt nicht
m_pHand=NULL;
}else{
m_HandCopy.X=-1;
}
}
// Das kennt ihr ja bereits schon
sBoardCopy BC;
BC.Pieces = Pieces; // Absturzstelle
BC.bTurn = m_bTurn;
BC.DrawNumber = m_DrawNumber;
m_BoardCopy.push_back(BC);
It2 = m_BoardCopy.end();
It2 --;
Pcs = &It2->Pieces;
for (int i=0; i<8; i++){
for (int j=0; j<8; j++){
m_Board[i][j] = NULL; // CPiece *m_Board[8][8] ist das Schachbrett
}
}
//so, jetzt wirds richtig schirch
for (It = Pcs->ListBlack.begin(); It!=Pcs->ListBlack.end(); It++){
if (TryDrawDebug == 0){ // Erster Virtueller Zug
if (It->X == m_HandCopy.X && It->Y == m_HandCopy.Y)
m_pHand = &(*It);
}
m_Board[It->X][It->Y] = &(*It);
}
for (It = Pcs->ListWhite.begin(); It!=Pcs->ListWhite.end(); It++){
if (TryDrawDebug == 0){
if (It->X == m_HandCopy.X && It->Y == m_HandCopy.Y)
m_pHand = &(*It);
}
m_Board[It->X][It->Y] = &(*It);
}
for (PVIt = PVars.begin(); PVIt != PVars.end(); PVIt++){
if (PVIt->second.X >= 0){
// FindPieceInCopy liefert im "Virtuellsten" Zug den Spielstein mit den selben Werten
PVIt->second = *FindPieceInCopy(&(PVIt->second));
if (PVIt->second.X < 0) cout << "Not in Copy: "<<PVIt->first;
else cout << "Done: "<<PVIt->first;
}else{cout << "Nullzeiger: "<<PVIt->first;}
}
TryDrawDebug ++;
}
|
und hier wird der virtuelle Zug wieder gelöscht:
Mein Gott, furchtbar. Ich sollte vlt doch das ganze Programm neu schreiben. Aber ich bin halt schon fast fertig
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
void CGame::EndTryDraw(){
m_bMate = false;
if (TryDrawDebug <= 0)
cout << "Oups";
vector<sBoardCopy>::iterator Pt;
Pt = m_BoardCopy.end();
Pt--;
m_bTurn = Pt->bTurn;
m_DrawNumber = Pt->DrawNumber;
m_BoardCopy.pop_back();
TryDrawDebug --;
if (TryDrawDebug == 0){
Pcs = &Pieces;
}else{
vector<sBoardCopy>::iterator Pt;
Pt = m_BoardCopy.end();
Pt--;
Pcs = &Pt->Pieces;
}
for (int i=0; i<8; i++){
for (int j=0; j<8; j++){
m_Board[i][j] = NULL;
}
}
list<CPiece>::iterator It;
for (It = Pieces.ListBlack.begin(); It!=Pieces.ListBlack.end(); It++){
if (TryDrawDebug == 0){
if (It->X == m_HandCopy.X && It->Y == m_HandCopy.Y)
m_pHand = &(*It);
}
m_Board[It->X][It->Y] = &(*It);
}
for (It = Pieces.ListWhite.begin(); It!=Pieces.ListWhite.end(); It++){
if (TryDrawDebug == 0){
if (It->X == m_HandCopy.X && It->Y == m_HandCopy.Y)
m_pHand = &(*It);
}
m_Board[It->X][It->Y] = &(*It);
}
// Im Folgenden geht es um Variablen im KI-Skript, die Spielsteine Enthalten.
for (PVIt = PVars.begin(); PVIt != PVars.end(); PVIt++){
PVIt->second = *FindPieceInCopy(&(PVIt->second));
}
}
|