forked from freudenreichan/info2Praktikum-Wortsalat
game.c todo
This commit is contained in:
1 parent
fb2f92284e
commit
83eb2bd50d
1 file changed
+4
-3
+4
-3
@@ -92,6 +92,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
||||
}
|
||||
// Sicherer lokaler Puffer für strncpy
|
||||
char currentWord[MAX_WORD_LEN];
|
||||
unsigned int placedCount = 0;
|
||||
// 2. Wörter platzieren
|
||||
for (unsigned int i = 0; i < wordCount; i++)
|
||||
{
|
||||
@@ -107,7 +108,7 @@ for (unsigned int i = 0; i < wordCount; i++)
|
||||
// Falls das Wort länger als das Spielfeld ist, abbrechen
|
||||
if (wordLen > searchFieldLen)
|
||||
{
|
||||
return -1;
|
||||
continue;
|
||||
}
|
||||
int placed = 0;
|
||||
for (int attempt = 0; attempt < MAX_RAND_TRIES_PER_WORD; attempt++)
|
||||
@@ -137,7 +138,7 @@ for (unsigned int i = 0; i < wordCount; i++)
|
||||
// Wenn das Wort nach MAX_RAND_TRIES_PER_WORD Versuchen nicht platziert werden konnte
|
||||
if (!placed)
|
||||
{
|
||||
return -1;
|
||||
placedCount++;
|
||||
}
|
||||
}
|
||||
// 3. Restliche Felder mit zufälligen Großbuchstaben ('A'-'Z') füllen
|
||||
@@ -151,5 +152,5 @@ for (unsigned int i = 0; i < wordCount; i++)
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0; // Erfolg
|
||||
return (int)placedCount; // Erfolg
|
||||
}
|
||||
Reference in new issue
Block a user