Skip to content

Commit

Permalink
Fix Windows check. Improve Windows setup instructions.
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan P. C. McQuen <[email protected]>
  • Loading branch information
Ryan P. C. McQuen committed Feb 28, 2020
1 parent 6de28d1 commit e6fb6e0
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 15 deletions.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,28 @@ brew install sdl2 sdl2_image sdl2_mixer sdl2_ttf

#### Windows:

Cmd:

```
nuget install sdl2.nuget -NonInteractive -ExcludeVersion -OutputDirectory C:\INCLUDE\ && nuget install sdl2_image.nuget -NonInteractive -ExcludeVersion -OutputDirectory C:\INCLUDE\ && nuget install sdl2_mixer.nuget -NonInteractive -ExcludeVersion -OutputDirectory C:\INCLUDE\ && nuget install sdl2_ttf.nuget -NonInteractive -ExcludeVersion -OutputDirectory C:\INCLUDE\
```

```
mkdir C:\INCLUDE\SDL2\
robocopy C:\INCLUDE\sdl2.nuget\build\native\include\ C:\INCLUDE\SDL2\
robocopy C:\INCLUDE\sdl2_image.nuget\build\native\include\ C:\INCLUDE\SDL2\
robocopy C:\INCLUDE\sdl2_mixer.nuget\build\native\include\ C:\INCLUDE\SDL2\
robocopy C:\INCLUDE\sdl2_ttf.nuget\build\native\include\ C:\INCLUDE\SDL2\
```

PowerShell:

```
nuget install sdl2.nuget -NonInteractive -ExcludeVersion -OutputDirectory C:\INCLUDE\; nuget install sdl2_image.nuget -NonInteractive -ExcludeVersion -OutputDirectory C:\INCLUDE\; nuget install sdl2_mixer.nuget -NonInteractive -ExcludeVersion -OutputDirectory C:\INCLUDE\; nuget install sdl2_ttf.nuget -NonInteractive -ExcludeVersion -OutputDirectory C:\INCLUDE\
```

```
mkdir C:\INCLUDE\SDL2\; robocopy C:\INCLUDE\sdl2.nuget\build\native\include\ C:\INCLUDE\SDL2\; robocopy C:\INCLUDE\sdl2_image.nuget\build\native\include\ C:\INCLUDE\SDL2\; robocopy C:\INCLUDE\sdl2_mixer.nuget\build\native\include\ C:\INCLUDE\SDL2\; robocopy C:\INCLUDE\sdl2_ttf.nuget\build\native\include\ C:\INCLUDE\SDL2\; if ($LASTEXITCODE -le 7) { exit 0 } else { exit 1 }
mkdir C:\INCLUDE\SDL2\; robocopy C:\INCLUDE\sdl2.nuget\build\native\include\ C:\INCLUDE\SDL2\; robocopy C:\INCLUDE\sdl2_image.nuget\build\native\include\ C:\INCLUDE\SDL2\; robocopy C:\INCLUDE\sdl2_mixer.nuget\build\native\include\ C:\INCLUDE\SDL2\; robocopy C:\INCLUDE\sdl2_ttf.nuget\build\native\include\ C:\INCLUDE\SDL2\
```

---
Expand Down
18 changes: 9 additions & 9 deletions line_count.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
cloc|github.com/AlDanial/cloc v 1.84 T=0.02 s (437.1 files/s, 83541.4 lines/s)
--- | ---

Language|files|blank|comment|code
:-------|-------:|-------:|-------:|-------:
C/C++ Header|6|206|142|971
C|1|5|0|14
--------|--------|--------|--------|--------
SUM:|7|211|142|985
cloc|github.com/AlDanial/cloc v 1.84 T=0.50 s (14.0 files/s, 2680.0 lines/s)
--- | ---

Language|files|blank|comment|code
:-------|-------:|-------:|-------:|-------:
C/C++ Header|6|206|142|973
C|1|5|0|14
--------|--------|--------|--------|--------
SUM:|7|211|142|987
2 changes: 1 addition & 1 deletion source/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ char* get_multiplier(char* attribute)
{
char* attribute_copy = (char*)calloc(strlen(attribute), sizeof(char));
if (attribute_copy != NULL) {
#if PLATFORM_IS_WINDOWS
#ifdef PLATFORM_IS_WINDOWS
strcpy_s(attribute_copy, sizeof(attribute), &attribute[1]);
strcpy_s(attribute, sizeof(attribute_copy), &attribute_copy[0]);
#else
Expand Down
2 changes: 1 addition & 1 deletion source/mechanics.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ int write_map_layout(GameState* game)
FILE* new_map_layout;
FILE* old_map_layout;
FILE* map_lock;
#if PLATFORM_IS_WINDOWS
#ifdef PLATFORM_IS_WINDOWS
fopen_s(&new_map_layout, new_map_layout_file, "wb");
fopen_s(&old_map_layout, game->map.layout_file, "wb");
fopen_s(&map_lock, MAP_LOCK_FILE, "wb");
Expand Down
8 changes: 5 additions & 3 deletions source/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#include <sys/stat.h>
#include <time.h>

#if defined(_WIN64) || defined(_WIN32) || defined(__WIN32__) || defined(__WINRT__)
#define PLATFORM_IS_WINDOWS
#endif

int file_exists(char* path)
{
struct stat filestat;
Expand All @@ -19,12 +23,10 @@ time_t read_file_time(char* path)
return filestat.st_mtime;
}

#define PLATFORM_IS_WINDOWS() defined(_WIN64) || defined(_WIN32) || defined(__WIN32__) || defined(__WINRT__)

char* read_file(char* path)
{
FILE* file_to_read;
#if PLATFORM_IS_WINDOWS
#ifdef PLATFORM_IS_WINDOWS
fopen_s(&file_to_read, path, "rb");
#else
file_to_read = fopen(path, "rb");
Expand Down

0 comments on commit e6fb6e0

Please sign in to comment.