Format Project

This commit is contained in:
Tobias Linz committed 2026-10-29 16:00:21 +01:00
1 parent 4a7d34044b
commit e94da31756
4 files changed
+24 -30

No files matched your search

+4 -19
View File
@@ -1,45 +1,30 @@
# clang-format-Konfiguration, abgeleitet aus dem bestehenden Wortsalat-Code
BasedOnStyle: LLVM BasedOnStyle: LLVM
# Einrückung: 4 Leerzeichen, keine Tabs
IndentWidth: 4 IndentWidth: 4
TabWidth: 4 TabWidth: 4
UseTab: Never UseTab: Never
ContinuationIndentWidth: 4 ContinuationIndentWidth: 4
# Allman-Stil: geschweifte Klammern für Funktionen, Schleifen, if/else stehen in eigenen Zeilen
BreakBeforeBraces: Allman BreakBeforeBraces: Allman
# Keine automatischen Zeilenumbrüche, der Code bricht lange Zeilen bereits selbst um
ColumnLimit: 0 ColumnLimit: 0
ReflowComments: false ReflowComments: false
# Zeiger-Sternchen rechts: char *word, SearchWord *words
PointerAlignment: Right PointerAlignment: Right
DerivePointerAlignment: false DerivePointerAlignment: false
# Kein Leerzeichen vor der Klammer bei if/for/while und bei Funktionsaufrufen
SpaceBeforeParens: Custom
SpaceBeforeParensOptions:
AfterControlStatements: false
AfterFunctionDeclarationName: false
AfterFunctionDefinitionName: false
SpaceAfterCStyleCast: false
# Kurze Konstrukte bleiben mehrzeilig
AllowShortIfStatementsOnASingleLine: Never AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false AllowShortLoopsOnASingleLine: false
AllowShortBlocksOnASingleLine: Never AllowShortBlocksOnASingleLine: Never
AllowShortFunctionsOnASingleLine: None AllowShortFunctionsOnASingleLine: None
AllowShortCaseLabelsOnASingleLine: false AllowShortCaseLabelsOnASingleLine: false
# Geschweifte Initialisierer: {0, 0} InsertBraces: true
Cpp11BracedListStyle: true Cpp11BracedListStyle: true
# Includes nicht umsortieren (Reihenfolge ist teils bewusst gewählt) SortIncludes: CaseSensitive
SortIncludes: Never IncludeBlocks: Regroup
IncludeBlocks: Preserve
# Leerzeilen
MaxEmptyLinesToKeep: 2 MaxEmptyLinesToKeep: 2
KeepEmptyLinesAtTheStartOfBlocks: true KeepEmptyLinesAtTheStartOfBlocks: true
+11 -2
View File
@@ -1,8 +1,9 @@
#include "game.h" #include "game.h"
#include <time.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <time.h>
#define MAX_RAND_TRIES_PER_WORD 10 #define MAX_RAND_TRIES_PER_WORD 10
#define EMPTY_CHAR 0 #define EMPTY_CHAR 0
@@ -19,7 +20,9 @@ int createWordSalad(
unsigned int wordCount) unsigned int wordCount)
{ {
if (searchFieldLen == 0 || searchFieldLen > MAX_SEARCH_FIELD_LEN) if (searchFieldLen == 0 || searchFieldLen > MAX_SEARCH_FIELD_LEN)
{
return 0; return 0;
}
int placedWords = 0; int placedWords = 0;
@@ -27,8 +30,12 @@ int createWordSalad(
// Spielfeld leeren: // Spielfeld leeren:
for (int x = 0; x < searchFieldLen; x++) for (int x = 0; x < searchFieldLen; x++)
{
for (int y = 0; y < searchFieldLen; y++) for (int y = 0; y < searchFieldLen; y++)
{
salad[x][y] = EMPTY_CHAR; salad[x][y] = EMPTY_CHAR;
}
}
// Wörter platzieren // Wörter platzieren
@@ -37,7 +44,9 @@ int createWordSalad(
int wordlenght = strlen(words[w]); // Wortlänge festgelegt int wordlenght = strlen(words[w]); // Wortlänge festgelegt
if (wordlenght == 0 || wordlenght > searchFieldLen) if (wordlenght == 0 || wordlenght > searchFieldLen)
{
continue; continue;
}
for (int attempts = 0; for (int attempts = 0;
attempts < MAX_RAND_TRIES_PER_WORD; attempts < MAX_RAND_TRIES_PER_WORD;
+5 -6
View File
@@ -1,14 +1,17 @@
#include "input.h" #include "input.h"
#include <string.h> #include <string.h>
int readWord(char *buffer, char *divisor, char words[][MAX_WORD_LEN], unsigned int maxWordCount, int *count); int readWord(char *buffer, char *divisor, char words[][MAX_WORD_LEN], unsigned int maxWordCount, int *count);
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) { int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
{
char buffer[MAX_LINE_LEN]; char buffer[MAX_LINE_LEN];
int count = 0; int count = 0;
char *divisor = " ,;.\n"; char *divisor = " ,;.\n";
while (fgets(buffer, MAX_LINE_LEN, file) != NULL) { while (fgets(buffer, MAX_LINE_LEN, file) != NULL)
{
for (char *word = strtok(buffer, divisor); word != NULL && count < maxWordCount; word = strtok(NULL, divisor)) for (char *word = strtok(buffer, divisor); word != NULL && count < maxWordCount; word = strtok(NULL, divisor))
{ {
strncpy(words[count], word, MAX_WORD_LEN); strncpy(words[count], word, MAX_WORD_LEN);
@@ -17,7 +20,3 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
} }
return count; return count;
} }
+4 -3
View File
@@ -1,8 +1,9 @@
#include <stdlib.h>
#include <stdio.h>
#include "input.h"
#include "game.h" #include "game.h"
#include "graphicalGame.h" #include "graphicalGame.h"
#include "input.h"
#include <stdio.h>
#include <stdlib.h>
#define MAX_NUMBER_OF_WORDS 100 #define MAX_NUMBER_OF_WORDS 100
#define SALAD_SIZE 20 #define SALAD_SIZE 20