game.c todo

This commit is contained in:
David committed 2026-10-19 09:27:05 +02:00
1 parent fb2f92284e
commit 83eb2bd50d
1 file changed
+4 -3
+4 -3
View File
@@ -92,6 +92,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
} }
// Sicherer lokaler Puffer für strncpy // Sicherer lokaler Puffer für strncpy
char currentWord[MAX_WORD_LEN]; char currentWord[MAX_WORD_LEN];
unsigned int placedCount = 0;
// 2. Wörter platzieren // 2. Wörter platzieren
for (unsigned int i = 0; i < wordCount; i++) 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 // Falls das Wort länger als das Spielfeld ist, abbrechen
if (wordLen > searchFieldLen) if (wordLen > searchFieldLen)
{ {
return -1; continue;
} }
int placed = 0; int placed = 0;
for (int attempt = 0; attempt < MAX_RAND_TRIES_PER_WORD; attempt++) 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 // Wenn das Wort nach MAX_RAND_TRIES_PER_WORD Versuchen nicht platziert werden konnte
if (!placed) if (!placed)
{ {
return -1; placedCount++;
} }
} }
// 3. Restliche Felder mit zufälligen Großbuchstaben ('A'-'Z') füllen // 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
} }