Skip to content

Commit

Permalink
Fixed bug with loading.
Browse files Browse the repository at this point in the history
  • Loading branch information
CubedProgrammer committed Jul 17, 2021
1 parent f57465e commit ae47a84
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
2 changes: 2 additions & 0 deletions ClickPatternReplicator/ClickPatternReplicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ int main(int argl, char *argv[])
{
std::cin >> tmp;
LoadClickPattern(&clicks, tmp.c_str());
std::cout << "Loaded pattern." << std::endl;
}
else if (cmd == "play")
{
Expand All @@ -63,6 +64,7 @@ int main(int argl, char *argv[])
break;
}
SendInput(2, mi, sizeof(mi[0]));
Sleep(100);
}
}
std::cin >> cmd;
Expand Down
3 changes: 2 additions & 1 deletion ClickPatternReplicator/ClickPatternReplicator.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand Down
22 changes: 9 additions & 13 deletions ClickPatternReplicator/SaveLoad.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,21 @@ void LoadClickPattern(struct Click** pattern, const char* fname)
size_t capa = 5, ocapa = 3;
struct Click* arr = malloc(capa * sizeof(struct Click));
struct Click* tmp;
FILE* fh = fopen(fname, "e");
FILE* fh = fopen(fname, "r");
char str[20];
char* remains;
struct Click click;
fscanf(fh, "%s", str);
while (strcmp(str, "end"))
{
scanf("%s\n", str);
remains = strchr(str, ' ');
*remains = '\0';
++remains;
click.x = atoi(str);
remains = strchr(remains, ' ');
*remains = '\0';
++remains;
click.y = atoi(remains);
if (strcmp(remains, "left") == 0)
fscanf(fh, "%s", str);
click.y = atoi(str);
fscanf(fh, "%s", str);
if (strcmp(str, "left") == 0)
click.button = LBUTTON;
else if (strcmp(remains, "middle") == 0)
else if (strcmp(str, "middle") == 0)
click.button = MBUTTON;
else if (strcmp(remains, "right") == 0)
else if (strcmp(str, "right") == 0)
click.button = RBUTTON;
if (capa == len)
{
Expand All @@ -46,6 +41,7 @@ void LoadClickPattern(struct Click** pattern, const char* fname)
}
arr[len] = click;
++len;
fscanf(fh, "%s", str);
}
fclose(fh);

Expand Down

0 comments on commit ae47a84

Please sign in to comment.