Skip to content

Commit a858709

Browse files
committed
conf.cpp: change to Unix line endings like other source files
1 parent 9c14eeb commit a858709

File tree

2 files changed

+226
-226
lines changed

2 files changed

+226
-226
lines changed

conf.cpp

Lines changed: 183 additions & 183 deletions
Original file line numberDiff line numberDiff line change
@@ -1,183 +1,183 @@
1-
#include <stdio.h>
2-
3-
#include "conf.h"
4-
#include "spec.h"
5-
#include "menu.h"
6-
7-
// open file?
8-
// how does it work in browsers?
9-
10-
ConfCampaign conf_campaign=
11-
{
12-
0,0,0
13-
};
14-
15-
ConfKeyboard conf_keyboard=
16-
{
17-
{'A','D','W','S','L','Q'}
18-
};
19-
20-
ConfPlayer conf_player=
21-
{
22-
"Player 1",
23-
0x00000000
24-
};
25-
26-
ConfControl conf_control=
27-
{
28-
16,
29-
16,
30-
0,
31-
1
32-
};
33-
34-
struct ConfFile1
35-
{
36-
struct Campaign
37-
{
38-
int course;
39-
int level;
40-
} conf_campaign;
41-
ConfKeyboard conf_keyboard;
42-
ConfPlayer conf_player;
43-
};
44-
45-
struct ConfFile2
46-
{
47-
ConfCampaign conf_campaign;
48-
ConfKeyboard conf_keyboard;
49-
ConfPlayer conf_player;
50-
};
51-
52-
struct ConfFile3
53-
{
54-
ConfCampaign conf_campaign;
55-
ConfKeyboard conf_keyboard;
56-
ConfPlayer conf_player;
57-
ConfControl conf_control;
58-
};
59-
60-
void LoadConf()
61-
{
62-
FILE* f=0;
63-
fopen_s(&f,conf_path(),"rb");
64-
if (!f)
65-
return;
66-
67-
int version=0;
68-
int ret = fread(&version,4,1,f);
69-
if (ret!=1)
70-
{
71-
fclose(f);
72-
return;
73-
}
74-
75-
if (version==1)
76-
{
77-
ConfFile1 conf;
78-
int ret = fread(&conf,sizeof(ConfFile1),1,f);
79-
fclose(f);
80-
81-
if (ret != 1)
82-
return;
83-
84-
conf_campaign.passed = 0;
85-
conf_campaign.course = 0;
86-
conf_campaign.level = 0;
87-
conf_keyboard = conf.conf_keyboard;
88-
conf_player = conf.conf_player;
89-
90-
conf_control.mus_vol=16;
91-
conf_control.sfx_vol=16;
92-
conf_control.sticky=0;
93-
conf_control.color=1;
94-
}
95-
96-
if (version==2)
97-
{
98-
ConfFile2 conf;
99-
int ret = fread(&conf,sizeof(ConfFile2),1,f);
100-
fclose(f);
101-
102-
if (ret != 1)
103-
return;
104-
105-
conf_campaign = conf.conf_campaign;
106-
conf_keyboard = conf.conf_keyboard;
107-
conf_player = conf.conf_player;
108-
109-
conf_control.mus_vol=16;
110-
conf_control.sfx_vol=16;
111-
conf_control.sticky=0;
112-
conf_control.color=1;
113-
}
114-
115-
if (version==3)
116-
{
117-
ConfFile3 conf;
118-
int ret = fread(&conf,sizeof(ConfFile3),1,f);
119-
fclose(f);
120-
121-
if (ret != 1)
122-
return;
123-
124-
conf_campaign = conf.conf_campaign;
125-
conf_keyboard = conf.conf_keyboard;
126-
conf_player = conf.conf_player;
127-
conf_control = conf.conf_control;
128-
}
129-
130-
conf_campaign.course=0;
131-
conf_campaign.level=0;
132-
conf_campaign.passed=2;
133-
134-
135-
LoadMenu();
136-
}
137-
138-
void SaveConf()
139-
{
140-
FILE* f=0;
141-
fopen_s(&f,conf_path(),"wb");
142-
143-
if (!f)
144-
return;
145-
146-
int version = 3;
147-
fwrite(&version,4,1,f);
148-
149-
ConfFile3 conf;
150-
conf.conf_campaign = conf_campaign;
151-
conf.conf_keyboard = conf_keyboard;
152-
conf.conf_player = conf_player;
153-
conf.conf_control = conf_control;
154-
155-
fwrite(&conf,sizeof(ConfFile3),1,f);
156-
fclose(f);
157-
158-
write_fs();
159-
}
160-
161-
char ConfMapInput(char c)
162-
{
163-
static const char m[6]=
164-
{
165-
KBD_LT,KBD_RT,KBD_UP,KBD_DN,13,27
166-
};
167-
168-
while (1)
169-
{
170-
for (int i=0; i<6; i++)
171-
{
172-
if (conf_keyboard.map[i] == c)
173-
return m[i];
174-
}
175-
176-
if (c>='a' && c<='z')
177-
c+='A'-'a';
178-
else
179-
break;
180-
}
181-
182-
return c;
183-
}
1+
#include <stdio.h>
2+
3+
#include "conf.h"
4+
#include "spec.h"
5+
#include "menu.h"
6+
7+
// open file?
8+
// how does it work in browsers?
9+
10+
ConfCampaign conf_campaign=
11+
{
12+
0,0,0
13+
};
14+
15+
ConfKeyboard conf_keyboard=
16+
{
17+
{'A','D','W','S','L','Q'}
18+
};
19+
20+
ConfPlayer conf_player=
21+
{
22+
"Player 1",
23+
0x00000000
24+
};
25+
26+
ConfControl conf_control=
27+
{
28+
16,
29+
16,
30+
0,
31+
1
32+
};
33+
34+
struct ConfFile1
35+
{
36+
struct Campaign
37+
{
38+
int course;
39+
int level;
40+
} conf_campaign;
41+
ConfKeyboard conf_keyboard;
42+
ConfPlayer conf_player;
43+
};
44+
45+
struct ConfFile2
46+
{
47+
ConfCampaign conf_campaign;
48+
ConfKeyboard conf_keyboard;
49+
ConfPlayer conf_player;
50+
};
51+
52+
struct ConfFile3
53+
{
54+
ConfCampaign conf_campaign;
55+
ConfKeyboard conf_keyboard;
56+
ConfPlayer conf_player;
57+
ConfControl conf_control;
58+
};
59+
60+
void LoadConf()
61+
{
62+
FILE* f=0;
63+
fopen_s(&f,conf_path(),"rb");
64+
if (!f)
65+
return;
66+
67+
int version=0;
68+
int ret = fread(&version,4,1,f);
69+
if (ret!=1)
70+
{
71+
fclose(f);
72+
return;
73+
}
74+
75+
if (version==1)
76+
{
77+
ConfFile1 conf;
78+
int ret = fread(&conf,sizeof(ConfFile1),1,f);
79+
fclose(f);
80+
81+
if (ret != 1)
82+
return;
83+
84+
conf_campaign.passed = 0;
85+
conf_campaign.course = 0;
86+
conf_campaign.level = 0;
87+
conf_keyboard = conf.conf_keyboard;
88+
conf_player = conf.conf_player;
89+
90+
conf_control.mus_vol=16;
91+
conf_control.sfx_vol=16;
92+
conf_control.sticky=0;
93+
conf_control.color=1;
94+
}
95+
96+
if (version==2)
97+
{
98+
ConfFile2 conf;
99+
int ret = fread(&conf,sizeof(ConfFile2),1,f);
100+
fclose(f);
101+
102+
if (ret != 1)
103+
return;
104+
105+
conf_campaign = conf.conf_campaign;
106+
conf_keyboard = conf.conf_keyboard;
107+
conf_player = conf.conf_player;
108+
109+
conf_control.mus_vol=16;
110+
conf_control.sfx_vol=16;
111+
conf_control.sticky=0;
112+
conf_control.color=1;
113+
}
114+
115+
if (version==3)
116+
{
117+
ConfFile3 conf;
118+
int ret = fread(&conf,sizeof(ConfFile3),1,f);
119+
fclose(f);
120+
121+
if (ret != 1)
122+
return;
123+
124+
conf_campaign = conf.conf_campaign;
125+
conf_keyboard = conf.conf_keyboard;
126+
conf_player = conf.conf_player;
127+
conf_control = conf.conf_control;
128+
}
129+
130+
conf_campaign.course=0;
131+
conf_campaign.level=0;
132+
conf_campaign.passed=2;
133+
134+
135+
LoadMenu();
136+
}
137+
138+
void SaveConf()
139+
{
140+
FILE* f=0;
141+
fopen_s(&f,conf_path(),"wb");
142+
143+
if (!f)
144+
return;
145+
146+
int version = 3;
147+
fwrite(&version,4,1,f);
148+
149+
ConfFile3 conf;
150+
conf.conf_campaign = conf_campaign;
151+
conf.conf_keyboard = conf_keyboard;
152+
conf.conf_player = conf_player;
153+
conf.conf_control = conf_control;
154+
155+
fwrite(&conf,sizeof(ConfFile3),1,f);
156+
fclose(f);
157+
158+
write_fs();
159+
}
160+
161+
char ConfMapInput(char c)
162+
{
163+
static const char m[6]=
164+
{
165+
KBD_LT,KBD_RT,KBD_UP,KBD_DN,13,27
166+
};
167+
168+
while (1)
169+
{
170+
for (int i=0; i<6; i++)
171+
{
172+
if (conf_keyboard.map[i] == c)
173+
return m[i];
174+
}
175+
176+
if (c>='a' && c<='z')
177+
c+='A'-'a';
178+
else
179+
break;
180+
}
181+
182+
return c;
183+
}

0 commit comments

Comments
 (0)