Skip to content

Commit ae47a84

Browse files
Fixed bug with loading.
1 parent f57465e commit ae47a84

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

ClickPatternReplicator/ClickPatternReplicator.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ int main(int argl, char *argv[])
3838
{
3939
std::cin >> tmp;
4040
LoadClickPattern(&clicks, tmp.c_str());
41+
std::cout << "Loaded pattern." << std::endl;
4142
}
4243
else if (cmd == "play")
4344
{
@@ -63,6 +64,7 @@ int main(int argl, char *argv[])
6364
break;
6465
}
6566
SendInput(2, mi, sizeof(mi[0]));
67+
Sleep(100);
6668
}
6769
}
6870
std::cin >> cmd;

ClickPatternReplicator/ClickPatternReplicator.vcxproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,9 @@
129129
<FunctionLevelLinking>true</FunctionLevelLinking>
130130
<IntrinsicFunctions>true</IntrinsicFunctions>
131131
<SDLCheck>true</SDLCheck>
132-
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
132+
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
133133
<ConformanceMode>true</ConformanceMode>
134+
<LanguageStandard>stdcpp17</LanguageStandard>
134135
</ClCompile>
135136
<Link>
136137
<SubSystem>Console</SubSystem>

ClickPatternReplicator/SaveLoad.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,21 @@ void LoadClickPattern(struct Click** pattern, const char* fname)
1616
size_t capa = 5, ocapa = 3;
1717
struct Click* arr = malloc(capa * sizeof(struct Click));
1818
struct Click* tmp;
19-
FILE* fh = fopen(fname, "e");
19+
FILE* fh = fopen(fname, "r");
2020
char str[20];
21-
char* remains;
2221
struct Click click;
22+
fscanf(fh, "%s", str);
2323
while (strcmp(str, "end"))
2424
{
25-
scanf("%s\n", str);
26-
remains = strchr(str, ' ');
27-
*remains = '\0';
28-
++remains;
2925
click.x = atoi(str);
30-
remains = strchr(remains, ' ');
31-
*remains = '\0';
32-
++remains;
33-
click.y = atoi(remains);
34-
if (strcmp(remains, "left") == 0)
26+
fscanf(fh, "%s", str);
27+
click.y = atoi(str);
28+
fscanf(fh, "%s", str);
29+
if (strcmp(str, "left") == 0)
3530
click.button = LBUTTON;
36-
else if (strcmp(remains, "middle") == 0)
31+
else if (strcmp(str, "middle") == 0)
3732
click.button = MBUTTON;
38-
else if (strcmp(remains, "right") == 0)
33+
else if (strcmp(str, "right") == 0)
3934
click.button = RBUTTON;
4035
if (capa == len)
4136
{
@@ -46,6 +41,7 @@ void LoadClickPattern(struct Click** pattern, const char* fname)
4641
}
4742
arr[len] = click;
4843
++len;
44+
fscanf(fh, "%s", str);
4945
}
5046
fclose(fh);
5147

0 commit comments

Comments
 (0)