From 83eb2bd50d53c6a0265c61c63803d605f0add5dd Mon Sep 17 00:00:00 2001 From: David Date: Mon, 19 Oct 2026 09:27:05 +0200 Subject: [PATCH] game.c todo --- Startcode/game.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Startcode/game.c b/Startcode/game.c index 098f225..12d4170 100644 --- a/Startcode/game.c +++ b/Startcode/game.c @@ -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 } \ No newline at end of file